vahid 4 years ago
parent 7cbecadccc
commit c4b2c71e68

@ -1869,6 +1869,8 @@ class Eynollah:
if np.abs(slope_deskew) >= SLOPE_THRESHOLD: if np.abs(slope_deskew) >= SLOPE_THRESHOLD:
contours_only_text, hir_on_text = return_contours_of_image(text_only) contours_only_text, hir_on_text = return_contours_of_image(text_only)
contours_only_text_parent = return_parent_contours(contours_only_text, hir_on_text) contours_only_text_parent = return_parent_contours(contours_only_text, hir_on_text)
if len(contours_only_text_parent) > 0:
areas_cnt_text = np.array([cv2.contourArea(contours_only_text_parent[j]) for j in range(len(contours_only_text_parent))]) areas_cnt_text = np.array([cv2.contourArea(contours_only_text_parent[j]) for j in range(len(contours_only_text_parent))])
areas_cnt_text = areas_cnt_text / float(text_only.shape[0] * text_only.shape[1]) areas_cnt_text = areas_cnt_text / float(text_only.shape[0] * text_only.shape[1])
self.logger.info('areas_cnt_text %s', areas_cnt_text) self.logger.info('areas_cnt_text %s', areas_cnt_text)
@ -1932,10 +1934,15 @@ class Eynollah:
# img2=cv2.fillPoly(img2,pts=[contours_only_text_parent_d[np.argmin(dists)]] ,color=(1,1,1)) # img2=cv2.fillPoly(img2,pts=[contours_only_text_parent_d[np.argmin(dists)]] ,color=(1,1,1))
# plt.imshow(img2[:,:,0]) # plt.imshow(img2[:,:,0])
# plt.show() # plt.show()
else:
contours_only_text_parent_d_ordered = []
contours_only_text_parent_d = []
else: else:
contours_only_text, hir_on_text = return_contours_of_image(text_only) contours_only_text, hir_on_text = return_contours_of_image(text_only)
contours_only_text_parent = return_parent_contours(contours_only_text, hir_on_text) contours_only_text_parent = return_parent_contours(contours_only_text, hir_on_text)
if len(contours_only_text_parent) > 0:
areas_cnt_text = np.array([cv2.contourArea(contours_only_text_parent[j]) for j in range(len(contours_only_text_parent))]) areas_cnt_text = np.array([cv2.contourArea(contours_only_text_parent[j]) for j in range(len(contours_only_text_parent))])
areas_cnt_text = areas_cnt_text / float(text_only.shape[0] * text_only.shape[1]) areas_cnt_text = areas_cnt_text / float(text_only.shape[0] * text_only.shape[1])
@ -1952,6 +1959,8 @@ class Eynollah:
self.logger.debug('areas_cnt_text_parent %s', areas_cnt_text_parent) self.logger.debug('areas_cnt_text_parent %s', areas_cnt_text_parent)
# self.logger.debug('areas_cnt_text_parent_d %s', areas_cnt_text_parent_d) # self.logger.debug('areas_cnt_text_parent_d %s', areas_cnt_text_parent_d)
# self.logger.debug('len(contours_only_text_parent) %s', len(contours_only_text_parent_d)) # self.logger.debug('len(contours_only_text_parent) %s', len(contours_only_text_parent_d))
else:
pass
txt_con_org = get_textregion_contours_in_org_image(contours_only_text_parent, self.image, slope_first) txt_con_org = get_textregion_contours_in_org_image(contours_only_text_parent, self.image, slope_first)
boxes_text, _ = get_text_region_boxes_by_given_contours(contours_only_text_parent) boxes_text, _ = get_text_region_boxes_by_given_contours(contours_only_text_parent)
boxes_marginals, _ = get_text_region_boxes_by_given_contours(polygons_of_marginals) boxes_marginals, _ = get_text_region_boxes_by_given_contours(polygons_of_marginals)

@ -1560,7 +1560,11 @@ def find_number_of_columns_in_document(region_pre_p, num_col_classifier, pixel_l
#regions_without_separators_tile=cv2.erode(regions_without_separators_tile,kernel,iterations = 3) #regions_without_separators_tile=cv2.erode(regions_without_separators_tile,kernel,iterations = 3)
# #
try:
num_col, peaks_neg_fin = find_num_col(regions_without_separators_tile,multiplier=7.0) num_col, peaks_neg_fin = find_num_col(regions_without_separators_tile,multiplier=7.0)
except:
num_col = 0
peaks_neg_fin = []
if num_col>num_col_fin: if num_col>num_col_fin:
num_col_fin=num_col num_col_fin=num_col

Loading…
Cancel
Save