Ask Your Question

Akoo's profile - activity

2013-09-11 05:21:33 -0600 commented answer Displaying radius of a circle

Another one more question, And what should I do if I have two circles in the image? It would be possible to show both radiu and discrimine it?

2013-09-11 04:45:17 -0600 commented answer Displaying radius of a circle

Thank you very much Moster!!!

2013-09-11 04:11:03 -0600 received badge  Editor (source)
2013-09-11 04:10:26 -0600 commented answer Displaying radius of a circle

I would like to show the radius in number, although I could show a line but also the number. I had tried with putText but in this function I only can show a constant string. I'll edit my post to upload my code.

2013-09-11 04:02:54 -0600 commented answer Displaying radius of a circle

I know I've alredy got the radius and the center to draw that circle, but I don't know how to display it in the image.

2013-09-11 03:07:33 -0600 asked a question Displaying radius of a circle

Hi everybody, I am learning OpenCV now and I have wrote a simple program which displays the bounding circle of a contour. Now I would like to know, how can I display in the same image the radius of that circle. I leave an image where you can see the bounding circle of a contour and where I would like to draw the radius of that circle. Any help would be apreciated.

Thanks in advance. This is the code I've got:

void CirculoMin(int, void* ) { Mat thresh_output; vector<vector<point> > contornos; vector<vec4i> jerarquia;

  threshold( imgThresh,thresh_output, 50, 50, THRESH_TRUNC );
 findContours( thresh_output, contornos, jerarquia, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

vector<vector<Point> > contours_poly( contornos.size() );
vector<Rect> boundRect( contornos.size() );
vector<Point2f>centro( contornos.size() );
vector<float>radio( contornos.size() );

for( uint i = 0; i < contornos.size(); i++ ){

      approxPolyDP( Mat(contornos[i]), contours_poly[i], 3, true );
      minEnclosingCircle( (Mat)contours_poly[i], centro[i], radio[i] );

}

Mat dibujo = Mat::zeros( thresh_output.size(), CV_8UC3 );

for( uint i = 0; i< contornos.size(); i++ ){

   Scalar R = Scalar(0,0,255); /*color rojo*/
   Scalar G = Scalar(0,255,0);/*color verde*/
   Scalar B = Scalar(255,0,0);/*color azul*/

   drawContours( dibujo, contours_poly, i, G, 1, 8, vector<Vec4i>(), 0, Point() );

   if((int)radio[i] >= 15){        
       circle( dibujo, centro[i], (int)radio[i], R, 2, 8, 0 );        
   }//if

}//for

imshow( "Círculo mínimo", dibujo );

}

image description