如何绘制运动时跟踪一个对象
how to draw the movement when tracking an object?
我使用webcam和使用openCV检索每帧和跟踪对象的位置。
基本上,我在每一帧中都有一个点。但是我怎样才能实时绘制运动图呢?
我是否需要一个计时器来记录特定时间内的几个点并绘制线条?
在while循环中,我只获取一帧,我不认为如果我在当前帧上画一条线,我仍然可以在下一帧中保持这条线。那么我应该如何显示这个运动呢?
while( true )
{
//Read the video stream
capture = cvCaptureFromCAM(1);
frame = cvQueryFrame( capture );
//Apply the classifier to the frame
detectAndDisplay(frame); // I got a point from this function
// waitkey enter
int c = waitKey(10);
if( (char)c == 27 ) { exit(0); }
}
使用矢量来保存位置,然后在每一帧上绘制它们。注意,函数需要返回检测到的点。我改了它的名字,因为它在那个点不画。
vector<CvPoint> trajectory; Vec3b mycolor(100,0,0); while( true ) { //Read the video stream capture = cvCaptureFromCAM(1); frame = cvQueryFrame( capture ); //Apply the classifier to the frame CvPoint cur_pnt=detect(frame); // I got a point from this function trajectory.push_back(cur_point); //Draw points. for (int i=0;i<trajectory.size();i++) frame.at<Vec3b>(trajectory[i].x,trajectory[i].y)=mycolor; // waitkey enter int c = waitKey(10); if( (char)c == 27 ) { exit(0); } }
相关文章:
- 光线跟踪器灯光反射错误
- 人脸跟踪arduino代码的优化
- 跟踪滚动条上的鼠标事件
- 如何使用新运算符跟踪在循环中创建的 QLabel
- C++:跟踪类对象
- 用于解析 win64 堆栈跟踪的命令行客户端(可以访问符号服务器)
- 跟踪日志中的T.11803()是什么意思?
- 我能做些什么来跟踪矢量元素?
- 两个进程可以通过跟踪附加到同一个 PID 吗?
- 粒子系统:所有粒子都朝同一方向运动
- 提升堆栈跟踪不显示函数名称和行号
- cygwin_exception::open_stackdumpfile:将堆栈跟踪转储到 class4.exe.sta
- 如何按指针查看堆栈跟踪
- WinDbg 不显示某些小型转储文件的完整堆栈跟踪
- C++ MFC 跟踪事件调用
- 是否可以/希望创建不可复制的共享指针模拟(以启用weak_ptr跟踪/借用类型语义)?
- 使用 Dijkstra 算法跟踪两个节点之间的最短路径
- 发布代码的 gdb 堆栈跟踪可读性如何影响 x64?
- MATLAB:跟踪imufilter对象中的状态变化
- 如何绘制运动时跟踪一个对象