Reputation: 23
I would like to ask for some assistance regarding OpenCV (I am currently a beginner in using OpenCV).
I intend to measure the growth or movement of an object between two frames.
For example:
_ _
= = = =
= = = =
= = = =
= = = =
= = = =
= = = =
~ ~
The first frame contains a black circle with a white background.
The second frame contains a bigger circle with a white background.
What I am thinking of doing is to get the coordinates of the circles (I am not sure what functions are available in OpenCV that allow me to segment the circle and retrieve it's coordinates). Then subtract the coordinates so that I can measure the growth of the circle.
I have tried looking through some tutorials but have not been able to find any discussing about segmenting objects (such as the circles) and then printing or writing their coordinates into a file.
Is it possible to do something like this with OpenCV, or do I require some other software solution?
Thank you all.
Upvotes: 2
Views: 917
Reputation: 5416
In OpenCV, you can:
cvSnakeImage()
which takes an image as an input and computes a set of pointscv::minEnclosingCircle()
, which will return the diameter of your circleFeature detection doc: http://opencv.willowgarage.com/documentation/feature_detection.html Structural/shape descriptor doc: http://opencv.willowgarage.com/documentation/cpp/structural_analysis_and_shape_descriptors.html
Maybe you can also use optical flows too (though I am not familiar with it, so I am not sure).
Edit (answer to comment):
Function cvMinEnclosingCircle()
returns "the circumscribed circle of minimal area for a given 2D point set" (from the OpenCV doc) -- it means the 2D point set can represent any shape, not only circles. If you know you are comparing different scales of the same object, this measure makes sense (because all parts of your object will grow or shrink at the same time, thus "pushing" or "contracting" the circumscribed circle).
But there is actually a simpler method: compare the number of black pixels in each image, they represent the area.
Or, you might be interested in using another library dedicated to segmentation, for example ITK.
Upvotes: 1