Problem with the class VideoWriter
Posted: 12 March 2012 06:57 AM   [ Ignore ]
Rank
Joined  2012-03-06
Total Posts:  1
New Member

Hello people!

I’m newbie starting to use OpenCV on ubuntu 10.4. I’m trying to capture video from camera and to write that video on an avi file, the code is the next:

#include "opencv2/opencv.hpp"
#include <iostream>
#include <vector>
#include <stdio.h>
#include <opencv2/highgui/highgui.hpp> 

using namespace cv;

int main(intchar**)
{
    VideoCapture cap
(0); // open the default camera
    
if(!cap.isOpened())  // check if we succeeded
        
return -1;
    
    
namedWindow("cam1",CV_WINDOW_AUTOSIZE);
    
Mat frame;
    
    
VideoWriter outputVideo("lalala.avi"CV_FOURCC('D','I','V','X') , 30Size(720480) , true); // or frame.size()
    
outputVideo.open("lalala.avi"CV_FOURCC('D','I','V','X') ,  30Size(720480), true) ;    // or frame.size()  
    
    
if( !outputVideo.isOpened() ) {
      printf
("VideoWriter failed to open!\n"); 
    
}
      
    
for(;;)
    
{       
      cap 
>> frame// get a new frame from camera                          
      
      
imshow("cam1"frame);
      
      
outputVideo.write(frame);    // or outputVideo << frame;

      
if(waitKey(30) >= 0) break;
    
}
    
    
return 0;
}

My problem is that I can’t open the class VideoWriter but I get the frame well from the camera, any idea of why the program don’t initialize the class VideoWriter?

Profile