Skip to content

Commit 4aa9543

Browse files
committed
remove more branches after textline_light default true
1 parent 177d555 commit 4aa9543

File tree

2 files changed

+2
-48
lines changed

2 files changed

+2
-48
lines changed

src/eynollah/eynollah.py

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,52 +1512,10 @@ def extract_text_regions(self, img, patches, cols):
15121512
img_width_h = img.shape[1]
15131513
model_region = self.model_zoo.get("region_fl") if patches else self.model_zoo.get("region_fl_np")
15141514

1515-
if not patches:
1516-
img = otsu_copy_binary(img)
1517-
img = img.astype(np.uint8)
1518-
prediction_regions2 = None
1519-
elif cols:
1520-
if cols == 1:
1521-
img_height_new = int(img_height_h * 0.7)
1522-
img_width_new = int(img_width_h * 0.7)
1523-
elif cols == 2:
1524-
img_height_new = int(img_height_h * 0.4)
1525-
img_width_new = int(img_width_h * 0.4)
1526-
else:
1527-
img_height_new = int(img_height_h * 0.3)
1528-
img_width_new = int(img_width_h * 0.3)
1529-
img2 = otsu_copy_binary(img)
1530-
img2 = img2.astype(np.uint8)
1531-
img2 = resize_image(img2, img_height_new, img_width_new)
1532-
prediction_regions2 = self.do_prediction(patches, img2, model_region, marginal_of_patch_percent=0.1)
1533-
prediction_regions2 = resize_image(prediction_regions2, img_height_h, img_width_h)
1534-
1535-
img = otsu_copy_binary(img).astype(np.uint8)
1536-
if cols == 1:
1537-
img = resize_image(img, int(img_height_h * 0.5), int(img_width_h * 0.5)).astype(np.uint8)
1538-
elif cols == 2 and img_width_h >= 2000:
1539-
img = resize_image(img, int(img_height_h * 0.9), int(img_width_h * 0.9)).astype(np.uint8)
1540-
elif cols == 3 and ((self.scale_x == 1 and img_width_h > 3000) or
1541-
(self.scale_x != 1 and img_width_h > 2800)):
1542-
img = resize_image(img, 2800 * img_height_h // img_width_h, 2800).astype(np.uint8)
1543-
elif cols == 4 and ((self.scale_x == 1 and img_width_h > 4000) or
1544-
(self.scale_x != 1 and img_width_h > 3700)):
1545-
img = resize_image(img, 3700 * img_height_h // img_width_h, 3700).astype(np.uint8)
1546-
elif cols == 4:
1547-
img = resize_image(img, int(img_height_h * 0.9), int(img_width_h * 0.9)).astype(np.uint8)
1548-
elif cols == 5 and self.scale_x == 1 and img_width_h > 5000:
1549-
img = resize_image(img, int(img_height_h * 0.7), int(img_width_h * 0.7)).astype(np.uint8)
1550-
elif cols == 5:
1551-
img = resize_image(img, int(img_height_h * 0.9), int(img_width_h * 0.9)).astype(np.uint8)
1552-
elif img_width_h > 5600:
1553-
img = resize_image(img, 5600 * img_height_h // img_width_h, 5600).astype(np.uint8)
1554-
else:
1555-
img = resize_image(img, int(img_height_h * 0.9), int(img_width_h * 0.9)).astype(np.uint8)
1556-
15571515
prediction_regions = self.do_prediction(patches, img, model_region, marginal_of_patch_percent=0.1)
15581516
prediction_regions = resize_image(prediction_regions, img_height_h, img_width_h)
15591517
self.logger.debug("exit extract_text_regions")
1560-
return prediction_regions, prediction_regions2
1518+
return prediction_regions, None
15611519

15621520
def get_textlines_of_a_textregion_sorted(self, textlines_textregion, cx_textline, cy_textline, w_h_textline):
15631521
N = len(cy_textline)

src/eynollah/writer.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,9 @@ def serialize_lines_in_region(self, text_region, all_found_textline_polygons, re
7272
point = point[0]
7373
point_x = point[0] + page_coord[2]
7474
point_y = point[1] + page_coord[0]
75-
# FIXME: or actually... not self.curved_line or np.abs(slopes[region_idx]) > 45?
76-
if not (self.curved_line and np.abs(slopes[region_idx]) <= 45):
77-
point_x += region_bboxes[2]
78-
point_y += region_bboxes[0]
7975
point_x = max(0, int(point_x / self.scale_x))
8076
point_y = max(0, int(point_y / self.scale_y))
81-
points_co += str(point_x) + ',' + str(point_y) + ' '
77+
points_co += f'{point_x},{point_y} '
8278
coords.set_points(points_co[:-1])
8379

8480
def write_pagexml(self, pcgts):

0 commit comments

Comments
 (0)