如何在CamShift中平滑跟踪 [英] How to Smooth the Tracking in CamShift

查看:149
本文介绍了如何在CamShift中平滑跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenCV库函数进行项目跟踪。通过使用 Camshift()功能,我可以跟踪我的手,但它并不稳定,即使我的手保持稳定,跟踪也没有什么动静。所以我无法在正确的位置执行鼠标点击操作。有人请帮我解决这个问题。

I'm Doing Project on hand Tracking using OpenCV library function. By using Camshift() function I could able to track my hands but it wasn't not stable, even I make my hand stable there is little movement in tracking. So I couldn't able to perform mouse click operation at correct position. Someone please help me to figure out this.

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);

}

在上面的代码中,我通过<$获得跟踪对象的位置c $ c> obectLocation 参数,我在被跟踪区域上绘制了矩形。
通过获得它的中心我做了鼠标移动。

In above code I get the tracked object location by obectLocation parameter and I've drawn rectangle over the tracked region. By getting its center I did mouse movement.

关闭手掌以便做 MouseDown 事件,被跟踪对象的位置已被更改。

While closing the palm in order to do MouseDown event, the position of tracked object has being changed.

推荐答案

答案是卡尔曼滤波器。
您可以使用这个代码。如下图所示,过滤后的结果(绿线)忽略了跟踪器的突然位移(青色描绘了原始跟踪结果)。

The answer is Kalman filters. You can use this code. As you can see in the figure below, the filtered results (green line) ignore tracker's sudden displacements (where cyan depicts the original tracking results).

这篇关于如何在CamShift中平滑跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆