What does isContourConvex actually do? [closed]

asked 2018-02-07 07:31:10 -0600

Grillteller gravatar image

Hi,

I am using isContourConvex to remove some contours in my image and it also works quite well. But now I want to know what the function actually does? I found some threads where it says, that isContourConvex can distinguish between closed and open contours. In my example "boomerang-shaped" contours which in fact are closed get marked as false and I can remove them (exactly what I want).

I found this: https://docs.opencv.org/2.4/modules/i... and this: https://github.com/opencv/opencv/blob... but the explanation is really small and I don't understand the source code.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-09-04 13:53:47.295570

Comments

A convex shape is a shape (defined by its contour) where if you choose two points belonging to this shape then line between this two points belongs to shape. A disk is convex not a star... boomerang-shaped is not convex

What is an open contour in opencv ?

open set but it is topology

LBerger gravatar imageLBerger ( 2018-02-07 08:20:20 -0600 )edit

A convex hull can always be built around a set of vertices. Once the convex hull is built, and if there are extra vertices inside the convex hull, then it's not a convex shape.

sjhalayka gravatar imagesjhalayka ( 2018-02-07 08:28:11 -0600 )edit

Thanks, I understand the definition of convex shape now! Did they build the source code of this function like this? Do they test all possible lines between points of the contour and if one intersects the contour the say it is not a convex shape? Or do they follow sjhalayka's approach?

Grillteller gravatar imageGrillteller ( 2018-02-08 02:28:35 -0600 )edit