c++ - Extract data from Point2f -


I am developing a code that needs to find a red slice. I get the function of the image to get the center of the image < Code> minEnclosingCircle .

The way the function gives me, vector format vector & lt; Point 2f> Center (contours.size ()); However, I need this data to determine the area of ​​interest (ROI). Can I extract data from a point in any way, so that I can get two coordinates in X and Y in the integer?

Thank you!

- Update -

I will post some code to try to do better what I want to do:

  vector & lt; Vector & lt; Point & gt; & Gt; Contours_poly (contours.size ()); Vector & lt; Point 2f & gt; Center (contours.size ()); Vector & lt; Float & gt; Radius (contours.size ()); For (Int i = 0; I & lt; contours.size (); i ++) {approximate polydee (mat (pattern [i]), contours_poly [i], 3, true); MinEnclosingCircle (Mat) contours_poly [i], center [i], radius [i]); }   

So once I get the shape from my image, I apply the function minEnclosingCicrle to determine the center I am very new in OpenCV I think that it shows that the center of the circle is saved in this vector of point2f. The thing I want to talk to is to get to this point to get the position of my object to determine an ROI around the object.

from your comments

Suppose I have found 20 circles and I know that Circle 15 is the largest. I want to know the position of the D X and Y Center [15], which is a point, but inside a vector.

Without limit inquiry:

  float x = center [15] .x; Float y = center [15] .y;   

with border check:

  float x = center.at (15) .x; Float y = center.at (15) .y;   

Regarding the range of vector, if index is & gt; = Center.size () , then you are out of range so you can check yourself:

  int idx = 15; If (idx   

Note that the index starts with 0 , So here we are reaching the 16th point.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -