Image 如何在图像Opencv中绘制运动对象的轨迹(跟踪路径)?

Image 如何在图像Opencv中绘制运动对象的轨迹(跟踪路径)?,image,opencv,draw,Image,Opencv,Draw,如何在图像-Opencv中绘制轨迹(跟踪路径) 我知道一个运动物体的坐标(x,y),每一帧它都在更新新的坐标(x,y) 现在,如何绘制最近20帧或N帧数的对象轨迹路径。cv::Mat imageToDraw//这是要绘制的图像,别忘了加载它 cv::Mat imageToDraw; //this is your image to draw, don't forget to load it std::vector<cv::Point> pointsInLast20Frames; //f

如何在图像-Opencv中绘制轨迹(跟踪路径)

我知道一个运动物体的坐标(x,y),每一帧它都在更新新的坐标(x,y)

现在,如何绘制最近20帧或N帧数的对象轨迹路径。

cv::Mat imageToDraw//这是要绘制的图像,别忘了加载它
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);
}
std::最近20帧的向量点//用点填充这个向量,它们应该是有序的 cv::标量颜色(0,0,255)//红色 对于(int i=0;i
cv::Mat imageToDraw//这是要绘制的图像,别忘了加载它
std::最近20帧的向量点//用点填充这个向量,它们应该是有序的
cv::标量颜色(0,0,255)//红色
对于(int i=0;i
cv::Mat imageToDraw//这是要绘制的图像,别忘了加载它
std::最近20帧的向量点//用点填充这个向量,它们应该是有序的
cv::标量颜色(0,0,255)//红色
对于(int i=0;i
cv::Mat imageToDraw//这是要绘制的图像,别忘了加载它
std::最近20帧的向量点//用点填充这个向量,它们应该是有序的
cv::标量颜色(0,0,255)//红色
对于(int i=0;i
经过与坐标的长期斗争,这里是我的代码。。跟踪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;
}
int nTrackCount=0;
int nTrackFrames=20;
向量boundRect1(nTrackFrames);
检测对象(帧)
{    
如果(nTrackCount
经过与坐标的长期斗争,这里是我的代码。。跟踪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;
}
int nTrackCount=0;
int nTrackFrames=20;
向量boundRect1(nTrackFrames);
检测对象(帧)
{    
如果(nTrackCount
经过与坐标的长期斗争,这里是我的代码。。跟踪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;
}
int nTrackCount=0;
int nTrackFrames=20;
向量boundRect1(nTrackFrames);
检测对象(帧)
{    
如果(nTrackCount
经过与坐标的长期斗争,这里是我的代码。。跟踪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;
}
int nTrackCount=0;
int nTrackFrames=20;
向量boundRect1(nTrackFrames);
检测对象(帧)
{    
如果(nTrackCount