Ask Your Question
0

Python cv2.drawContours returns None

asked 2016-08-30 18:12:23 -0600

interstar gravatar image

I'm following a simple tutorial example. But this call to drawContours is returning None.

contours,hierarchy = cv2.findContours(th3,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
img2 = cv2.drawContours(img, contours, -1, (0,255,0), 3)

I'm not getting an error. The contours and hierarchy arrays look plausibly full of points. (th3 is a thresholded version of img) But img2 is None

Anyone got any ideas?

(BTW : I'm using opencv 2.4.9.1)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-08-30 23:40:39 -0600

berak gravatar image

this is a version conflict, only the opencv3 version of cv2.drawContours() returns another image, with 2.4, you'd simply use it like:

 cv2.drawContours(img, contours, -1, (0,255,0), 3)
 cv2.imshow("omg", img)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-30 18:12:23 -0600

Seen: 2,309 times

Last updated: Aug 30 '16