Page 1 of 1

Receiving a VLC video stream with OpenCV

Posted: 17 Dec 2009 10:15
by alb84
Hi everybody, I posted this question in this section of the forum because I could not figure out which was the most proper section to post it.

My problem is that I have a VLC video stream from a VLC server, and I'd like to receive the stream and do some real time processing with OpenCV.
OpenCV highlevel API can only manage video from files stored on file system or from capture devices but there is no way to manage a VLC video stream.
Which is the best solution you can advise? Possibly the easiest and quickest one.

I looked if it was possible to virtualize a dummy video capture device to use as a VLC client output and as a OpenCV input but I found no solutions.
My next step is to download the VLC source and modify it in order to get the raw RGB data ready to be visualized on the screen and pass it to the OpenCV application.
I already snooped around the source tarball but I did not figure out where I can add the code to get the raw RGB data. I hope you can help me, or maybe you can advise me some other solutions more simple and comfortable.
I've seen there is a libVLC API which seems to be done for these problems but I only found a call to take a snapshot of the current video frame on a file and I found no useful example to do what I need.
Any help / reference / tutorial / sample code is welcome!
Thanks

Re: Receiving a VLC video stream with OpenCV

Posted: 21 Dec 2009 11:10
by nimport nawak
Have a look here :
viewtopic.php?f=32&t=68816

You will have to transform your image in ipl instead of QPixmap but it shouldn't be a big deal

Re: Receiving a VLC video stream with OpenCV

Posted: 28 Dec 2009 18:56
by mohit839
Were you able to do the OpenCV processing as mentioned in your earlier post? I am trying to do something similar - all I have got so far is the QT code from http://forum.qtfr.org/viewtopic.php?pid=65969. They seem to show how to access raw data using vmem.

Please do let me know if you come across something more concrete.

Re: Receiving a VLC video stream with OpenCV

Posted: 11 Feb 2010 12:26
by mighty_scoop
Hi there,

are there any news in this topic ? Does anybody managed to parse a stream/video/image from vlc to opencv ? I would be very grateful for any help.

Greetings

Re: Receiving a VLC video stream with OpenCV

Posted: 24 Feb 2010 10:44
by alb84
i succesfully integrated libVLC and OpenCV, you just need to create an image and then tell libVLC where to write the data...

Code: Select all

// Allocating the space for the structure context = ( struct ctx* )malloc( sizeof( *context ) ); // Allocating the video buffer //context->pixels = ( unsigned char* )malloc( ( sizeof( *( context->pixels ) ) * VIDEO_WIDTH * VIDEO_HEIGHT ) * 4 ); context->img=cvCreateImage(cvSize(VIDEO_WIDTH, VIDEO_HEIGHT), IPL_DEPTH_8U, 4); context->pixels=(unsigned char *)context->img->imageData;
Then call libvlc using the vmem output as shown in the example posted above and available at
http://gitorious.org/vmem-example/vmem- ... ees/master

Re: Receiving a VLC video stream with OpenCV

Posted: 01 Jul 2012 16:20
by pv123
Hii alb84,

Can you please share the code where you integrated libvlc and opencv?

Thanks.