Search code examples
opencvgeometryhough-transform

Accuracy of the center with hough circle transform


I try to get the center of circles using Hough Circle algorithm from https://github.com/Itseez/opencv/blob/master/samples/cpp/houghcircles.cpp but I need more accurate coordinates.

When I get those coordinates like this

for( size_t i = 0; i < circles.size(); i++ )
{
     Vec3i c = circles[i];
     cout<<c[0]<<"  "<<c[1]<<endl;
}

it prints just the integer part. Is there any posibility to get the center more precise(4 decimals or more)?


Solution

  • You are explicitly converting the coordinates to integers by assigning them to an integer vector (Vec3i). If you print them like this, you will print the values as you get them from OpenCV:

    cout<<circles[0]<<"  "<<circles[1]<<endl;
    

    However, these results might not be as accurate as you desire. In that case, you are out of luck with your current approach as OpenCV does not provide more accurate results.