Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
497 views
in Technique[技术] by (71.8m points)

opencv - HoughCircles Parameters to recognise balls

After processing an image by converting it to grey scale and then blurring it, I'm trying to apply a Hough Circle Transformation with these parameters:

  • CV_HOUGH_GRADIENT
  • dp = 1
  • min_dist = 1
  • param_1 = 70
  • param_2 = 100
  • min_radius = 0
  • max_radius = 0

Here is one of the many images I've tried: http://i.stack.imgur.com/JGRiM.jpg

But the algorithm fails to recognise the ball even with relaxed parameters.

(When I try it with an image of a circle created in GIMP it works fine)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;

enter image description here

Good luck :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...