Guest User

Untitled

a guest
Jul 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdio.h>
  4.  
  5. #include "opencv/cv.h"
  6. #include "opencv/highgui.h"
  7. #include "opencv/cvaux.h"
  8. #include "opencv/cxcore.h"
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14.     CvCapture * capture = cvCaptureFromAVI("square.avi");
  15.     IplImage * frame;
  16.  
  17.     if(!capture)
  18.     {
  19.         perror("");
  20.         return 10;
  21.     }
  22.  
  23.     char key = 'c';
  24.     int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
  25.  
  26.     cvNamedWindow("Video");
  27.  
  28.     while(key != 'q' && key != 'Q')
  29.     {
  30.         frame = cvQueryFrame(capture);
  31.  
  32.         if(!frame)
  33.         {
  34.             perror("");
  35.             return 20;
  36.         }
  37.  
  38.         cvShowImage("Video", frame);
  39.  
  40.         key = cvWaitKey(1000 / fps);
  41.     }
  42.  
  43.     cvReleaseImage(&frame);
  44.     cvReleaseCapture(&capture);
  45.     cvDestroyAllWindows();
  46.  
  47.     return 0;
  48. }
Add Comment
Please, Sign In to add comment