Ask Your Question

Revision history [back]

Detecting tennis balls with HoughCircles

Hi there,

I'm new to OpenCV and struggling to use HoughCircles to detect a tennis ball in a jpg image.

The image has dimensions of 2016x1512px. The tennis ball in the image has a diameter of roughly 360px.

        Console.WriteLine("Detect circle in jpg");

        Mat src1 = new Mat(@"TestData\BowlDefiniteEdgfe.jpg", ImreadModes.Grayscale);
        Mat dst1 = new Mat();

        dst1 = src1.GaussianBlur(new Size(13, 13), 0/*sigmaX*/);
        CircleSegment[] circles1 = dst1.HoughCircles(HoughMethods.Gradient,1/*dp*/, 20/*minDist*/);

I do not understand if I am using suitable parameters for HoughCircle, specifically the second (dp) and the final one (minDist)? I've uploaded the photo but not sure it uploaded successfully.

Note the actually Nuget library was OpenCvSharp3.

tennisball