I'm trying to use OpenCV library on pandaboard ubuntu 12.04.
So I installed Opencv2.4.2 version and the code is beneath.
#include <stdio.h>
#include <stdlib.h>
#include "opencv2/opencv.hpp"
int main*int argc, char** argv)
{
cvNamedWindow("origin", CV_WINDOW_AUTOSIZE);
CvCapture *capture = cvCaptureFromAVI("hkleecv-desktop:/home/hkleecv/OpenCV-2.4.2/samples/cpp/captured.avi");
IplImage *frameOrigin;
if(!capture0 return 1;
int key = 0;
int fps = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
while(key != 'q')
{
frameOrigin = cvQueryFrame(capture);
cvShowImage("origin", frameOrigin);
key = cvWaitKey(1000/fps);
}
cvReleaseCapture(&capture);
cvDestroyWindow("origin");
}
The problem is this program can't grab frames from the avi file. (this code worked well on VS2010 C++)
when I run the program on the shell with gdb, it just return message "Inferior 1 (process nnnn) exited with code 01"
I googled about this error and found a page posted by someone who had similar problem as me, but cvCaptureFromAVI() isn't working currently.
can someone tell me what can I do from here to make cvaptureFromAVI() work?
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main()
{
cvNamedWindow("origin", CV_WINDOW_AUTOSIZE);
CvCapture *capture = cvCaptureFromAVI("C:\\j.avi");
IplImage *frameOrigin;
if(capture==NULL) {
return -1;
cout<<"VIDEO NOT READ"<<endl;
}
int key = 0;
int fps = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
while(key != 'q')
{
frameOrigin = cvQueryFrame(capture);
if(frameOrigin == NULL)
break;
cvShowImage("origin", frameOrigin);
key = cvWaitKey(1000/fps);
}
cvReleaseCapture(&capture);
cvDestroyWindow("origin");
return 0;
}
try the above code...it works for me on windows platform...put the avi fie address correctly..