I'm developing a code that needs to find a red piece. I'm using the function minEnclosingCircle in order to get the center of the image.
The way that the function gives me the center is in a vector format vector<Point2f>center( contours.size() );. However I need this data to determine a region of interest (ROI). Is there any way I can extract the data from the point, so that I can have two coordinates in X and Y in an integer?
Thanks!
--update--
I'll post some code to try to explain better what i want to do:
vector<vector<Point> > contours_poly( contours.size() );
vector<Point2f>center( contours.size() );
vector<float>radius( contours.size() );
for( int i = 0; i < contours.size(); i++ )
{
approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
minEnclosingCircle( (Mat)contours_poly[i], center[i], radius[i] );
}
So once i get contours from my image I apply the function minEnclosingCicrle to determinate the center. I'm very new in OpenCV. I suppose that the center of the circles that it finds is saved in this vector of Point2f. The thing I want to do is to access to this points in order to get the position of my object to determinate a ROI around the object.
minEnclosingCirclegives you a centre and a radius for a given set of input points. What data exactly are you trying to extract? - juanchopanza