opencv 3/C++그림 을 비디오 로 변환 하 는 인 스 턴 스

현재 일부 그림 은 한 폴 더 의 jogging 1\아래 순서대로 놓 여 있 습 니 다.그림:

통합 해서 동 영상 으로 변환 해 야 합 니 다.
예시:
환경:Win7+OpenCV3+VS 2012

#include<opencv2/opencv.hpp>
#include <stdio.h>
#include <io.h>
#include <string>
#include <iostream> 
#include <fstream> 
using namespace std;
using namespace cv;

int main()
{
  _finddata_t FileInfo; 
  //         
  string inPath = "E:\\image\\yu\\jogging1\\"; 
  string strfind = inPath + "*";
  long Handle = _findfirst(strfind.c_str(), &FileInfo);
  char filename[300];
  Mat src;
  if (Handle == -1L)
  { 
    cerr << "can not match the folder path" << endl; 
    exit(-1);
  }

  Mat frame;
  Mat src0 = imread("E:/image/yu/jogging1/0000.jpg");
  Size size = src0.size();
  VideoWriter writer;
  writer.open("jogging.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25, size, true);

  do{
    //        
    if (FileInfo.attrib & _A_SUBDIR) 
    { 
      if ((strcmp(FileInfo.name, ".") != 0) && (strcmp(FileInfo.name, "..") != 0)) 
      { 
        inPath += FileInfo.name;
        cout <<inPath<<endl; 
      }
    }
    else
    {
      cout <<inPath<<FileInfo.name<<endl;
      //         
      string path = "E:/image/yu/jogging1/" + (string)FileInfo.name;
      src = imread(path);
      imshow("input", src);
      writer.write(src);
      waitKey(1);
    } 
  } while (_findnext(Handle, &FileInfo) == 0); 
  _findclose(Handle);  
  return 0; 
}

이상 의 opencv 3/C++사진 을 동 영상 으로 변환 하 는 인 스 턴 스 는 바로 작은 편집 이 여러분 에 게 공유 하 는 모든 내용 입 니 다.여러분 께 참고 가 되 고 저 희 를 많이 사랑 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기