什么是正确的设备/相机名称/格式应该传递给 ZBar/ZBarSharp 库,[无效请求:找不到视频设备]

问题描述

我尝试使用 ZBarSharp 库来检测来自相机的 QRCode 但是当我传递相机名称时,我收到一条错误消息

invalid request: video device not found

这是代码


public void Load(){
            // https://stackoverflow.com/a/26159982/12920956
            var devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);    
            
            var video = new Video();

            // the problem here,what is the device name ?!
            video.Open(devices[1].Name.ToString());
            // Or video.Open(devices[1].ClassID.ToString());
}

我认为问题出在 C# Wrapper 中,但我从 Here

下载了二进制文件

并执行

zbarcam.exe "USB2.0_Camera"

我得到了

ERROR: zbar processor in _zbar_video_open():
    invalid request: video device not found 'USB2.0_Camera'

我试图传递一个类似于帮助中出现的设备名称

λ zbarcam --help
usage: zbarcam [options] [/dev/video?]

scan and decode bar codes from a video stream

options:
    -h,--help      display this help text
    --version       display version information and exit
    -q,--quiet     disable beep when symbol is decoded
    -v,--verbose   increase debug output level
    --verbose=N     set specific debug output level
    --xml           use XML output format
    --raw           output decoded symbol data without symbology prefix
    --nodisplay     disable video display window
    --prescale=<W>x<H>
                    request alternate video image size from driver
    -S<CONfig>[=<VALUE>],--set <CONfig>[=<VALUE>]
                    set decoder/scanner <CONfig> to <VALUE> (or 1)

但是当我执行 zbarcam --verbose=32

运行应用程序并获取更多详细信息 ,我得到了

select camera window

所以,注意 USB2.0_Camera 是否在列表中? 当我选择它并按 OK 时一切正常, 我得到

_zbar_video_open:     [0] Microsoft WDM Image Capture (Win32) - Version:  10.0.19041.1
vfw_capture_thread: spawned vfw capture thread (thr=5630)
_zbar_video_open: opened camera: Microsoft WDM Image Capture (Win32) (0) (thr=5530)
vfw_probe: initial format: 640x480 @16bpp (96000) cmp=YUY2(32595559) res=0x0 clr=0/0 (28) (bisz=28)
vfw_probe: probing supported formats:
vfw_probe_format:     trying I420(30323449)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying YV12(32315659)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying NV12(3231564e)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying UYVY(59565955)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying YUY2(32595559)...
vfw_probe_format:       actual: 640x480 @16bpp (96000) cmp=YUY2(32595559) res=0x0 clr=0/0 (28)
vfw_probe_format:       yes
vfw_probe_format:     trying BGR3(33524742)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying BGR4(34524742)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying YVU9(39555659)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying GREY(59455247)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying Y800(30303859)...
vfw_probe_format:       no (set fails)
vfw_probe_format:     trying JPEG(4745504a)...
vfw_probe_format:       no (set fails)
WARNING: zbar video in zbar_video_get_fd():
    unsupported request: video driver does not support polling
proc_video_thread: spawned video thread
proc_input_thread: spawned input thread
_zbar_best_format: from YUY2(32595559) to BGR3(33524742)=144 BGR4(34524742)=144 JPEG(4745504a)=-1
zbar_negotiate_format: YUY2(32595559) -> BGR3(33524742) (144)
zbar_negotiate_format: setting best format YUY2(32595559) (144)
vfw_set_format: seting format: YUY2(32595559) 640x480 @16bpp (96000) cmp=YUY2(32595559) res=0x0 clr=0/0 (28)
vfw_set_format: set new format: YUY2(32595559) 640x480 @16bpp (96000) cmp=YUY2(32595559) res=0x0 clr=0/0 (28)
vfw_init: initialized video capture: 4 buffers 33333ms/frame
win_handle_event: WM_SIZE 640x480
_zbar_window_resize: 640x480 scale=13
_zbar_process_image: processing: YUY2(32595559) 640x480 @06860008
_zbar_best_format: from YUY2(32595559) to BGR3(33524742)=144 BGR4(34524742)=144 JPEG(4745504a)=-1
zbar_window_redraw: init: src=YUY2(32595559) 0x0 dst=BGR3(33524742) 0x0
_zbar_window_bih_init: biCompression=0 biBitCount=24
zbar_window_redraw: scale: src=640x480 win=640x480 by 480/480 => 640x480 @0,0
_zbar_process_image: processing: YUY2(32595559) 640x480 @06900008

并且二维码检测有效。

但是设备名称是什么,

我试图更多地研究代码 Here,但我在 Windows 上构建此代码时遇到问题 所以调试它来找出设备名称的来源非常复杂

所以,简而言之,我只想知道我应该传递的相机名称的正确格式以使其在 CSharp二进制文件

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...