OpenCV, Video file load and display example source code (using VideoCapture function)

This is example source code to load video file and display

//file load
 VideoCapture capture(".\\video.avi");
 Mat frame;

 //check
 if( !capture.isOpened() )
 {
  printf("AVI file can not open.\n");
  return;
 }
 
 //create window
 namedWindow("w");
 
 while(1)
 {
  //grab frame from file & throw to Mat
  capture >> frame;
  if(frame.empty() ) //Is video end?
   break;
  
  //processing example
  Sobel(frame,frame,frame.depth(),1,0);
  ////////////////////

  //display and delay
  imshow("w", frame);
  if(waitKey(10) > 0)
   break;
 }

Thank you.

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

Image warping (using opencv findHomography, warpPerspective)

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