Advertisement
Guest User

opencv code

a guest
Jan 31st, 2012
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include "cv.h"
  2. #include "cxcore.h"
  3. #include "highgui.h"
  4. #include "math.h"
  5. #include <iostream>
  6. #include <fstream>
  7. #include <stdlib.h>
  8. #include <sys/stat.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <sstream>
  12. using namespace std;
  13. IplImage *src;
  14. int main(){
  15.     CvCapture* capture = cvCreateFileCapture("test.avi");
  16.     double frameRate = 25.0;
  17.     CvVideoWriter *vdowriter = cvCreateVideoWriter( "newtest.flv", CV_FOURCC('F', 'L', 'V', '1'), frameRate, cvSize(320,240) );
  18.     if(!cvQueryFrame(capture)){ cout<<"Video capture failed, please check the camera."<<endl;}else{cout<<"Video camera capture status: OK"<<endl;};
  19.     CvSize sz = cvGetSize(cvQueryFrame( capture));
  20.     int in=0;
  21.     while((src = cvQueryFrame(capture)) != NULL){
  22.         cvWriteFrame(vdowriter,src);
  23.             if( (cvWaitKey(40) & 255) == 27 && in==200 )
  24.                break;
  25.             in++;
  26.     }
  27.     cvReleaseVideoWriter(&vdowriter);
  28.     cvReleaseCapture( &capture);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement