Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#11 Use libv4l for zbarcam

open
nobody
None
5
2010-12-25
2010-12-06
No

Instead of having two drivers, one for v4l1 and another for v4l2, and both missing support for lots of webcams, use libv4l.

Libv4l is mainained together with upstream drivers. Every time a new webcam is added with some weird proprietary format, a decoder is added at libv4l. Due to that, _all_ V4L webcams are supported via libv4l. Also, it provides backport support to the old V4L1 API.

So, just remove v4l1.c driver and convert v4l2.c driver to use libv4l.
Tested here with several webcams supported by the latest gspca driver found at my upstream tree:
http://git.linuxtv.org/media_tree.git

Discussion

1 2 > >> (Page 1 of 2)
  • spadix
    spadix
    2010-12-10

    • status: open --> pending-rejected
     
  • spadix
    spadix
    2010-12-10

    > remove v4l1.c driver and convert v4l2.c driver

    Sorry, this doesn't make sense to me: we remove existing support and require another external dependency? As far as I understand the approach, we also lose visibility to the native camera formats, resulting in extra conversions or more expensive conversion paths.

    What would make sense is to leverage the v4l conversion library when it's available to provide support for missing conversions... I would certainly be interested in applying a patch that achieved that :)

     
    • status: pending-rejected --> closed-rejected
     
  • This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • The patch doesn't remove existing support, but, instead, it adds support for all cameras supported by the Linux Kernel.
    On my tests with about 15 different cameras, only 3 or 4 worked with the zbar, due to the lack of all those proprietary formats used by most cameras. With libv4l2, all of them worked fine.

    While the patch I sent doesn't use it, libv4l2 returns the flag V4L2_FMT_FLAG_EMULATED for the emulated formats, as an answer for VIDIOC_ENUM_FMT. So, it is possible to add a logic that will decide to use a non-emulated format if Zbar has support for it.

     
    • status: closed-rejected --> open-rejected
     
    • status: open-rejected --> open
     
  • I've enclosed a patch that do the trick with the emulated flags. The second patch should be applied after the one that did the libv4l2 conversion.

    What the patch does is to try first the non-emulated formats. If none are supported, it chooses between the emulated ones.

    I tested here with two cameras. The first one is a Philips SPC230C (pac7302). This camera supports only a proprietary file format (fourcc: PJPG)

    The results with this camera are:

    $ zbarcam --nodisplay -vvvv_zbar_video_open: opened camera device /dev/video0 (fd=5)
    _zbar_v4l2_probe: USB Camera (093a:262c) on usb-0000:00:1d.0-1 driver pac7302 (version 2.11.0)
    _zbar_v4l2_probe: capabilities: CAPTURE READWRITE STREAMING
    ERROR: zbar video in v4l2_reset_crop():
    system error: querying crop support (VIDIOC_CROPCAP): Invalid argument (22)
    v4l2_probe_formats: enumerating supported formats:
    v4l2_probe_formats: [0] RGB3 : RGB3 EMULATED
    v4l2_probe_formats: [1] BGR3 : BGR3 EMULATED
    v4l2_probe_formats: [2] YU12 : YU12 EMULATED
    v4l2_probe_formats: [3] YV12 : YV12 EMULATED
    v4l2_probe_formats: Found 0 formats and 4 emulated formats.
    v4l2_probe_formats: current format: RGB3(33424752) 640 x 480 (line=0x780 size=0xe1000)
    v4l2_probe_formats: setting requested size: 40960 x 30720
    v4l2_probe_formats: final format: RGB3(33424752) 640 x 480 (line=0x780 size=0xe1000)
    _zbar_v4l2_probe: using I/O mode: MMAP
    proc_input_thread: spawned input thread
    _zbar_best_format: from YU12(32315559) to Y800(30303859)=1
    zbar_negotiate_format: YU12(32315559) -> Y800(30303859) (1)
    _zbar_best_format: from YV12(32315659) to Y800(30303859)=1
    zbar_negotiate_format: YV12(32315659) -> Y800(30303859) (1)
    _zbar_best_format: from RGB3(33424752) to Y800(30303859)=112
    zbar_negotiate_format: RGB3(33424752) -> Y800(30303859) (112)
    _zbar_best_format: from BGR3(33524742) to Y800(30303859)=112
    zbar_negotiate_format: BGR3(33524742) -> Y800(30303859) (112)
    zbar_negotiate_format: setting best format YU12(32315559) (1)
    v4l2_set_format: set new format: YU12(32315559) 640 x 480 (0x70800)
    v4l2_v4l2_mmap_buffers: mapping 4 buffers (of 4 requested)
    v4l2_v4l2_mmap_buffers: buf[0] 0x1000000 bytes @0xb2f3b000
    v4l2_v4l2_mmap_buffers: buf[1] 0x1000000 bytes @0xb3f3b000
    v4l2_v4l2_mmap_buffers: buf[2] 0x1000000 bytes @0xb4f3b000
    v4l2_v4l2_mmap_buffers: buf[3] 0x1000000 bytes @0xb5f3b000

    I tested also with an UVC camera that supports YUY format:

    $ zbarcam --nodisplay -vvvv
    _zbar_video_open: opened camera device /dev/video0 (fd=5)
    _zbar_v4l2_probe: Integrated Webcam on usb-0000:00:1a.7-3 driver uvcvideo (version 1.0.0)
    _zbar_v4l2_probe: capabilities: CAPTURE READWRITE STREAMING
    v4l2_reset_crop: crop bounds: 640 x 480 @ (0, 0)
    v4l2_reset_crop: current crop win: 640 x 480 @ (0, 0) aspect 1 / 1
    v4l2_probe_formats: enumerating supported formats:
    v4l2_probe_formats: [0] YUYV : YUV 4:2:2 (YUYV)
    v4l2_probe_formats: [1] RGB3 : RGB3 EMULATED
    v4l2_probe_formats: [2] BGR3 : BGR3 EMULATED
    v4l2_probe_formats: [3] YU12 : YU12 EMULATED
    v4l2_probe_formats: [4] YV12 : YV12 EMULATED
    v4l2_probe_formats: Found 1 formats and 4 emulated formats.
    v4l2_probe_formats: current format: YUYV(56595559) 640 x 480 (line=0x500 size=0x96000)
    _zbar_v4l2_probe: using I/O mode: MMAP
    proc_input_thread: spawned input thread
    _zbar_best_format: from YUYV(56595559) to Y800(30303859)=24
    zbar_negotiate_format: YUYV(56595559) -> Y800(30303859) (24)
    zbar_negotiate_format: setting best format YUYV(56595559) (24)
    v4l2_set_format: set new format: YUYV(56595559) 640 x 480 (0x96000)
    v4l2_v4l2_mmap_buffers: mapping 4 buffers (of 4 requested)
    v4l2_v4l2_mmap_buffers: buf[0] 0x96000 bytes @0xb6e6e000
    v4l2_v4l2_mmap_buffers: buf[1] 0x96000 bytes @0xb6dd8000
    v4l2_v4l2_mmap_buffers: buf[2] 0x96000 bytes @0xb6d42000
    v4l2_v4l2_mmap_buffers: buf[3] 0x96000 bytes @0xb6cac000

     
1 2 > >> (Page 1 of 2)