hello all,
I am working on intel galileo. Now, I want to capture video from webcam and I want to save it using opencv in my board.
but I am facing error in this task,
my code
#include <highgui.h>
#include "opencv2/highgui/highgui.hpp"
#include <cv.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
{
int i=0,j=0;
CvCapture* capture = cvCaptureFromCAM(0);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 240);
CvSize size = cvSize((int)cvGetCaptureProperty( capture,CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty( capture,CV_CAP_PROP_FRAME_HEIGHT));
IplImage* frame = cvQueryFrame( capture );
CvVideoWriter *writer = cvCreateVideoWriter( "video.avi" ,CV_FOURCC('M','J','P','G'), 10 ,size, 1);
if(!writer)
printf("errorrrrrrrrrrrrrrrrrrrrrr\n");
while(1)
{
frame = cvQueryFrame(capture);
if(!frame) break;
j = cvWriteFrame(writer, frame);
printf("writer = %d\n",j);
if(i==10)
{
cvReleaseCapture(&capture);
break;
}
else
i++;
}
}
I have attached my c code for video capturing and saving using opencv
I have shown output of this this below
================================================================
root@clanton:/# ./video
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
errorrrrrrrrrrrrrrrrrrrrrr
writer = 0
writer = 0
writer = 0
writer = 0
writer = 0
writer = 0
writer = 0
writer = 0
writer = 0
writer = 0
root@clanton:/#
================================================================
here my cvCreateVideoWriter function fails each and every time
I have tried many things but not able to solve this error
please give me some solution
Thanx in advance