[ros-users] cvCaptureFromAVI returns NULL
beepbeep
mvharish14988 at gmail.com
Mon Sep 13 21:24:43 UTC 2010
Hello,
I've been trying to get the following code working. It's a standard code to
read AVI files from here:
http://nashruddin.com/How_to_Play_AVI_Files_with_OpenCV
Eventually, I want to send this to a camera display in Rviz.
#include <ros/ros.h>
#include "sensor_msgs/Image.h"
#include "image_transport/image_transport.h"
#include "cv_bridge/CvBridge.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
int main( int argc, char** argv )
{
IplImage *frame;
int key;
//assert( argc == 2 );
CvCapture *capture =
cvCaptureFromAVI("/home/harish/Desktop/movie.avi");
printf("Hello1");
if( !capture )
{
printf("Hello2");
return 1;
}
int fps = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FPS );
cvNamedWindow( "video", 0 );
while( key != 'q' ) {
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "video", frame );
key = cvWaitKey( 1000 / fps );
}
cvReleaseCapture( &capture );
cvDestroyWindow( "video" );
return 0;
}
For some reason, cvCaptureFromAVI returns NULL, because Hello2 is printed in
the output.
The file movie.avi is stored in the bin folder, src folder, and package
folder as well. I've also tried an absolute path to my Desktop.
The interesting thing is that the code executes perfectly if compiled using
g++ in the regular way, independent of ROS. But using rosmake, or just make,
something happens, and cvCaptureFromAVI returns NULL during execution.
Any ideas? According to a friend, possibly something to do with rosmake or
the makefiles is creating trouble..
Thanks.
--
View this message in context: http://ros-users.122217.n3.nabble.com/cvCaptureFromAVI-returns-NULL-tp1468798p1468798.html
Sent from the ROS-Users mailing list archive at Nabble.com.
More information about the ros-users
mailing list