HoughCircles Parameters to recognise balls

柔情痞子 提交于 2019-11-28 09:27:58

I agree with krzych. I had it working effortlessly with :

cv::Mat img,img2;
std::vector<cv::Vec3f> circles;
img = cv::imread("JGRiM.jpg",1);
cv::bilateralFilter(img, img2, 15, 1000, 1000);
cv::cvtColor(img2, img2,CV_BGR2GRAY);
cv::HoughCircles(img2, circles, CV_HOUGH_GRADIENT, 1,300,50, 10);
cv::circle(img2,cv::Point(circles[0][0],circles[0][1]),circles[0][2],cv::Scalar(126),2);
cv::imshow("test",img2);

cv::waitKey(0);
cv::imwrite("test.jpg",img2);
return 0;

Good luck :)

Check Canny output of your images first. From this Canny output it is possible to detect ball with very small param_2 as well as many false circles on image. (I've used for example param_2 = 10, and with specified ball center to eliminate false circles it works)

Try to help Hough Circle Transform. The task is to segment ball from other elements. In your image problem is line, you can try to segment ball using colours for example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!