First time here? Check out the FAQ!

Ask Your Question
1

Has OpenCV built-in functions to calculate circularity, compactness etc for contours/blobs?

asked Nov 30 '14

huehuehue gravatar image

Compactness can be defined for example as the perimeter squared, divided by 4piarea, so that a circle has a compactness of 1.

Before writing my own function, Is there a similar function in the OpenCV Library ?

Thanks.

Ps : SimpleBlobDetector does not help me as I want to calculate circularity for existing prior extracted contours.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Nov 30 '14

There are the different (Hu-)moments:

http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=moments#structural-analysis-and-shape-descriptors

You could easily compute your compactness via cv::arcLength (perimeter) and cv::contourArea

Preview: (hide)

Question Tools

Stats

Asked: Nov 30 '14

Seen: 13,321 times

Last updated: Nov 30 '14