• <tfoot id='tJlWn'></tfoot>
  • <legend id='tJlWn'><style id='tJlWn'><dir id='tJlWn'><q id='tJlWn'></q></dir></style></legend>
      <bdo id='tJlWn'></bdo><ul id='tJlWn'></ul>
    1. <small id='tJlWn'></small><noframes id='tJlWn'>

        <i id='tJlWn'><tr id='tJlWn'><dt id='tJlWn'><q id='tJlWn'><span id='tJlWn'><b id='tJlWn'><form id='tJlWn'><ins id='tJlWn'></ins><ul id='tJlWn'></ul><sub id='tJlWn'></sub></form><legend id='tJlWn'></legend><bdo id='tJlWn'><pre id='tJlWn'><center id='tJlWn'></center></pre></bdo></b><th id='tJlWn'></th></span></q></dt></tr></i><div id='tJlWn'><tfoot id='tJlWn'></tfoot><dl id='tJlWn'><fieldset id='tJlWn'></fieldset></dl></div>

      1. openCV:如何将视频拆分为图像序列?

        时间:2023-10-07
            <bdo id='z4qf4'></bdo><ul id='z4qf4'></ul>

              <tbody id='z4qf4'></tbody>

                1. <i id='z4qf4'><tr id='z4qf4'><dt id='z4qf4'><q id='z4qf4'><span id='z4qf4'><b id='z4qf4'><form id='z4qf4'><ins id='z4qf4'></ins><ul id='z4qf4'></ul><sub id='z4qf4'></sub></form><legend id='z4qf4'></legend><bdo id='z4qf4'><pre id='z4qf4'><center id='z4qf4'></center></pre></bdo></b><th id='z4qf4'></th></span></q></dt></tr></i><div id='z4qf4'><tfoot id='z4qf4'></tfoot><dl id='z4qf4'><fieldset id='z4qf4'></fieldset></dl></div>
                2. <legend id='z4qf4'><style id='z4qf4'><dir id='z4qf4'><q id='z4qf4'></q></dir></style></legend><tfoot id='z4qf4'></tfoot>

                3. <small id='z4qf4'></small><noframes id='z4qf4'>

                  本文介绍了openCV:如何将视频拆分为图像序列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  使用opencv,如何将视频分割成图像序列?
                  我如何拆分它以便输出将是一系列图像?

                  Using opencv, how can one split a video into an image sequence?
                  How can i split it so that the output will be a sequence of images?

                  推荐答案

                  令我惊讶的是,我在 StackoverFlow 上找不到这个问题的答案.

                  For my surprise, I couldn't find an answer to this question on StackoverFlow.

                  我目前使用的是 OpenCV 2.1.这可能有点旧,但它就像一个魅力.该程序将读取一个输入文件并在名为 *frame_xx.jpg* 的当前文件夹上创建一系列图像

                  I'm currently using OpenCV 2.1. This might be a little old but it works like a charm. The program will read an input file and create a sequence of images on the current folder named *frame_xx.jpg*

                  #include <stdio.h>
                  #include <stdlib.h>
                  #include "cv.h"
                  #include "highgui.h"
                  
                  int main( int argc, char** argv )
                  {  
                      if (argc < 2)
                      {
                          printf("!!! Usage: ./program <filename>
                  ");
                          return -1;
                      }
                  
                      printf("* Filename: %s
                  ", argv[1]);   
                  
                      CvCapture *capture = cvCaptureFromAVI(argv[1]);
                      if(!capture) 
                      {
                          printf("!!! cvCaptureFromAVI failed (file not found?)
                  ");
                          return -1; 
                      }
                  
                      int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
                      printf("* FPS: %d
                  ", fps);
                  
                      IplImage* frame = NULL;
                      int frame_number = 0;
                      char key = 0;   
                  
                      while (key != 'q') 
                      {
                          // get frame 
                          frame = cvQueryFrame(capture);       
                          if (!frame) 
                          {
                              printf("!!! cvQueryFrame failed: no frame
                  ");
                              break;
                          }       
                  
                          char filename[100];
                          strcpy(filename, "frame_");
                  
                          char frame_id[30];
                          itoa(frame_number, frame_id, 10);
                          strcat(filename, frame_id);
                          strcat(filename, ".jpg");
                  
                          printf("* Saving: %s
                  ", filename);
                  
                          if (!cvSaveImage(filename, frame))
                          {
                              printf("!!! cvSaveImage failed
                  ");
                              break;
                          }
                  
                          frame_number++;
                  
                          // quit when user press 'q'
                          key = cvWaitKey(1000 / fps);
                      }
                  
                      // free resources
                      cvReleaseCapture(&capture);
                  
                      return 0;
                  }
                  

                  这篇关于openCV:如何将视频拆分为图像序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:C++:打开视频文件最简单的库是什么 下一篇:使用 Qt 播放实时视频流

                  相关文章

                  最新文章

                  <tfoot id='VFotG'></tfoot>
                  <legend id='VFotG'><style id='VFotG'><dir id='VFotG'><q id='VFotG'></q></dir></style></legend>
                4. <small id='VFotG'></small><noframes id='VFotG'>

                      <bdo id='VFotG'></bdo><ul id='VFotG'></ul>

                      <i id='VFotG'><tr id='VFotG'><dt id='VFotG'><q id='VFotG'><span id='VFotG'><b id='VFotG'><form id='VFotG'><ins id='VFotG'></ins><ul id='VFotG'></ul><sub id='VFotG'></sub></form><legend id='VFotG'></legend><bdo id='VFotG'><pre id='VFotG'><center id='VFotG'></center></pre></bdo></b><th id='VFotG'></th></span></q></dt></tr></i><div id='VFotG'><tfoot id='VFotG'></tfoot><dl id='VFotG'><fieldset id='VFotG'></fieldset></dl></div>