4
我正在做手头项目使用OpenCV库函数进行跟踪。通过使用Camshift()
功能,我可以跟踪我的手,但它并不稳定,即使我的手稳定,跟踪中的动作也不大。所以我无法在正确的位置进行鼠标点击操作。有人请帮我弄清楚这一点。如何平滑CamShift中的跟踪
void TrackingObjects::drawRectangle(CvRect objectLocation){
CvPoint p1, p2,mou;
CvRect crop;
p1.x = objectLocation.x;
p2.x = objectLocation.x + objectLocation.width;
p1.y = objectLocation.y;
p2.y = objectLocation.y + objectLocation.height;
cvRectangle(image,p1,p2,CV_RGB(0,255,0),1,CV_AA,0);
mou.x=(p2.x-p1.x)/2;
mou.x=p1.x+mou.x;
mou.y=(p2.y-p1.y)/2;
mou.y=p1.y+mou.y;
SetCursorPos(mou.x,mou.y);
}
在上面的代码中,我通过obectLocation
参数得到的跟踪对象的位置和我所绘制矩形在跟踪区域。 通过获得它的中心我做了鼠标移动。
虽然为了做MouseDown
事件而关闭手掌,但跟踪对象的位置正在改变。
什么问题? – Safir 2013-03-28 12:41:36