Untitled
unknown
plain_text
a year ago
3.9 kB
6
Indexable
res_table = [] # список строк со всеми значениями ячеек current_row = [] # значения ячеек текущей строки for table in extracted_tables: # цикл по всем таблицам for row in table.content.values(): # цикл по всем строкам for cell in row: # цикл по всем столбцам crop = table_img[cell.bbox.y1:cell.bbox.y2, cell.bbox.x1:cell.bbox.x2] # берем ячейку result = reader.readtext(crop) # координаты bounding boxes, распознанный текст в них и вероятность txt = "\n".join([elem[1] for elem in result]) # распознанный текст из всех bounding boxes txt_n = txt.replace('\n',' ') # распознанный текст без переноса строк current_row.append(txt_n) res_table.append(current_row) current_row = [] --------------------------------------------------------------------------- error Traceback (most recent call last) Input In [175], in <cell line: 3>() 5 for cell in row: # цикл по всем столбцам 6 crop = table_img[cell.bbox.y1:cell.bbox.y2, cell.bbox.x1:cell.bbox.x2] # берем ячейку ----> 7 result = reader.readtext(crop) # координаты bounding boxes, распознанный текст в них и вероятность 8 txt = "\n".join([elem[1] for elem in result]) # распознанный текст из всех bounding boxes 9 txt_n = txt.replace('\n',' ') # распознанный текст без переноса строк File /opt/conda/lib/python3.8/site-packages/easyocr/easyocr.py:454, in Reader.readtext(self, image, decoder, beamWidth, batch_size, workers, allowlist, blocklist, detail, rotation_info, paragraph, min_size, contrast_ths, adjust_contrast, filter_ths, text_threshold, low_text, link_threshold, canvas_size, mag_ratio, slope_ths, ycenter_ths, height_ths, width_ths, y_ths, x_ths, add_margin, threshold, bbox_min_score, bbox_min_size, max_candidates, output_format) 440 def readtext(self, image, decoder = 'greedy', beamWidth= 5, batch_size = 1,\ 441 workers = 0, allowlist = None, blocklist = None, detail = 1,\ 442 rotation_info = None, paragraph = False, min_size = 20,\ (...) 448 threshold = 0.2, bbox_min_score = 0.2, bbox_min_size = 3, max_candidates = 0, 449 output_format='standard'): 450 ''' 451 Parameters: 452 image: file path or numpy-array or a byte stream object 453 ''' --> 454 img, img_cv_grey = reformat_input(image) 456 horizontal_list, free_list = self.detect(img, 457 min_size = min_size, text_threshold = text_threshold,\ 458 low_text = low_text, link_threshold = link_threshold,\ (...) 464 bbox_min_size = bbox_min_size, max_candidates = max_candidates 465 ) 466 # get the 1st result from hor & free list as self.detect returns a list of depth 3 File /opt/conda/lib/python3.8/site-packages/easyocr/utils.py:757, in reformat_input(image) 755 elif len(image.shape) == 3 and image.shape[2] == 3: # BGRscale 756 img = image --> 757 img_cv_grey = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 758 elif len(image.shape) == 3 and image.shape[2] == 4: # RGBAscale 759 img = image[:,:,:3] error: OpenCV(4.9.0) /io/opencv/modules/imgproc/src/color.cpp:196: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Editor is loading...
Leave a Comment