Ask Your Question

vkcelik's profile - activity

2017-05-08 18:47:12 -0500 received badge  Notable Question (source)
2016-04-11 04:18:38 -0500 received badge  Popular Question (source)
2014-06-16 07:34:04 -0500 commented question Split connected blobs

I have added it to the question

2014-06-16 05:32:27 -0500 asked a question Split connected blobs

Hello

I am using contours to detect the balls by their area. The problem arises when the balls are next to each other. I have tried the erode function but I can't get it right.

This is a sample picture:

image description

This is the binary image I get after using inRange.

image description

How would you guys tackle this problem? Would you use erode? In that case, which parameters would you give to the function? Is there any other way than erode, which is not very complex?

EDIT: Adding eroded image by request. image description

Im using this code to get it:

Imgproc.erode(filtered, filtered, Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, new Size(8,8)));
2014-06-15 13:34:10 -0500 commented question Detection of table tennis balls and color correction

Thanks for the reply. I solved the problem by applying a GuassianBlur, adaptiveThreshold, erode, removed the noise (erode, dilate, dilate, erode) and findContours. For each contour I checked whether the area was in a acceptable interval and used boundingRect to find the center of the circle countour.

2014-06-15 13:34:00 -0500 commented answer Detection of table tennis balls and color correction

Thanks for the reply. As you said in the answer, the method did not work on all my test images. I solved the problem by applying a GuassianBlur, adaptiveThreshold, erode, removed the noise (erode, dilate, dilate, erode) and findContours. For each contour I checked whether the area was in a acceptable interval and used boundingRect to find the center of the circle countour.

2014-06-13 14:48:58 -0500 commented question Detection of table tennis balls and color correction

Thanks for the comment. I will look into it and tell if it works.

2014-06-13 06:10:12 -0500 received badge  Student (source)
2014-06-12 21:22:22 -0500 received badge  Editor (source)
2014-06-12 21:19:45 -0500 asked a question Detection of table tennis balls and color correction

Hello

I am making a robot project and I am trying to detect the tables tennis balls in pictures (from a webcam) like this.

Hej

I have tried different smoothing functions and tried a lot different numbers in the parameters to the functions, but the image (pre-processed) that gives best results look like this.

image description

The camera stand foot got detected as a circle but I removed that result and 4 balls are not found. This is the balls I find at the end.

So far

This is my code:

src = Highgui.imread("Picture 10.jpg",1);
Mat srcH = new Mat();
src.convertTo(srcH, -1, 0.7, 0);
Highgui.imwrite("contrast.jpg", srcH);

Imgproc.cvtColor(srcH, src_gray, Imgproc.COLOR_BGR2GRAY);
Imgproc.equalizeHist(src_gray, src_gray);
Highgui.imwrite("outgray.jpg", src_gray);
Imgproc.GaussianBlur(src_gray, smooth, new Size(11,11),4, 4);
Highgui.imwrite("blur.jpg", smooth);
Imgproc.HoughCircles(smooth, circles, Imgproc.CV_HOUGH_GRADIENT, 2, 20, 81, 29, 10, 13);

System.out.println("Found "+circles.cols() + " circles.");
for (int i = 0; i < circles.cols(); i++) {
    double[] circle = circles.get(0,i);
    if (src.get((int)circle[1], (int)circle[0])[2]>140){
        list.add(new Ball((int)circle[0],(int)circle[1]));
        Point center = new Point((int)circle[0], (int)circle[1]);

        int radius =  (int) circle[2];
        // circle center
        Core.circle( src, center, 3, new Scalar(0,255,0), -1, 8, 0 );
        // circle outline
        Core.circle( src, center, radius, new Scalar(0,0,255), 3, 8, 0 );
     }
}

Do you guys have any ideas about why the last 4 balls are not detected and how the pre-processing can be improved?

I am also having trouble detecting the colored circles on the robot. Sometimes it works, sometimes it doesn't. I think the sunlight affects the detection. I found this color balance technique which is implemented in Matlab (I think) and I have no idea how I would translate that to OpenCV. Any advice on how to translate that would also be appreciated.

2014-06-12 18:54:09 -0500 received badge  Supporter (source)