opencv, simple source code Video frames to jpeg files (VideoCapture, imwrite)

simple source code.

read avi file and save jpeg files.

set video file name and save directory property in your setting.

#include < opencv2\opencv.hpp>
#include < stdio.h>


#ifdef _DEBUG        
#pragma comment(lib, "opencv_core249d.lib")
#pragma comment(lib, "opencv_imgproc249d.lib")   
#pragma comment(lib, "opencv_highgui249d.lib")
#else
#pragma comment(lib, "opencv_core249.lib")
#pragma comment(lib, "opencv_imgproc249.lib")
#pragma comment(lib, "opencv_highgui249.lib")
#endif  

using namespace std;
using namespace cv;

void main()
{
 VideoCapture stream1("./bigBugs1.avi");  //file name

 if (!stream1.isOpened()) { //check if video file has been initialised   
  cout << "cannot open the file";   
 }   
 //window name
 namedWindow("Origin");   

 //string 
 char str[256];
 int frameCount=0;
 //unconditional loop   
 while (true) {   
  Mat Frame;   
  if( stream1.read(Frame) == 0) //get one frame form video   
   break;
  imshow("Origin", Frame);   

  sprintf_s(str,".\\frames1\\%d_frames.jpg", frameCount++);
  imwrite(str,Frame);
  
  

  if (waitKey(30) >= 0)   
   break;   
 }   

 destroyAllWindows();   


}

..


Comments

Popular posts from this blog

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

OpenCV Stitching example (Stitcher class, Panorama)

AMP dose run on my pc?, AMP(Accelerated Massive Parallelism)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Optical Flow sample source code using OpenCV

Real-time N camera stitching Class.

OpenCV meanShiftFiltering example source code ( cpu: pyrMeanShiftFiltering, gpu:meanShiftFiltering, gpu:meanShiftSegmentation )

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)

Image warping (using opencv findHomography, warpPerspective)