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