videowriter
hi!
i am the beginner of opencv and i've just written a first program for videocaptur and videowriter. i copied the source from the wiki and changed the only video file name, but it made error.
at first i expected there is no error because i did not write myself but copy from wiki.
next is the source of wiki.
///////
int main(int, char**)
{ VideoCapture capture(1); // open the default camera
if( !capture.isOpened() ) {
printf("Camera failed to open!\n");
return -1;
}
Mat frame;
capture >> frame; // get first frame for size
// record video
VideoWriter record("RobotVideo.avi", CV_FOURCC('D','I','V','X'), 30, frame.size(), true);
if( !record.isOpened() ) {
printf("VideoWriter failed to open!\n");
return -1;
}
namedWindow("video",1);
for(;;)
{
// get a new frame from camera
capture >> frame;
// show frame on screen
imshow("video", frame);
// add frame to recorded video
record << frame;
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
// the recorded video will be closed automatically in the VideoWriter destructor
return 0;
} //////
with the source, i changed 2 parts as next
one is for VideoCapture. (i don't have tunercard or camera.)
/////
VideoCapture capture("C:/Users/Public/Videos/Sample Videos/WildlifeTest.wmv"); // open the default camera
/////
and the other is for VideoWriter
VideoWriter record("C:/Users/Public/Videos/Sample Videos/WildlifeRec.wmv",
CV_FOURCC('W','M','V','1'), 30,
frame.size(), true);
//////
and the part of error is
// add frame to recorded video
record << frame;
please show me what is my mistake!
Asked by naleemom on 2011-11-10 15:33:33 UTC
Comments