[ros-users] cvCaptureFromAVI returns NULL

James Bowman jamesb at willowgarage.com
Mon Sep 13 21:34:16 UTC 2010


Hi,

yes, the ROS version of OpenCV (in package opencv2) builds without video
support - we do this to avoid cross-platform build problems.
And you can do as Dejan suggests and turn on FFMPEG in opencv2's Makefile.

Alternatively, you can just extract images to a directory:

ffmpeg -i /home/harish/Desktop/movie.avi '%04.jpg'

and use a cvLoadImage to play them back into ROS.

J.

On Mon, Sep 13, 2010 at 2:30 PM, Dejan Pangercic
<dejan.pangercic at gmail.com>wrote:

> Hi beepbeep:-),
>
> are you using openCV from ROS? In my case I had to enable "-D
> WITH_FFMPEG=ON" in pkg's Makefile and recompile.
>
> cheers,d.
>
> On Mon, Sep 13, 2010 at 11:24 PM, beepbeep <mvharish14988 at gmail.com>
> wrote:
> >
> > 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.
> > _______________________________________________
> > ros-users mailing list
> > ros-users at code.ros.org
> > https://code.ros.org/mailman/listinfo/ros-users
> >
>
>
>
> --
> MSc. Dejan Pangercic
> PhD Student/Researcher
> Intelligent Autonomous Systems Group
> Technische Universität München
> Telephone: +49 (89) 289-26908
> E-Mail: dejan.pangercic at cs.tum.edu
> WWW: http://ias.cs.tum.edu/people/pangercic
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>



-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100913/265bcfd5/attachment-0003.html>


More information about the ros-users mailing list