0
votes

The following code is giving me the following error:

contours = cv2.findContours(horizontal_lines_canvas, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
contours = contours[1]
contours = sorted(contours, key=lambda c: cv2.arcLength(c, True), reverse=True)[:2]

ERROR:

cv2.error: OpenCV(4.0.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/shapedescr.cpp:237: error: (-215:Assertion failed) count >= 0 && (depth == CV_32F || depth == CV_32S) in function 'arcLength'

  • OpenCV version: 4.0.0
  • Python version: 3.7

Why so ? All seems correct

1
It's contours, hierarchy = cv2.findContours(...), see the doc. In your case, contours is a tuple, thus the error.HansHirse

1 Answers

0
votes

Thank you, HansHirse.

Replaced with:

contours, hierarchy = cv2.findContours(..