Ask Your Question
0

Circle Detection

asked 2013-03-22 04:38:23 -0600

Aayman gravatar image

Hi, I am compiling a code for Hough Circle Transform from the following link: http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html

this code should return the circular object framed in a red circle and a green dot at the center but it's not working that way... what it does, is to display the image as such... looking forward to guidance...

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-03-22 05:35:38 -0600

In the example code you see this appearing somewhere

 /// Draw the circles detected
  for( size_t i = 0; i < circles.size(); i++ )
  {
      Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
      int radius = cvRound(circles[i][2]);
      // circle center
      circle( src, center, 3, Scalar(0,255,0), -1, 8, 0 );
      // circle outline
      circle( src, center, radius, Scalar(0,0,255), 3, 8, 0 );
   }

  /// Show your results
  namedWindow( "Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE );
  imshow( "Hough Circle Transform Demo", src );

If you do not see your circles display, but just the original image, this means that you have not displayed the adapted image. What this code does is:

  1. Reading in the image (not in code sample here - but in the original guide it is
  2. Using the circle command, you add information to the mat object
  3. When then calling imshow, you actually show the adapted form of the Mat element, and not the original.

Did you check that you used the exact same code? Didn't you adapt names of variables for better understanding for yourself? Check again or post your exact code as from your project.

edit flag offensive delete link more
0

answered 2013-04-02 22:26:42 -0600

iceman gravatar image

Hi!i'm new here.i come across the same question! And i check out every message mentioned above.but my trouble still here. The output appears to be the same of the input.what's wrong with it? here i put my code with my input image.

image description

image description

edit flag offensive delete link more

Comments

Actually, look clearly to your image. The circle is showing in black i think, which is weird since you asked colours. Can you increase the thickness parameter of the circle drawing to your screen. It seems weird that in the first circle, it is -1, change it to 10 (which is a large circle, but better visible), same for the 3 value Then please check if still nothing appears. If the resolution of your input image is very large I have a few other suggestions, but please try this one first.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-03 01:18:39 -0600 )edit

Question Tools

Stats

Asked: 2013-03-22 04:38:23 -0600

Seen: 946 times

Last updated: Apr 02 '13