View Full Version : OpenCV + ffmpeg hangs at low resolutions and low framerate
virtuald
10-03-2013, 03:34
In case anyone is using OpenCV + ffmpeg to do their image processing, I found a bug in OpenCV that causes ffmpeg to hang for up to 30 seconds or so when trying to connect to the AXIS M1011 camera. I'm surprised the SmartDashboard doesn't run into this problem, since it appears to use ffmpeg underneath the hood for capturing with camera extension widgets (but not for the default camera widget that comes with it).
If you're interested in more details, check out the bug reports at OpenCV (http://code.opencv.org/issues/2877) and FFMpeg (http://ffmpeg.org/trac/ffmpeg/ticket/2343).
Around the start of this year's build season, I contacted Spectrum 3847 about using OpenCV on an onboard Raspberry Pi for vision processing. They replied describing a problem with ffmpeg and OpenCV causing significant lag. It is probably the same issue you found above.
Well, a few months later and here I am. I created a fully working Node.js based OpenCV processing server. I'm using the Axis VAPIX Video Streaming API (which is just MJPG over HTTP) and it's giving me 25 processed target images (640x480) per second. I created node-vapix to implement this and interface with the camera and I'm using node-opencv for OpenCV bindings.
This entire time, I never even had to introduce FFmpeg into my project. So I'm asking, why even use OpenCV's VideoCapture instead of directly providing images?
oculus.js: https://github.com/team178/oculus.js
node-vapix: https://github.com/gluxon/node-vapix
node-opencv: https://github.com/peterbraden/node-opencv
virtuald
11-03-2013, 22:17
This entire time, I never even had to introduce FFmpeg into my project. So I'm asking, why even use OpenCV's VideoCapture instead of directly providing images?
Cool stuff. Of course, I've already put in the effort to fix the problem with FFMpeg (and it is fixed, after changing the source code a bit), so I'll stick with that for now until it bites me again. :)
faust1706
13-03-2013, 04:06
Im so glad to hear 1706 isnt the only team using OpenCV. We use the microsoft kinect though with illuminators (as of this year). Good luck!
billbo911
20-03-2013, 19:39
Cool stuff. Of course, I've already put in the effort to fix the problem with FFMpeg (and it is fixed, after changing the source code a bit), so I'll stick with that for now until it bites me again. :)
I am just starting down the road to learning how to use OpenCV with a webcam through Linux. I HAVE NO CLUE right now what I will be facing. So, can you possibly provide tips on what to look out for, gotcha's to avoid, things that worked and things that didn't? I would hate to reinvent the wheel when the work has already been done.
So, what caused the OpenCV + ffmpeg issues and how did you resolve it?
faust1706
20-03-2013, 19:43
Just make sure whenever you call functions such as cvCreateWindow and cvCreateMemStorage, you get rid of them too at the end.
virtuald
05-04-2013, 11:39
So, what caused the OpenCV + ffmpeg issues and how did you resolve it?
To fix it, you have to add a line to the OpenCV source code and rebuild it. Check out the bug reports referenced above for more information.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.