当前位置: 首页>>代码示例>>C++>>正文


C++ VideoCapture::play方法代码示例

本文整理汇总了C++中VideoCapture::play方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoCapture::play方法的具体用法?C++ VideoCapture::play怎么用?C++ VideoCapture::play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VideoCapture的用法示例。


在下文中一共展示了VideoCapture::play方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char** argv)
{
  if ( argc != 2 )
  {
    cout << "Usage :" << argv[0] << " <video/image filename or camera device>" << endl;
    exit(0);
  }

  cout << "Opening " << argv[1] << endl;
  capture = new Capture( argv[1]);

  char type[32];
  strcpy( type, capture->getType());
  cout << "Type :" << type << endl;

  float fps = 100;

  cvNamedWindow( "Video", 1);

  if ( !strncmp( type, "VIDEO", 5))
  {
    delete capture;
    capture = new VideoCapture( argv[1]);

    VideoCapture* temp = (VideoCapture*) capture;

    //cout << "Width : " <<  temp->getWidth() << endl;
    //cout << "Height : " <<  temp->getHeight() << endl;
    //cout << "Duration : " << temp->getDuration() << endl;
    //cout << "FPS : " << temp->getFPS() << endl;

    fps = 25;
  }
  else
  {
    fprintf( stderr, "Couldn't Not Detect Type of Source");
    fprintf( stderr, " or No Handeller Available\n");
    exit(0);
  }

  if ( !(strncmp( capture->getType(), "VIDEO", 5)))
  {
    VideoCapture* temp = (VideoCapture*) capture;
    temp->play();
    cout << capture->getStatus();
  }

  IplImage* image = NULL;

  if (( capture->getWidth() > 0) && (capture->getHeight() > 0))
  {
    image = cvCreateImageHeader( cvSize(capture->getWidth(),
          capture->getHeight()), IPL_DEPTH_8U, 3);
  }
  else
  {
    cout << capture->getStatus();
    return 0;
  }
  //Assuming height 1100 and width 2000
  vecDetections =  new vector<Detection>* [1100];
  for( int i=0; i<1100; i++)
    vecDetections[i] = new vector<Detection>[2000];


  char key=' ';
  for( int i = 0; ;)
  {
    image->imageData = (char*) capture->getNextFrame();
    processFrameFastHog(image);

    if ( image->imageData == NULL) break;

    cvShowImage( "Video", image);

    key = cvWaitKey((int) 1000.0 / fps);
    if (( key == '\n') && ( i == 0))
    {
      i = 1;
      if ( !(strncmp( capture->getType(), "VIDEO", 5)))
      {
        VideoCapture* temp = (VideoCapture*) capture;
        temp->pause();
      }
    }
    else if( key == 27) break;
  }

  fstream outfile;
  outfile.open("dump.txt", ios_base::out);

  for(int i=0; i<capture->getHeight(); i++)
    for(int j=0; j<capture->getWidth(); j++)
    {
      vector<Detection> detVec = vecDetections[i][j];
      for(int k=0; k<detVec.size(); k++)
      {
        outfile << detVec[k].y << " " << detVec[k].x << " " << detVec[k].width;
        outfile << " " << detVec[k].height << " " << detVec[k].scale << " " << detVec[k].score << endl;
      }
//.........这里部分代码省略.........
开发者ID:achintsetia,项目名称:fastHOG,代码行数:101,代码来源:fastHOGTraining.cpp


注:本文中的VideoCapture::play方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。