diff --git a/page_xml/xml_converter.py b/page_xml/xml_converter.py index 66b63fa..897119a 100644 --- a/page_xml/xml_converter.py +++ b/page_xml/xml_converter.py @@ -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: diff --git a/utils/vector_utils.py b/utils/vector_utils.py index c7cf14e..86ab856 100644 --- a/utils/vector_utils.py +++ b/utils/vector_utils.py @@ -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]