# How can I write numbers inside the detected circles on the image when using Hough Circle Transform?

I used the Hough Circle Transform to detected around 2000~4000 circular wood columns. I followed the link below. http://docs.opencv.org/doc/tutorials/... my questions are:

1. How can I write a number inside the detected circles? i.e. to write a number 1,2,3, to each of detected circle inside the red circle.

2. How can I save the image of question 1 to a file so that I can later check the result?

edit retag close merge delete

Sort by ยป oldest newest most voted

cv::puttext to write the numbers and cv::imwrite to save the image. Although you could have easily find that on your own...

Google: "opencv print text" first hit: http://docs.opencv.org/modules/core/d...

Google: "opencv save image" first hit: http://docs.opencv.org/doc/tutorials/...

more

THank you very much . I followed your link and add the following code to the tutorial. However, the number can not be located around the center of a circle.

//For putting the numbers on the image; locate the center of the numbers to be putted on the image Point centerText(cvRound(circles[i][0])-radius/2, cvRound(circles[i][1])-radius/2);

  //Convert an integer to a string;
ss << i+1;
text = ss.str();
//Put the string on the image
putText(src, text, centerText, fontFace, fontScale, Scalar::all(0),thicknessText,0);
//Clear the string;
ss.str("");

( 2015-01-05 21:53:44 -0500 )edit

Please do not add other answers if they don't have a solution, but use comments or edit button. I just switched it for you.

( 2015-01-06 06:19:56 -0500 )edit

In the tutorial go to this line of code

Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));


stringstream ss;
ss << i+1;
putText(src, ss.str(), center, 1, 1, Scalar(255,0,0), 2,0);


This doest exactly what you want!

more

Official site

GitHub

Wiki

Documentation