Skip to content Skip to sidebar Skip to footer

Create Contour From Scratch In Python Opencv (cv2)

I am trying to use the opencv python interface cv2 to determine if a polygon is convex. From all I found on the web, the input contour must be a numpy array of float32 tuples for e

Solution 1:

OpenCV expects that the points of an image would be integer tuples, just change their type to int:

>>>import cv2>>>import numpy as np>>>contour = np.array([(378, 949), (375, 940), (368, 934), (359, 932), ...(350, 937), (345, 955), (351, 962), (359, 966), (368, 964), ...(376, 958) ], dtype=np.int)>>>cv2.isContourConvex(contour)
 True

Solution 2:

It was a problem with the openCV installation on debian testing. After installing openCV 2.4.8 from source, it works. Thanks for the help!

Post a Comment for "Create Contour From Scratch In Python Opencv (cv2)"