OpenCV Support

This forum is about all development around libVLC.
zurasi
New Cone
New Cone
Posts: 5
Joined: 05 Aug 2010 02:51

OpenCV Support

Postby zurasi » 05 Aug 2010 03:05

Hi,

I found some posts about the OpenCV support in VLC. So I decided to give it a try.
(After 2 days compiling packages :/) I got a selfbuild VLC-Player with --enable-opencv.
But now i got stuck. What exactly i need to do to use a OpenCV filter.
I found an opencv_example.ccp and an opencv_wrapper.c but both are not compiled while ./compile
Can I compile them now standalone? How do I add them?
How do I run the example?

( Im also new at OpenCV I just found some tutorials and played around )

Thank you
Lucia Zurasi

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: OpenCV Support

Postby ivoire » 05 Aug 2010 13:56

If you add --enable-opencv, opencv_example might be build.
To create a new one just take the example and add the OpenCV code you need in the Filter function. This function will be called for each picture before rendering it on the screen.

zurasi
New Cone
New Cone
Posts: 5
Joined: 05 Aug 2010 02:51

Re: OpenCV Support

Postby zurasi » 05 Aug 2010 15:05

Humm

I use ./configure --enable-opencv --enable-run-as-root
Then i get:

Code: Select all

Enabled modules: a52tofloat32 access_avio access_mmap access_oss atmo avcodec avformat cdda dbus dynamicoverlay fb freetype inhibit libmpeg2 mpgatofixed32 mux_ogg ogg oldhttp oldtelnet opencv_example opencv_wrapper osd_parser osdmenu oss png postproc qt4 remoteosd screensaver skins2 stream_out_raop svg swscale telepathy telx theora unzip v4l2 vcd visual vorbis xcb_apps xcb_glx xcb_screen xcb_window xcb_x11 xcb_xv xdg_screensaver xml zip
So I think the configuration accepted the opencv

After ./compile i got this warnings:

Code: Select all

debian3:~/vlc/vlc-1.1.2# ./compile | grep -i opencv --color WARNING : input.c: 61: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : decoder.c: 145: ignoring return value of 'write', declared with attribute warn_unused_result WARNING : intf.c: 232: ignoring return value of 'asprintf', declared with attribute warn_unused_result WARNING : intf.c: 242: ignoring return value of 'asprintf', declared with attribute warn_unused_result WARNING : intf.c: 247: ignoring return value of 'asprintf', declared with attribute warn_unused_result WARNING : intf.c: 254: ignoring return value of 'asprintf', declared with attribute warn_unused_result WARNING : intf.c: 259: ignoring return value of 'asprintf', declared with attribute warn_unused_result WARNING : intf.c: 270: ignoring return value of 'asprintf', declared with attribute warn_unused_result WARNING : demux.c: 75: unused variable 'i_seek' WARNING : libs/net.c: 201: variable 'i_fds' might be clobbered by 'longjmp' or 'vfork' WARNING : libs/objects.c: 148: 'vlc_object_find' is deprecated (declared at ../../../include/vlc_objects.h:74) WARNING : libs/objects.c: 177: 'vlc_object_find_name' is deprecated (declared at ../../../include/vlc_objects.h:78) WARNING : libs/osd.c: 132: 'vlc_object_find' is deprecated (declared at ../../../include/vlc_objects.h:74) WARNING : libs/osd.c: 147: 'vlc_object_find' is deprecated (declared at ../../../include/vlc_objects.h:74) WARNING : libs/playlist.c:289: 2: #warning Indexing input items by ID is unsafe, WARNING : freetype.c: 388: pointer targets in passing argument 3 of 'FcPatternAddString' differ in signedness WARNING : freetype.c: 389: pointer targets in passing argument 3 of 'FcPatternAddString' differ in signedness WARNING : freetype.c: 409: passing argument 4 of 'FcPatternGetString' from incompatible pointer type WARNING : freetype.c: 350: unused variable 't2' WARNING : freetype.c: 544: 'vlc_object_find' is deprecated (declared at ../../include/vlc_objects.h:74) WARNING : inhibit/xdg.c: 112: variable 'suspended' might be clobbered by 'longjmp' or 'vfork' WARNING : rtsp.c:1048: 2: #warning Should use secure randomness here! (spoofing risk) WARNING : rtsp.c:1388: 2: #warning Session ID should be securely random (spoofing risk) WARNING : mediadirs.c: 258: unused parameter 'p_this' WARNING : atmo/atmo.cpp: 2416: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : atmo/FnordlichtConnection.cpp: 342: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : /usr/include/opencv/cxtypes.h:45: 42: "_MSC_VER" is not defined WARNING : /usr/include/opencv/cvcompat.h: 383: unused parameter 'bound_rect' WARNING : /usr/include/opencv/cvcompat.h: 545: unused parameter 'method' WARNING : /usr/include/opencv/cvcompat.h: 576: unused parameter 'thresharr' WARNING : /usr/include/opencv/cvcompat.h: 577: unused parameter 'storage' WARNING : /usr/include/opencv/cvcompat.h: 641: unused parameter 'image_size' WARNING : /usr/include/opencv/cvcompat.h: 666: unused parameter 'image_size' WARNING : /usr/include/opencv/cvcompat.h: 760: unused parameter 'interpolate' WARNING : /usr/include/opencv/cvcompat.h: 770: unused parameter 'src' WARNING : /usr/include/opencv/cvcompat.h: 773: unused parameter 'interpolate' WARNING : /usr/include/opencv/cvcompat.h: 788: unused parameter 'interpolate' WARNING : opencv_example.c: 219: assignment discards qualifiers from pointer target type WARNING : /usr/include/opencv/cxtypes.h:45: 42: "_MSC_VER" is not defined WARNING : /usr/include/opencv/cvcompat.h: 383: unused parameter 'bound_rect' In file included from /usr/include/opencv/cxcore.h:69, from opencv_example.c:41: In file included from /usr/include/opencv/cv.h:1205, from opencv_example.c:42: /usr/include/opencv/cvcompat.h: In function 'cvConvexHull': /usr/include/opencv/cvcompat.h: In function 'cvFindFundamentalMatrix': /usr/include/opencv/cvcompat.h: In function 'cvFindChessBoardCornerGuesses': /usr/include/opencv/cvcompat.h: In function 'cvFindExtrinsicCameraParams': /usr/include/opencv/cvcompat.h: In function 'cvFindExtrinsicCameraParams_64d': /usr/include/opencv/cvcompat.h: In function 'cvUnDistortOnce': /usr/include/opencv/cvcompat.h: In function 'cvUnDistortInit': /usr/include/opencv/cvcompat.h: In function 'cvUnDistort': opencv_example.c: In function 'Filter': In file included from /usr/include/opencv/cxcore.h:69, from opencv_wrapper.c:44: In file included from /usr/include/opencv/cv.h:1205, from opencv_wrapper.c:45: /usr/include/opencv/cvcompat.h: In function 'cvConvexHull': WARNING : /usr/include/opencv/cvcompat.h: 545: unused parameter 'method' WARNING : /usr/include/opencv/cvcompat.h: 576: unused parameter 'thresharr' WARNING : /usr/include/opencv/cvcompat.h: 577: unused parameter 'storage' WARNING : /usr/include/opencv/cvcompat.h: 641: unused parameter 'image_size' WARNING : /usr/include/opencv/cvcompat.h: 666: unused parameter 'image_size' WARNING : /usr/include/opencv/cvcompat.h: 760: unused parameter 'interpolate' WARNING : /usr/include/opencv/cvcompat.h: 770: unused parameter 'src' WARNING : /usr/include/opencv/cvcompat.h: 773: unused parameter 'interpolate' WARNING : /usr/include/opencv/cvcompat.h: 788: unused parameter 'interpolate' WARNING : opencv_wrapper.c: 541: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : osdmenu.c: 256: 'vlc_object_find' is deprecated (declared at ../../include/vlc_objects.h:74) WARNING : osdmenu.c: 643: unused parameter 'psz_var' WARNING : remoteosd.c: 311: 'vlc_object_find' is deprecated (declared at ../../include/vlc_objects.h:74) WARNING : swscale.c: 557: passing argument 2 of 'sws_scale' from incompatible pointer type WARNING : colorthres.c: 287: 'i_v_offset' may be used uninitialized in this function WARNING : colorthres.c: 287: 'i_u_offset' may be used uninitialized in this function WARNING : crop.c: 511: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : deinterlace.c: 567: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : deinterlace.c: 585: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : puzzle.c: 445: comparison between signed and unsigned WARNING : transform.c: 311: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : wrapper.c: 420: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : xcb/xvideo.c: 625: comparison between signed and unsigned WARNING : xcb/xvideo.c: 628: comparison between signed and unsigned WARNING : xcb/xvideo.c: 638: comparison between signed and unsigned WARNING : visual.c: 344: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : udp.c: 410: variable 'i_to_send' might be clobbered by 'longjmp' or 'vfork' WARNING : udp.c: 411: variable 'i_dropped_packets' might be clobbered by 'longjmp' or 'vfork' WARNING : pes.c: 359: comparison between signed and unsigned WARNING : pes.c: 368: comparison between signed and unsigned WARNING : ../demux/xiph.h: 51: comparison between signed and unsigned WARNING : asf.c: 194: unused variable 'i' WARNING : video.c:91: 2: #warning THERE IS DEFINITELY A BUG! LOCKING IS INSUFFICIENT! WARNING : video.c: 80: call to 'harmful_delay' declared with attribute warning: use proper event handling instead of short delay WARNING : description.c: 109: 'vlc_object_find' is deprecated (declared at ../../include/vlc_objects.h:74) WARNING : description.c: 149: 'vlc_object_find' is deprecated (declared at ../../include/vlc_objects.h:74) WARNING : display.c: 161: 'vlc_object_find' is deprecated (declared at ../../include/vlc_objects.h:74) WARNING : rtp.c: 1610: variable 'out' might be clobbered by 'longjmp' or 'vfork' /usr/include/opencv/cvcompat.h: In function 'cvFindFundamentalMatrix': /usr/include/opencv/cvcompat.h: In function 'cvFindChessBoardCornerGuesses': /usr/include/opencv/cvcompat.h: In function 'cvFindExtrinsicCameraParams': /usr/include/opencv/cvcompat.h: In function 'cvFindExtrinsicCameraParams_64d': /usr/include/opencv/cvcompat.h: In function 'cvUnDistortOnce': /usr/include/opencv/cvcompat.h: In function 'cvUnDistortInit': /usr/include/opencv/cvcompat.h: In function 'cvUnDistort': opencv_wrapper.c: In function 'Render':
So i searched for compiled stuff

Code: Select all

debian3:~/vlc/vlc-1.1.2# find . | grep -i opencv ./modules/video_filter/libopencv_example_plugin_la-opencv_example.lo ./modules/video_filter/libopencv_example_plugin.la ./modules/video_filter/opencv_example.c ./modules/video_filter/libopencv_wrapper_plugin_la-opencv_wrapper.lo ./modules/video_filter/.libs/libopencv_wrapper_plugin_la-opencv_wrapper.o ./modules/video_filter/.libs/libopencv_example_plugin.so ./modules/video_filter/.libs/libopencv_wrapper_plugin.lai ./modules/video_filter/.libs/libopencv_example_plugin.la ./modules/video_filter/.libs/libopencv_example_plugin_la-opencv_example.o ./modules/video_filter/.libs/libopencv_example_plugin.lai ./modules/video_filter/.libs/libopencv_wrapper_plugin.so ./modules/video_filter/.libs/libopencv_wrapper_plugin.la ./modules/video_filter/.deps/libopencv_wrapper_plugin_la-opencv_wrapper.Plo ./modules/video_filter/.deps/libopencv_example_plugin_la-opencv_example.Plo ./modules/video_filter/opencv_wrapper.c ./modules/video_filter/libopencv_wrapper_plugin.la
It seams they are compiled.

But how can I use the example?
I started the new VLCplayer but I cant find some options.

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: OpenCV Support

Postby ivoire » 05 Aug 2010 15:47

--video-filter opencv_example ?

zurasi
New Cone
New Cone
Posts: 5
Joined: 05 Aug 2010 02:51

Re: OpenCV Support

Postby zurasi » 05 Aug 2010 16:08

Hello,

thx @ivoire that argument i missed.
But sadly

Code: Select all

debian3:~# vlc --video-filter=opencv_example http://10.14.0.2:8080 VLC media player 1.1.2 The Luggage (revision exported) Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS") Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE") Warning: call to signal(13, 0x1) [0x80ca334] main interface error: no suitable interface module [0x804c564] main libvlc error: interface "globalhotkeys,none" initialization failed [0x804c564] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. Blocked: call to setlocale(6, "") Blocked: call to setlocale(1, "C") Blocked: call to sigaction(17, 0xb5dac0a4, 0xb5dac130) Blocked: call to putenv("DESKTOP_STARTUP_ID=") [0x80d3314] main playlist: stopping playback [0x81bc814] access_mms access: selecting stream[0x1] audio (63 Kib/s) [0x81bc814] access_mms access: selecting stream[0x2] video (475 Kib/s) [0x81bc814] access_mms access: connection successful [0x82e2134] xcb_xv generic error: no available XVideo adaptor [swscaler @ 0x82ea5a0] No accelerated colorspace conversion found from yuv420p to bgr565le. [0x82e3014] oss audio output error: cannot open audio device (/dev/dsp) [0x8246284] main video output error: Failed to create video filter2 'opencv_example' [0x8246284] main video output error: Failed while trying to append 'opencv_example' to filter chain [0x8246284] main video output error: Video filter chain creation failed [0x8246284] main video output error: Failed to create video filter2 'opencv_example' [0x8246284] main video output error: Failed while trying to append 'opencv_example' to filter chain [0x8246284] main video output error: Video filter chain creation failed
I already cheked the video_filter dir and cant find the filters, so i copyed them into.

cp /root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv* /usr/local/lib/vlc/plugins/video_filter/

Code: Select all

`/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_example_plugin.la' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_example_plugin.la' `/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_example_plugin.lai' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_example_plugin.lai' `/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_example_plugin.so' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_example_plugin.so' `/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_example_plugin_la-opencv_example.o' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_example_plugin_la-opencv_example.o' `/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_wrapper_plugin.la' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_wrapper_plugin.la' `/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_wrapper_plugin.lai' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_wrapper_plugin.lai' `/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_wrapper_plugin.so' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_wrapper_plugin.so' `/root/vlc/vlc-1.1.2/modules/video_filter/.libs/libopencv_wrapper_plugin_la-opencv_wrapper.o' -> `/usr/local/lib/vlc/plugins/video_filter/libopencv_wrapper_plugin_la-opencv_wrapper.o'
Is there anything else i need to do?

zurasi
New Cone
New Cone
Posts: 5
Joined: 05 Aug 2010 02:51

Re: OpenCV Support

Postby zurasi » 05 Aug 2010 21:27

I also found some settings in the advanced options, but everytime i get:

Code: Select all

[0x887e5ac] main video output error: Failed to create video filter2 'opencv_wrapper' [0x887e5ac] main video output error: Failed while trying to append 'opencv_wrapper' to filter chain [0x887e5ac] main video output error: Video filter chain creation failed [0x887e5ac] main video output error: Failed to create video filter2 'opencv_wrapper' [0x887e5ac] main video output error: Failed while trying to append 'opencv_wrapper' to filter chain [0x887e5ac] main video output error: Video filter chain creation failed
And why vlc try to load the filter twice? also very strange...

Please help :(
Lucia Zurasi

zurasi
New Cone
New Cone
Posts: 5
Joined: 05 Aug 2010 02:51

Re: OpenCV Support

Postby zurasi » 10 Aug 2010 13:05

*push*

No Ideas?

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: OpenCV Support

Postby ivoire » 12 Aug 2010 13:56

You can add some code on the opencv_example Open function to see what the problem is.

sriney
New Cone
New Cone
Posts: 3
Joined: 12 Feb 2011 05:54

Re: OpenCV Support

Postby sriney » 14 Feb 2011 19:50

Hi,

Hoping to catch someones attention on this.

I'm trying to run the opencv_example, which from what I understand, inherits from the opencv_wrapper somehow (or, wrapper contains the example, and is configured to load it).

Anyone familiar with this?

I'm using OpenCV-2.2 and vlc-1.1.7. I'm configuring and compiling on Ubuntu 10.10.

I modified opencv_example slightly (changed path to cascade file to appropriate location for linux, and added an argument to cvHaarDetectObjects to get it to compile [minimum square for face identification, cvSize(0,0)].

I modified opencv_wrapper, changing the set_capability and set_subcategory to video_filter2 in the vlc_module_begin block.

when i run the following:

/home/sriney/vlc-1.1.7/vlc --reset-plugins-cache --video-filter=opencv_wrapper v4l2:///dev/video1

I get a segfault

when i run the following:

/home/sriney/vlc-1.1.7/vlc --reset-plugins-cache --video-filter=opencv_example v4l2:///dev/video1

Failed to create video filter2 'opencv_example'

even though the opencv_example is a SUBCAT_VIDEO_VFILTER2

Can anyone say if I'm attempting to execute these cascading filters from the command line properly or not, and whether there are other upgrade issues to consider in the code going to 1.1.7 and vfilter2?

My next exercise is stepping through the debugger. Anyone set up vlc to compile through Eclipse?

Thanks,

Seth

sriney
New Cone
New Cone
Posts: 3
Joined: 12 Feb 2011 05:54

Re: OpenCV Support

Postby sriney » 15 Feb 2011 14:11

Hi all,

I wanted to add some more information. I read through the code, and I now understand the inheritance/dependence works with the opencv_wrapper and opencv_example.

The filter should be initiated on a stream from the command line as such:

vlc --reset-plugins-cache --video-filter=opencv_wrapper --opencv-filter-name=opencv_example --opencv-verbosity=debug v4l2:///dev/video1

It makes it to the Create function of opencv_wrapper where it returns, but then Segfaults.

I'm going to try to hook up in the debugger in Eclipse.

Seth

sriney
New Cone
New Cone
Posts: 3
Joined: 12 Feb 2011 05:54

Re: OpenCV Support

Postby sriney » 16 Feb 2011 00:01

Hi All,

I abandoned opencv_wrapper. It seems it was using the old video_filter api (with Render). I trying to hook opencv_example up directly. I read on another post (from 2007) that opencv in vlc hadn't worked in some time. I'm going to try to resurrect it. Any help in converting picture_t to IplImage for processing in OpenCV would be helpful.

thanks,

Seth

biga
Blank Cone
Blank Cone
Posts: 21
Joined: 11 May 2011 10:31

Re: OpenCV Support

Postby biga » 19 May 2011 23:43

Have you found any solution to your problem. I am also trying to make opencv work, but I always get segfaults.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 9 guests