I can't detect and draw the circle cover the tennis ball using webcam [closed]

asked 2014-09-12 08:22:35 -0500

nhat.truong gravatar image

Hi everybody ! I used webcam to detect and draw the circle cover the ball that was got from webcam using Hough transform, but I couldn't draw right circle cover this ball and there were many wrong circles were painted. Here is my code : VideoCapture capture(0); Mat src,col; while(true) { capture >> col; cvtColor(col.clone(),src,CV_BGR2GRAY); GaussianBlur( src, src, Size(9, 9), 2, 2 ); if(src.empty()) { cout<< "can't load file from webcam" <<endl; }<="" p="">

        int canny_threshold = 200;

        vector<Vec3f> circles;
            1, // dp
            50, // min_dist_px
            canny_threshold, // higher canny
            20, // acc threshold
            0, // min radius
            0); // max radius

            for(int i=0;i<circles.size(); i++)
            Point center(cvRound(circles[i][0]),cvRound(circles[i][1]));
            int radius = cvRound(circles[i][2]);

        char c = waitKey(33);
        if(c==27) break;

Can everyone help me about this problem ? I will attach the error window that contain many wrong circles I got when I debug at here C:\fakepath\Untitled2.png Have a great day !

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by berak
close date 2014-09-12 12:17:39.883703