【发布时间】:2012-01-07 03:50:10
【问题描述】:
我试图检测一个白球最初接触的是什么颜色的球。
所有球的坐标和颜色都是已知的,球的视频输入将是顶视图,因此只有 x-y 坐标
我检测到的球的代码如下
*//draw all detected circles
for (int i = 0; i < circles->total; i++)
{
// round the floats to an int
float* p = (float*)cvGetSeqElem(circles, i);
cv::Point center(cvRound(p[0]), cvRound(p[1]));
int radius = cvRound(p[2]);
//uchar* ptr;
//ptr = cvPtr2D(img, center.y, center.x, NULL);
//printf("B: %d G: %d R: %d\n", ptr[0],ptr[1],ptr[2]);
CvScalar s;
s = cvGet2D(img,center.y, center.x);//colour of circle
printf("B: %f G: %f R: %f\n",s.val[0],s.val[1],s.val[2]);
// draw the circle center
cvCircle(img, center, 3, CV_RGB(0,255,0), -1, 8, 0 );
// draw the circle outline
cvCircle(img, center, radius+1, CV_RGB(0,0,255), 2, 8, 0 );
//display coordinates
printf("x: %d y: %d r: %d\n",center.x,center.y, radius);
}*
【问题讨论】:
-
这是什么编程语言?
-
应该把它放进去。它的 C.im 也使用 opencv
标签: c opencv collision-detection geometry