开发者

trouble with output directory for OpenCV VideoWriters

I'm a math undergrad and have little programming experience. I'm interested in computer vision however. Tried to follow the Learning OpenCV book but its slightly outdated. How do i save the resulting video file in my linux home directory? for eg "/home/user/..", thanks in advance, this is my first post and i know i won't be disappointed. I'm compiling on eclipse btw, and i'm not too familiar with the arguments setting.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>


int main(int argc, char *argv[]) {

 int isColor = 1;
 int frameW  = 640;
 int frameH  = 480;
 int fps     = 开发者_开发问答25;

 CvCapture* capture = cvCaptureFromCAM(0);
 assert( capture != NULL );

 cvNamedWindow( "Webcam", CV_WINDOW_AUTOSIZE);

 CvVideoWriter *writer = cvCreateVideoWriter(
   "out.avi",
   CV_FOURCC('M','J','P','G'),
   fps,
   cvSize(frameW,frameH),
   isColor
  );

 IplImage* frame = cvQueryFrame( capture );

 while( (frame = cvQueryFrame( capture )) != NULL ) {
  cvWriteFrame(writer, frame);
  cvShowImage("Webcam", frame);
  char c = cvWaitKey( 33 );
  if ( c == 27 ) break;
 }

 cvReleaseVideoWriter( &writer );
 cvReleaseCapture( &capture );
 return(0);

}


Have you tried passing the full path to cvCreateVideoWriter?

 CvVideoWriter *writer = cvCreateVideoWriter(
   "/home/user/out.avi",
   CV_FOURCC('M','J','P','G'),
   fps,
   cvSize(frameW,frameH),
   isColor
  );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜