Opencv Typeerror: Points Is Not A Numpy Array, Neither A Scalar
Basically, I have this code that detects changes in background and boxed them. When I run the code, I get this error: Traceback (most recent call last): File 'cam2.py', line 28,
Solution 1:
According to the findContour doc it returns two things:
cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) → contours, hierarchy
Change the line to:
contours, hierarchy = cv2.findContours(mask, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
That may works!
Solution 2:
contours is actually a double-array. the outer one is the list of contours, the inner ones are the points of a single contour.
so, replace:
while contours:
vertices = cv2.boundingRect(list(contours))
with:
for cnt in contours:
vertices = cv2.boundingRect(cnt)
and drop the
contours = contours.h_next()
line (you probably confused cv2 with the old c-api/cv approach, which was using linked lists under the hood)
Post a Comment for "Opencv Typeerror: Points Is Not A Numpy Array, Neither A Scalar"