• <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:如何将视频拆分为图像序列?

        openCV: How to split a video into image sequence?(openCV:如何将视频拆分为图像序列?)
        <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:如何将视频拆分为图像序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)
                • <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>
                            <tbody id='HkhzH'></tbody>
                          <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>