如何绘制图像中的轨迹(跟踪路径)- Opencv?
我知道运动物体( x,y)的坐标,每一个帧都在更新新的(x,y)坐标。
现在,如何为最后20帧或N个帧绘制目标的轨迹路径。
发布于 2014-04-30 12:34:18
cv::Mat imageToDraw; //this is your image to draw, don't forget to load it
std::vector<cv::Point> pointsInLast20Frames; //fill this vector with points, they should be ordered
cv::Scalar color(0, 0, 255); //red
for(int i = 0; i < pointsInLast20Frames.size() - 1; ++i)
{
cv::line(imageToDraw, pointsInLast20Frames[i], pointsInLast20Frames[i+1], color);
}发布于 2014-04-30 13:00:08
经过与协调者的长期斗争,我的代码..跟踪N个帧数
int nTrackCount = 0;
int nTrackFrames = 20;
vector<Rect> boundRect1( nTrackFrames );
Detect_Object(frame)
{
if ( nTrackCount < nTrackFrames )
{
boundRect1[nTrackCount].x = PredictKP.x;
boundRect1[nTrackCount].y = PredictKP.y;
}
nTrackCount++;
for ( int iTrack = 0; iTrack < nTrackCount ; iTrack++)
{
Point Pt;
Pt.x = boundRect1[iTrack].x;
Pt.y = boundRect1[iTrack].y;
// Drawing Cross ( X ) for tracking
drawCross(frame, Pt, Scalar(255, 255, 255), 5); // Corrected
}
if(nTrackCount ==nTrackFrames)
nTrackCount = 0;
}https://stackoverflow.com/questions/23387459
复制相似问题