Skip to content

Commit

Permalink
Lines shorter than 2 will not be cut based on start end
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanklut committed Apr 10, 2024
1 parent 87bcbac commit 854315f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion page_xml/xml_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def build_baseline_instances(self, page: PageData, out_size: tuple[int, int], li
for baseline_coords in page.iter_baseline_coords():
coords = self._scale_coords(baseline_coords, out_size, size)
mask.fill(0)
# HACK Currenty the most simple quickest solution used can probably be optimized
# HACK Currently the most simple quickest solution used can probably be optimized
mask, _ = self.draw_line(mask, coords, 255, thickness=line_width)
contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
if len(contours) == 0:
Expand Down
4 changes: 2 additions & 2 deletions utils/vector_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def point_at_start_or_end_assignment(line_segments: np.ndarray, points: np.ndarr
# Remove zero length lines
non_zero = line_norm != 0

# HACK If baseline has lenght 0, Do not remove any points
if not np.any(non_zero):
# If the total length of the line is less than 2, do not remove any points
if np.sum(line_norm) < 2:
return np.zeros(len(points))
else:
line_vector = line_vector[non_zero]
Expand Down

0 comments on commit 854315f

Please sign in to comment.