Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is exactly what my app does in iOS. Your circle is HUGE, easier to start with smaller circles...like coins. The only thing in my code that is not in yours is I run the Canny Edge Detector (cv::Canny(gray, edges, t1, t2, aS, l2); //25, 35, 3, true) after the Gaussian Blur. Also...if your parameters for Hough Circles are in the same order as mine then I would use something like this in the parameters after the Gradient. 1 or 2 for the AIR. 200, 35, 30, 300, 600. The first number is the Accumulated Inverse Ratio which determines the amount of pixels used from the image....either all or half. The second is the Minimum Distance Between Centers amount...and 20 is a bit small, since the ball is most of the image. Third parameter should be the same as the Threshold 2 setting in your Canny Edge Detector, which you should add, imo. Fourth is the Detection Filter and you have it maxed....drop that to 20 or 30. Fifth it is Minimum Distance, smallest circle. Sixth is Maximum Distance, largest circle. 0, 0 for the last two are common to scan the pic for every size possible, it is better to enter parameters so you will become familiar on how HC works. The numbers I gave you are for detecting the circle in your image. If you use some coins (easier) then try 2, 100, 35, 40, 50, 70. Hope this helps.

This is exactly what my app does in iOS. Your circle is HUGE, easier to start with smaller circles...like coins. The only thing in my code that is not in yours is I run the Canny Edge Detector (cv::Canny(gray, Detectorcv::Canny(gray, edges, t1, t2, aS, l2); //25, 35, 3, true) true (sub numbers for my int parameters) after the Gaussian Blur. Also...if your parameters for Hough Circles are in the same order as mine then I would use something like this in the parameters after the Gradient. 1 or 2 for the AIR. 200, 35, 30, 300, 600. The first number is the Accumulated Inverse Ratio which determines the amount of pixels used from the image....either all or half. The second is the Minimum Distance Between Centers amount...and 20 is a bit small, since the ball is most of the image. Third parameter should be the same as the Threshold 2 setting in your Canny Edge Detector, which you should add, imo. Fourth is the Detection Filter and you have it maxed....drop that to 20 or 30. Fifth it is Minimum Distance, smallest circle. Sixth is Maximum Distance, largest circle. 0, 0 for the last two are common to scan the pic for every size possible, it is better to enter parameters so you will become familiar on how HC works. The numbers I gave you are for detecting the circle in your image. If you use some coins (easier) then try 2, 100, 35, 40, 50, 70. Hope this helps.

This is exactly what my app does in iOS. Your circle is HUGE, easier to start with smaller circles...like coins. First off, check your header files for something like #import <opencv2/opencv.hpp>, this includes all the imports or "includes" in your case.. The only thing in my code that is not in yours is I run the Canny Edge Detectorcv::Canny(gray, edges, t1, t2, aS, l2); //25, 35, 3, true (sub numbers for my int parameters) after the Gaussian Blur. Also...if your parameters for Hough Circles are in the same order as mine then I would use something like this in the parameters after the Gradient. 1 or 2 for the AIR. 200, 35, 30, 300, 600. The first number is the Accumulated Inverse Ratio which determines the amount of pixels used from the image....either all or half. The second is the Minimum Distance Between Centers amount...and 20 is a bit small, since the ball is most of the image. Third parameter should be the same as the Threshold 2 setting in your Canny Edge Detector, which you should add, imo. Fourth is the Detection Filter and you have it maxed....drop that to 20 or 30. Fifth it is Minimum Distance, smallest circle. Sixth is Maximum Distance, largest circle. 0, 0 for the last two are common to scan the pic for every size possible, it is better to enter parameters so you will become familiar on how HC works. The numbers I gave you are for detecting the circle in your image. If you use some coins (easier) then try 2, 100, 35, 40, 50, 70. Hope this helps.