LineFiller
LineFiller copied to clipboard
Opencv version compatibility issue
Hi, thanks for your work.
While testing your codes, I found an error:
/content/LineFiller/linefiller/trappedball_fill.py in get_border_point(points, rect, max_height, max_width)
284
285 # Get shape.
--> 286 _, contours, _ = cv2.findContours(fill, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
287 approx_shape = cv2.approxPolyDP(contours[0], 0.02 * cv2.arcLength(contours[0], True), True)
288
ValueError: not enough values to unpack (expected 3, got 2)
I guess there is a version compatibility issue for opencv, since cv2.findContours
may return 2 or 3 values according to the opencv version.
I think the solution is simple:
# as is
_, contours, _ = cv2.findContours(fill, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
# to be
contours = cv2.findContours(fill, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2]
Thanks.