1 | initial version |
@FooBar I got a good result when I used your code, but when I used webcam to track the tennis ball, I got a bad result. There were many wrong circle drew arround this ball but no right circle drew cover this ball. Here is my code : capture >> col; cvtColor(col.clone(),src,CV_BGR2GRAY); equalizeHist(src,src); 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;
HoughCircles(src,circles,CV_HOUGH_GRADIENT,
1, // dp
50, // min_dist_px
canny_threshold, // higher canny
20, // acc threshold
0, // min radius
100); // 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]);
circle(col,center,radius,Scalar(0,0,255),2,8,0);
}
imshow("Window1",col);
char c = waitKey(33);
if(c==27) break;
}
Can you help me about this problem ? I will attach the bad result I got when I run my program at here C:\fakepath\Untitled2.png Have a great day !
2 | No.2 Revision |
@FooBar I got a good result when I used your code, but when I used webcam to track the tennis ball, I got a bad result. There were many wrong circle drew arround this ball but no right circle drew cover this ball. Here is my code : capture >> col; cvtColor(col.clone(),src,CV_BGR2GRAY); equalizeHist(src,src); 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;
HoughCircles(src,circles,CV_HOUGH_GRADIENT,
1, // dp
50, // min_dist_px
canny_threshold, // higher canny
20, // acc threshold
0, // min radius
100); // 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]);
circle(col,center,radius,Scalar(0,0,255),2,8,0);
}
imshow("Window1",col);
char c = waitKey(33);
if(c==27) break;
}
Can you help me about this problem ? I will attach the bad result I got when I run my program at here C:\fakepath\Untitled2.png The original Image C:\fakepath\ball.jpg Have a great day !