0

我想将IplImage's (从视频文件中获取)存储到一个向量中,然后从这个iplimage向量中播放。

#include <iostream>
#include "highgui.h"
using namespace std;

int main()
{
    CvCapture* capture=cvCreateFileCapture("D:\\Video\\Hands tracking.avi");
    vector<IplImage*> imagesNames[2];

    //playing video
    while(1)
   {
       IplImage* img=cvQueryFrame(capture);
       cvShowImage("Video Opencv example nd testing purpose",img);

       imagesNames[0].push_back(img);

       char c = cvWaitKey(30);
       if(c==27) break;
   }

  cvDestroyWindow( "Video Opencv example nd testing purpose" );
  cvReleaseCapture(&capture);

// play back grabbed IplImages
  for(unsigned i=0; imagesNames[0].size();i++)
  {
    cvShowImage("PlayBack from IplImages vector",imagesNames[0][i]);

    char c = cvWaitKey(30);

    if(c==27) break;
   }
return 0;
}

但是上述程序的播放部分无法正常工作并在运行时显示错误。

4

1 回答 1

0
#include <iostream>
#include "highgui.h"
using namespace std;

int main()

{

    CvCapture* capture=cvCreateFileCapture("D:\\Video\\Hands tracking.avi");
    vector<IplImage*> imagesNames;

    //playing video
    while(1)
   {
       IplImage* img=cvQueryFrame(capture);
       cvShowImage("Video Opencv example nd testing purpose",img);

       imagesNames.push_back(img);

      char c = cvWaitKey(30);
      if(c==27)
       break;

   }

  cvDestroyWindow( "Video Opencv example nd testing purpose" );
  cvReleaseCapture(&capture);

// play back grabbed IplImages
 for(unsigned i=0; i < imagesNames.size();i++)
 {

    cvShowImage("PlayBack from IplImages vector",imagesNames[i]);

    char c = cvWaitKey(30);

    if(c==27)
    break;

}
return 0;


}
于 2012-07-31T20:05:47.980 回答