log exceptions as errors

pull/19/head
Konstantin Baierer 4 years ago
parent 9dcb696e99
commit 605f583d21

@ -862,7 +862,8 @@ class eynollah:
# old method # old method
# slope_for_all=self.textline_contours_to_get_slope_correctly(self.all_text_region_raw[mv],denoised,contours[mv]) # 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) # text_patch_processed=textline_contours_postprocessing(gada)
except: except Exception as why:
self.logger.error(why)
slope_for_all = 999 slope_for_all = 999
if slope_for_all == 999: if slope_for_all == 999:
@ -914,10 +915,9 @@ class eynollah:
mask_biggest2 = resize_image(mask_biggest2, int(mask_biggest2.shape[0] * scale_par), int(mask_biggest2.shape[1] * scale_par)) mask_biggest2 = resize_image(mask_biggest2, int(mask_biggest2.shape[0] * scale_par), int(mask_biggest2.shape[1] * scale_par))
cnt_textlines_in_image_ind = return_contours_of_interested_textline(mask_biggest2, pixel_img) cnt_textlines_in_image_ind = return_contours_of_interested_textline(mask_biggest2, pixel_img)
try: try:
# textlines_cnt_per_region.append(cnt_textlines_in_image_ind[0]/scale_par)
textlines_cnt_per_region.append(cnt_textlines_in_image_ind[0]) textlines_cnt_per_region.append(cnt_textlines_in_image_ind[0])
except: except Exception as why:
pass self.logger.error(why)
else: else:
add_boxes_coor_into_textlines = True add_boxes_coor_into_textlines = True
textlines_cnt_per_region = textline_contours_postprocessing(all_text_region_raw, slope_for_all, contours_par_per_process[mv], boxes_text[mv], add_boxes_coor_into_textlines) textlines_cnt_per_region = textline_contours_postprocessing(all_text_region_raw, slope_for_all, contours_par_per_process[mv], boxes_text[mv], add_boxes_coor_into_textlines)
@ -973,7 +973,8 @@ class eynollah:
slope_for_all = return_deskew_slop(img_int_p, sigma_des, plotter=self.plotter) slope_for_all = return_deskew_slop(img_int_p, sigma_des, plotter=self.plotter)
if abs(slope_for_all) <= 0.5: if abs(slope_for_all) <= 0.5:
slope_for_all = [slope_deskew][0] slope_for_all = [slope_deskew][0]
except: except Exception as why:
self.logger.error(why)
slope_for_all = 999 slope_for_all = 999
if slope_for_all == 999: if slope_for_all == 999:
@ -1043,16 +1044,11 @@ class eynollah:
textline_con, hierachy = return_contours_of_image(crop_img) textline_con, hierachy = return_contours_of_image(crop_img)
textline_con_fil = filter_contours_area_of_image(crop_img, textline_con, hierachy, max_area=1, min_area=0.0008) textline_con_fil = filter_contours_area_of_image(crop_img, textline_con, hierachy, max_area=1, min_area=0.0008)
y_diff_mean = find_contours_mean_y_diff(textline_con_fil) y_diff_mean = find_contours_mean_y_diff(textline_con_fil)
sigma_des = max(1, int(y_diff_mean * (4.0 / 40.0)))
sigma_des = int(y_diff_mean * (4.0 / 40.0))
if sigma_des < 1:
sigma_des = 1
crop_img[crop_img > 0] = 1 crop_img[crop_img > 0] = 1
slope_corresponding_textregion = return_deskew_slop(crop_img, sigma_des, plotter=self.plotter) slope_corresponding_textregion = return_deskew_slop(crop_img, sigma_des, plotter=self.plotter)
except Exception as why:
except: self.logger.error(why)
slope_corresponding_textregion = 999 slope_corresponding_textregion = 999
if slope_corresponding_textregion == 999: if slope_corresponding_textregion == 999:
@ -1489,7 +1485,8 @@ class eynollah:
tartib_new = np.where(np.array(order_of_texts_tot) == iii)[0][0] tartib_new = np.where(np.array(order_of_texts_tot) == iii)[0][0]
order_text_new.append(tartib_new) order_text_new.append(tartib_new)
except: except Exception as why:
self.logger.error(why)
arg_text_con = [] arg_text_con = []
for ii in range(len(cx_text_only)): for ii in range(len(cx_text_only)):
for jj in range(len(boxes)): for jj in range(len(boxes)):
@ -1615,7 +1612,8 @@ class eynollah:
tartib_new = np.where(np.array(order_of_texts_tot) == iii)[0][0] tartib_new = np.where(np.array(order_of_texts_tot) == iii)[0][0]
order_text_new.append(tartib_new) order_text_new.append(tartib_new)
except: except Exception as why:
self.logger.error(why)
arg_text_con = [] arg_text_con = []
for ii in range(len(cx_text_only)): for ii in range(len(cx_text_only)):
for jj in range(len(boxes)): for jj in range(len(boxes)):
@ -1706,7 +1704,8 @@ class eynollah:
num_col = num_col + 1 num_col = num_col + 1
if not num_column_is_classified: if not num_column_is_classified:
num_col_classifier = num_col + 1 num_col_classifier = num_col + 1
except: except Exception as why:
self.logger.error(why)
num_col = None num_col = None
peaks_neg_fin = [] peaks_neg_fin = []
return num_col, num_col_classifier, img_only_regions, page_coord, image_page, mask_images, mask_lines, text_regions_p_1 return num_col, num_col_classifier, img_only_regions, page_coord, image_page, mask_images, mask_lines, text_regions_p_1
@ -2022,8 +2021,8 @@ class eynollah:
ind_largest = len(cx_bigest_d) -5 + np.argmin(dists_d) ind_largest = len(cx_bigest_d) -5 + np.argmin(dists_d)
cx_bigest_d_big[0] = cx_bigest_d[ind_largest] cx_bigest_d_big[0] = cx_bigest_d[ind_largest]
cy_biggest_d_big[0] = cy_biggest_d[ind_largest] cy_biggest_d_big[0] = cy_biggest_d[ind_largest]
except: except Exception as why:
pass self.logger.error(why)
(h, w) = text_only.shape[:2] (h, w) = text_only.shape[:2]
center = (w // 2.0, h // 2.0) center = (w // 2.0, h // 2.0)

Loading…
Cancel
Save