From ddd680bb4c6ecab67f8e170b168ecf85f0bf205a Mon Sep 17 00:00:00 2001 From: iriley Date: Fri, 8 Mar 2024 10:13:35 +0100 Subject: [PATCH] fix: change None to list when HoughLinesP returns None --- src/cv_analysis/table_parsing.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/cv_analysis/table_parsing.py b/src/cv_analysis/table_parsing.py index eb6fcc0..0757697 100644 --- a/src/cv_analysis/table_parsing.py +++ b/src/cv_analysis/table_parsing.py @@ -178,20 +178,17 @@ def detect_endpoints( return (dist_a < 15) and (dist_b < 15) and overlap - - lines = list( - map( - lambda x: tuple(x[0]), - cv2.HoughLinesP( - image, # Input edge image - 1, # Distance resolution in pixels - np.pi / 180, # Angle resolution in radians - threshold=100, # Min number of votes for valid line - minLineLength=200, # Min allowed length of line - maxLineGap=10, # Max allowed gap between line for joining them - ), - ) + points = cv2.HoughLinesP( + image, # Input edge image + 1, # Distance resolution in pixels + np.pi / 180, # Angle resolution in radians + threshold=100, # Min number of votes for valid line + minLineLength=200, # Min allowed length of line + maxLineGap=10, # Max allowed gap between line for joining them ) + points = points if points is not None else [] + + lines = list(map(lambda x: tuple(x[0]), points)) if not lines: return lines