mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-09-17 21:29:56 +02:00
use box2rect instead of crop_image_inside_box when no image needed
This commit is contained in:
parent
892ff41e38
commit
142ac8825e
2 changed files with 10 additions and 6 deletions
|
@ -98,6 +98,8 @@ from .utils.resize import resize_image
|
||||||
from .utils import (
|
from .utils import (
|
||||||
boosting_headers_by_longshot_region_segmentation,
|
boosting_headers_by_longshot_region_segmentation,
|
||||||
crop_image_inside_box,
|
crop_image_inside_box,
|
||||||
|
box2rect,
|
||||||
|
box2slice,
|
||||||
find_num_col,
|
find_num_col,
|
||||||
otsu_copy_binary,
|
otsu_copy_binary,
|
||||||
put_drop_out_from_only_drop_model,
|
put_drop_out_from_only_drop_model,
|
||||||
|
@ -1542,7 +1544,7 @@ class Eynollah:
|
||||||
all_found_textline_polygons.append(textlines_ins[::-1])
|
all_found_textline_polygons.append(textlines_ins[::-1])
|
||||||
slopes.append(slope_deskew)
|
slopes.append(slope_deskew)
|
||||||
|
|
||||||
_, crop_coor = crop_image_inside_box(boxes[index],image_page_rotated)
|
crop_coor = box2rect(boxes[index])
|
||||||
all_box_coord.append(crop_coor)
|
all_box_coord.append(crop_coor)
|
||||||
|
|
||||||
return all_found_textline_polygons, boxes, contours, contours_par, all_box_coord, np.array(range(len(contours_par))), slopes
|
return all_found_textline_polygons, boxes, contours, contours_par, all_box_coord, np.array(range(len(contours_par))), slopes
|
||||||
|
@ -1754,7 +1756,7 @@ class Eynollah:
|
||||||
##polygons_of_images_fin.append(ploy_img_ind)
|
##polygons_of_images_fin.append(ploy_img_ind)
|
||||||
|
|
||||||
box = cv2.boundingRect(ploy_img_ind)
|
box = cv2.boundingRect(ploy_img_ind)
|
||||||
_, page_coord_img = crop_image_inside_box(box, text_regions_p_true)
|
page_coord_img = box2rect(box)
|
||||||
# cont_page.append(np.array([[page_coord[2], page_coord[0]],
|
# cont_page.append(np.array([[page_coord[2], page_coord[0]],
|
||||||
# [page_coord[3], page_coord[0]],
|
# [page_coord[3], page_coord[0]],
|
||||||
# [page_coord[3], page_coord[1]],
|
# [page_coord[3], page_coord[1]],
|
||||||
|
@ -1768,7 +1770,7 @@ class Eynollah:
|
||||||
if h < 150 or w < 150:
|
if h < 150 or w < 150:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
_, page_coord_img = crop_image_inside_box(box, text_regions_p_true)
|
page_coord_img = box2rect(box)
|
||||||
# cont_page.append(np.array([[page_coord[2], page_coord[0]],
|
# cont_page.append(np.array([[page_coord[2], page_coord[0]],
|
||||||
# [page_coord[3], page_coord[0]],
|
# [page_coord[3], page_coord[0]],
|
||||||
# [page_coord[3], page_coord[1]],
|
# [page_coord[3], page_coord[1]],
|
||||||
|
|
|
@ -18,6 +18,8 @@ from .contour import (
|
||||||
from . import (
|
from . import (
|
||||||
find_num_col_deskew,
|
find_num_col_deskew,
|
||||||
crop_image_inside_box,
|
crop_image_inside_box,
|
||||||
|
box2rect,
|
||||||
|
box2slice,
|
||||||
)
|
)
|
||||||
|
|
||||||
def dedup_separate_lines(img_patch, contour_text_interest, thetha, axis):
|
def dedup_separate_lines(img_patch, contour_text_interest, thetha, axis):
|
||||||
|
@ -1540,7 +1542,7 @@ def do_work_of_slopes_new(
|
||||||
logger.debug('enter do_work_of_slopes_new')
|
logger.debug('enter do_work_of_slopes_new')
|
||||||
|
|
||||||
x, y, w, h = box_text
|
x, y, w, h = box_text
|
||||||
_, crop_coor = crop_image_inside_box(box_text, image_page_rotated)
|
crop_coor = box2rect(box_text)
|
||||||
mask_textline = np.zeros(textline_mask_tot_ea.shape)
|
mask_textline = np.zeros(textline_mask_tot_ea.shape)
|
||||||
mask_textline = cv2.fillPoly(mask_textline, pts=[contour], color=(1,1,1))
|
mask_textline = cv2.fillPoly(mask_textline, pts=[contour], color=(1,1,1))
|
||||||
all_text_region_raw = textline_mask_tot_ea * mask_textline
|
all_text_region_raw = textline_mask_tot_ea * mask_textline
|
||||||
|
@ -1631,7 +1633,7 @@ def do_work_of_slopes_new_curved(
|
||||||
slope_for_all = slope_deskew
|
slope_for_all = slope_deskew
|
||||||
slope = slope_for_all
|
slope = slope_for_all
|
||||||
|
|
||||||
_, crop_coor = crop_image_inside_box(box_text, image_page_rotated)
|
crop_coor = box2rect(box_text)
|
||||||
|
|
||||||
if abs(slope_for_all) < 45:
|
if abs(slope_for_all) < 45:
|
||||||
textline_region_in_image = np.zeros(textline_mask_tot_ea.shape)
|
textline_region_in_image = np.zeros(textline_mask_tot_ea.shape)
|
||||||
|
@ -1685,7 +1687,7 @@ def do_work_of_slopes_new_light(
|
||||||
logger.debug('enter do_work_of_slopes_new_light')
|
logger.debug('enter do_work_of_slopes_new_light')
|
||||||
|
|
||||||
x, y, w, h = box_text
|
x, y, w, h = box_text
|
||||||
_, crop_coor = crop_image_inside_box(box_text, image_page_rotated)
|
crop_coor = box2rect(box_text)
|
||||||
mask_textline = np.zeros(textline_mask_tot_ea.shape)
|
mask_textline = np.zeros(textline_mask_tot_ea.shape)
|
||||||
mask_textline = cv2.fillPoly(mask_textline, pts=[contour], color=(1,1,1))
|
mask_textline = cv2.fillPoly(mask_textline, pts=[contour], color=(1,1,1))
|
||||||
all_text_region_raw = textline_mask_tot_ea * mask_textline
|
all_text_region_raw = textline_mask_tot_ea * mask_textline
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue