Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problems with isContourConvex

I have tried to use cv2.isContourConvex on several different shapes, but I get "False" all the time. I think I might have misunderstood how cv2.isContourConvex is working. Can anyone help?

Here is how I have tried to use it on the image below (which should be convex, right?):

img = cv2.imread('convex.png')

img_gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(img_gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
image,contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
cnt = np.squeeze(contours[0])

print cv2.isContourConvex(cnt)

image description

Problems with isContourConvex

I have tried to use cv2.isContourConvex on several different shapes, but I get "False" all the time. I think I might have misunderstood how cv2.isContourConvex is working. Can anyone help?

Here is how I have tried to use it on the image below (which should be convex, right?):

img = cv2.imread('convex.png')

img_gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(img_gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
image,contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
cnt = np.squeeze(contours[0])
contours[0]

print cv2.isContourConvex(cnt)

image description

Problems with isContourConvex

I have tried to use cv2.isContourConvex on several different shapes, but I get "False" all the time. I think I might have misunderstood how cv2.isContourConvex is working. Can anyone help?

Here is how I have tried to use it on the image below (which should be convex, right?):

img = cv2.imread('convex.png')

img_gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(img_gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
image,contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
cnt = contours[0]

print cv2.isContourConvex(cnt)

image description

Problems with isContourConvexisContourConvex always returns "False"

I have tried to use cv2.isContourConvex on several different shapes, but I get "False" all the time. I think I might have misunderstood how cv2.isContourConvex is working. Can anyone help?

Here is how I have tried to use it on the image below (which should be convex, right?):

img = cv2.imread('convex.png')

img_gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(img_gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
image,contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
cnt = contours[0]

print cv2.isContourConvex(cnt)

image description