mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-06-08 19:59:56 +02:00
fixed #38
This commit is contained in:
parent
c4b2c71e68
commit
799a7c7632
1 changed files with 70 additions and 58 deletions
|
@ -159,6 +159,9 @@ class Eynollah:
|
|||
key += '_uint8'
|
||||
return self._imgs[key].copy()
|
||||
|
||||
def isNaN(self, num):
|
||||
return num != num
|
||||
|
||||
|
||||
def predict_enhancement(self, img):
|
||||
self.logger.debug("enter predict_enhancement")
|
||||
|
@ -920,16 +923,16 @@ class Eynollah:
|
|||
textline_con, hierarchy = return_contours_of_image(img_int_p)
|
||||
textline_con_fil = filter_contours_area_of_image(img_int_p, textline_con, hierarchy, max_area=1, min_area=0.0008)
|
||||
y_diff_mean = find_contours_mean_y_diff(textline_con_fil)
|
||||
if self.isNaN(y_diff_mean):
|
||||
slope_for_all = MAX_SLOPE
|
||||
else:
|
||||
sigma_des = max(1, int(y_diff_mean * (4.0 / 40.0)))
|
||||
|
||||
img_int_p[img_int_p > 0] = 1
|
||||
slope_for_all = return_deskew_slop(img_int_p, sigma_des, plotter=self.plotter)
|
||||
|
||||
if abs(slope_for_all) < 0.5:
|
||||
slope_for_all = [slope_deskew][0]
|
||||
# old method
|
||||
# slope_for_all=self.textline_contours_to_get_slope_correctly(self.all_text_region_raw[mv],denoised,contours[mv])
|
||||
# text_patch_processed=textline_contours_postprocessing(gada)
|
||||
|
||||
except Exception as why:
|
||||
self.logger.error(why)
|
||||
slope_for_all = MAX_SLOPE
|
||||
|
@ -1031,6 +1034,9 @@ class Eynollah:
|
|||
textline_con, hierarchy = return_contours_of_image(img_int_p)
|
||||
textline_con_fil = filter_contours_area_of_image(img_int_p, textline_con, hierarchy, max_area=1, min_area=0.00008)
|
||||
y_diff_mean = find_contours_mean_y_diff(textline_con_fil)
|
||||
if self.isNaN(y_diff_mean):
|
||||
slope_for_all = MAX_SLOPE
|
||||
else:
|
||||
sigma_des = int(y_diff_mean * (4.0 / 40.0))
|
||||
if sigma_des < 1:
|
||||
sigma_des = 1
|
||||
|
@ -1891,6 +1897,7 @@ class Eynollah:
|
|||
areas_cnt_text_d = np.array([cv2.contourArea(contours_only_text_parent_d[j]) for j in range(len(contours_only_text_parent_d))])
|
||||
areas_cnt_text_d = areas_cnt_text_d / float(text_only_d.shape[0] * text_only_d.shape[1])
|
||||
|
||||
if len(areas_cnt_text_d)>0:
|
||||
contours_biggest_d = contours_only_text_parent_d[np.argmax(areas_cnt_text_d)]
|
||||
index_con_parents_d=np.argsort(areas_cnt_text_d)
|
||||
contours_only_text_parent_d=list(np.array(contours_only_text_parent_d)[index_con_parents_d] )
|
||||
|
@ -1937,6 +1944,12 @@ class Eynollah:
|
|||
else:
|
||||
contours_only_text_parent_d_ordered = []
|
||||
contours_only_text_parent_d = []
|
||||
contours_only_text_parent = []
|
||||
|
||||
else:
|
||||
contours_only_text_parent_d_ordered = []
|
||||
contours_only_text_parent_d = []
|
||||
contours_only_text_parent = []
|
||||
|
||||
else:
|
||||
contours_only_text, hir_on_text = return_contours_of_image(text_only)
|
||||
|
@ -1968,7 +1981,6 @@ class Eynollah:
|
|||
if not self.curved_line:
|
||||
slopes, all_found_texline_polygons, boxes_text, txt_con_org, contours_only_text_parent, all_box_coord, index_by_text_par_con = self.get_slopes_and_deskew_new(txt_con_org, contours_only_text_parent, textline_mask_tot_ea, image_page_rotated, boxes_text, slope_deskew)
|
||||
slopes_marginals, all_found_texline_polygons_marginals, boxes_marginals, _, polygons_of_marginals, all_box_coord_marginals, _ = self.get_slopes_and_deskew_new(polygons_of_marginals, polygons_of_marginals, textline_mask_tot_ea, image_page_rotated, boxes_marginals, slope_deskew)
|
||||
|
||||
else:
|
||||
|
||||
scale_param = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue