• <small id='pNcUw'></small><noframes id='pNcUw'>

  • <legend id='pNcUw'><style id='pNcUw'><dir id='pNcUw'><q id='pNcUw'></q></dir></style></legend>
      <bdo id='pNcUw'></bdo><ul id='pNcUw'></ul>

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

      1. <tfoot id='pNcUw'></tfoot>

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

        时间:2023-06-05
        <i id='IyCBk'><tr id='IyCBk'><dt id='IyCBk'><q id='IyCBk'><span id='IyCBk'><b id='IyCBk'><form id='IyCBk'><ins id='IyCBk'></ins><ul id='IyCBk'></ul><sub id='IyCBk'></sub></form><legend id='IyCBk'></legend><bdo id='IyCBk'><pre id='IyCBk'><center id='IyCBk'></center></pre></bdo></b><th id='IyCBk'></th></span></q></dt></tr></i><div id='IyCBk'><tfoot id='IyCBk'></tfoot><dl id='IyCBk'><fieldset id='IyCBk'></fieldset></dl></div>
          <bdo id='IyCBk'></bdo><ul id='IyCBk'></ul>

              <small id='IyCBk'></small><noframes id='IyCBk'>

            1. <tfoot id='IyCBk'></tfoot>
              1. <legend id='IyCBk'><style id='IyCBk'><dir id='IyCBk'><q id='IyCBk'></q></dir></style></legend>

                    <tbody id='IyCBk'></tbody>
                  本文介绍了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:如何将视频拆分为图像序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

                • <legend id='HkhzH'><style id='HkhzH'><dir id='HkhzH'><q id='HkhzH'></q></dir></style></legend>

                      <small id='HkhzH'></small><noframes id='HkhzH'>

                        <bdo id='HkhzH'></bdo><ul id='HkhzH'></ul>
                      <tfoot id='HkhzH'></tfoot>

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