opencv video capturing and saving using webcam using intel galileo
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
... please stop living under a rock, and use opencv's c++ api.
include "opencv2/opencv.hpp"
include <iostream>
using namespace std; using namespace cv;
int main() { int i=0;
int frame_width= vcap.get(CV_CAP_PROP_FRAME_WIDTH); int frame_height= vcap.get(CV_CAP_PROP_FRAME_HEIGHT); VideoWriter video("out.avi",CV_FOURCC('M','J','P','G'),10, Size(frame_width,frame_height),true);
if(!video.isOpened()) { cout << "Errroooooooorrrrrrr" << endl;
}
while(1){
return 0; }
above is my c++ program it gives me an error as shown below
============================================
root@clanton:/kishan# ./v++ 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 Errroooooooorrrrrrr root@clanton:/kishan# ls
==================================================
Now I came out of the rock.. now you give me solution
try -1 instead of the fourcc, and see if it gives you a list of supported codecs
I have tried it but it is not showing me list of codec
the codec is not installed on your system ... try to figure out which codec packs exist for your system.
how to find which codecs are already installed in my system?
I am looking for a universal way myself. Have been installing codec packs to make it work on windows, on linux no experience in it yet.