开发者

Grabbing Images from a Webcam to be used with OpenCV

开发者 https://www.devze.com 2023-02-11 07:19 出处:网络
This is a follow up to my previous question, OpenCV PS 3 Eye Can someone sugg开发者_运维知识库est a library that would allow me grab frames from camera without too much fuss (like video videoinput l

This is a follow up to my previous question,

OpenCV PS 3 Eye

Can someone sugg开发者_运维知识库est a library that would allow me grab frames from camera without too much fuss (like video videoinput lib for windows) and pass them to opencv within my application?


I had a parallel problem using a completely different webcam: worked well in cheese/etc, v4l-info showed proper setup, but openCV would fail with:

HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV Unable to stop the stream.: Bad file descriptor

After much flailing I found that at least one guy had similar problems with webcams in various applications.

In blind faith I promptly punched in export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so and «poof» it worked.

The openCV v4l2 interface is not as robust as the v4l implementation and the export is a quick workaround (openCV appears to revert to v4l).

With a quick browse of opencv/modules/highgui/src/cap_v4l.cpp it would appear as though openCV would like to use v4l2.

I'm running Ubuntu Lucid 2.6.32-28-generic x86_64, libv4l-0 v0.6.4-1ubuntu1 with openCV pulled from the HEAD of the repo a few days ago.

In the course of explaining this I've resolved my issue. It turns out that openCV forces the resolution on a v4l2 device to 640x480 by default - and my device had a max 320x240 resolution which caused the fault when testing for the format type in opencv::highgui::cap_v41::try_palette_v4l2. I changed DEFAULT_V4L_WIDTH and, DEFAULT_V4L_HEIGHT.

0

精彩评论

暂无评论...
验证码 换一张
取 消