do_work_of_slopes*: use shm also in non-light mode(s)

This commit is contained in:
Robert Sachunsky 2025-09-04 15:18:55 +02:00
parent 31f240c3b8
commit 0662ece536
2 changed files with 23 additions and 16 deletions

View file

@ -1554,11 +1554,14 @@ class Eynollah:
if not len(contours):
return [], [], [], [], [], [], []
self.logger.debug("enter get_slopes_and_deskew_new_light")
results = self.executor.map(partial(do_work_of_slopes_new_light,
textline_mask_tot_ea=textline_mask_tot,
slope_deskew=slope_deskew,textline_light=self.textline_light,
logger=self.logger,),
boxes, contours, contours_par, range(len(contours_par)))
with share_ndarray(textline_mask_tot) as textline_mask_tot_shared:
results = self.executor.map(partial(do_work_of_slopes_new_light,
textline_mask_tot_ea=textline_mask_tot_shared,
slope_deskew=slope_deskew,
textline_light=self.textline_light,
logger=self.logger,),
boxes, contours, contours_par, range(len(contours_par)))
results = list(results) # exhaust prior to release
#textline_polygons, boxes, text_regions, text_regions_par, box_coord, index_text_con, slopes = zip(*results)
self.logger.debug("exit get_slopes_and_deskew_new_light")
return tuple(zip(*results))
@ -1567,14 +1570,16 @@ class Eynollah:
if not len(contours):
return [], [], [], [], [], [], []
self.logger.debug("enter get_slopes_and_deskew_new")
results = self.executor.map(partial(do_work_of_slopes_new,
textline_mask_tot_ea=textline_mask_tot,
slope_deskew=slope_deskew,
MAX_SLOPE=MAX_SLOPE,
KERNEL=KERNEL,
logger=self.logger,
plotter=self.plotter,),
boxes, contours, contours_par, range(len(contours_par)))
with share_ndarray(textline_mask_tot) as textline_mask_tot_shared:
results = self.executor.map(partial(do_work_of_slopes_new,
textline_mask_tot_ea=textline_mask_tot_shared,
slope_deskew=slope_deskew,
MAX_SLOPE=MAX_SLOPE,
KERNEL=KERNEL,
logger=self.logger,
plotter=self.plotter,),
boxes, contours, contours_par, range(len(contours_par)))
results = list(results) # exhaust prior to release
#textline_polygons, boxes, text_regions, text_regions_par, box_coord, index_text_con, slopes = zip(*results)
self.logger.debug("exit get_slopes_and_deskew_new")
return tuple(zip(*results))
@ -1596,8 +1601,8 @@ class Eynollah:
logger=self.logger,
plotter=self.plotter,),
boxes, contours, contours_par, range(len(contours_par)))
#textline_polygons, boxes, text_regions, text_regions_par, box_coord, index_text_con, slopes = zip(*results)
results = list(results) # exhaust prior to release
#textline_polygons, boxes, text_regions, text_regions_par, box_coord, index_text_con, slopes = zip(*results)
self.logger.debug("exit get_slopes_and_deskew_new_curved")
return tuple(zip(*results))

View file

@ -1539,9 +1539,10 @@ def get_smallest_skew(img, sigma_des, angles, logger=None, plotter=None, map=map
var = 0
return angle, var
@wrap_ndarray_shared(kw='textline_mask_tot_ea')
def do_work_of_slopes_new(
box_text, contour, contour_par, index_r_con,
textline_mask_tot_ea, slope_deskew,
textline_mask_tot_ea=None, slope_deskew=0.0,
logger=None, MAX_SLOPE=999, KERNEL=None, plotter=None
):
if KERNEL is None:
@ -1689,9 +1690,10 @@ def do_work_of_slopes_new_curved(
return textlines_cnt_per_region[::-1], box_text, contour, contour_par, crop_coor, index_r_con, slope
@wrap_ndarray_shared(kw='textline_mask_tot_ea')
def do_work_of_slopes_new_light(
box_text, contour, contour_par, index_r_con,
textline_mask_tot_ea, slope_deskew, textline_light,
textline_mask_tot_ea=None, slope_deskew=0, textline_light=True,
logger=None
):
if logger is None: