rk3399pro Debian10接UVC摄像头
rk3399pro Debian10上接一个UVC摄像头,会出现两个挂载点,如下图:
通过v4l2-ctl命令查看:
v4l2-ctl --list-devices
如上图,出现两个挂载点,并且前面video0-9已经被分配了,怀疑是开发板sdk中驱动已经默认强制分配了一些。
说明:上面是用v4l2-ctl命令查看的,如果提示没有该命令,可以通过下面的命令安装:
sudo apt-get install v4l-utils
因为这两个挂载点,并且是10和11,所以当用capture = cv.VideoCapture(index)就出现了问题,提示如下:
VIDEOIO ERROR: V4L: index 10 is not correct!
换成11也是一样的报错,我们来看一下,这两个挂载点的详细信息:
root@rockchip-evb:/userdata/zl/rknn_test# udevadm info --attribute-walk --name=/dev/video10
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3/3-1/3-1:1.0/video4linux/video10':
KERNEL=="video10"
SUBSYSTEM=="video4linux"
DRIVER==""
ATTR{dev_debug}=="0"
ATTR{index}=="0"
ATTR{name}=="FULL HD webcam"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3/3-1/3-1:1.0':
KERNELS=="3-1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="uvcvideo"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="0e"
ATTRS{iad_bFunctionSubClass}=="03"
ATTRS{iad_bFunctionProtocol}=="00"
ATTRS{bInterfaceSubClass}=="01"
ATTRS{supports_autosuspend}=="1"
ATTRS{authorized}=="1"
ATTRS{bNumEndpoints}=="01"
ATTRS{iad_bFunctionClass}=="0e"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{interface}=="FULL HD webcam"
ATTRS{bInterfaceNumber}=="00"
ATTRS{iad_bInterfaceCount}=="02"
ATTRS{iad_bFirstInterface}=="00"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3/3-1':
KERNELS=="3-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="ef"
ATTRS{devnum}=="5"
ATTRS{quirks}=="0x0"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 4"
ATTRS{bMaxPower}=="500mA"
ATTRS{removable}=="unknown"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{idProduct}=="2283"
ATTRS{maxchild}=="0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="12900"
ATTRS{manufacturer}=="AONI ELECTRONIC CO.LTD"
ATTRS{ltm_capable}=="no"
ATTRS{configuration}==""
ATTRS{bmAttributes}=="80"
ATTRS{idVendor}=="1bcf"
ATTRS{bDeviceSubClass}=="02"
ATTRS{busnum}=="3"
ATTRS{bcdDevice}=="0005"
ATTRS{devpath}=="1"
ATTRS{authorized}=="1"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{product}=="FULL HD webcam"
ATTRS{speed}=="480"
ATTRS{serial}=="20200523001"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3':
KERNELS=="usb3"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{urbnum}=="210"
ATTRS{authorized}=="1"
ATTRS{devpath}=="0"
ATTRS{bDeviceProtocol}=="01"
ATTRS{idProduct}=="0002"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bNumConfigurations}=="1"
ATTRS{serial}=="xhci-hcd.12.auto"
ATTRS{product}=="xHCI Host Controller"
ATTRS{bDeviceClass}=="09"
ATTRS{maxchild}=="1"
ATTRS{idVendor}=="1d6b"
ATTRS{interface_authorized_default}=="1"
ATTRS{bMaxPower}=="0mA"
ATTRS{configuration}==""
ATTRS{version}==" 2.00"
ATTRS{bcdDevice}=="0404"
ATTRS{busnum}=="3"
ATTRS{quirks}=="0x0"
ATTRS{bDeviceSubClass}=="00"
ATTRS{authorized_default}=="1"
ATTRS{ltm_capable}=="no"
ATTRS{bConfigurationValue}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{removable}=="unknown"
ATTRS{speed}=="480"
ATTRS{manufacturer}=="Linux 4.4.194 xhci-hcd"
ATTRS{devnum}=="1"
ATTRS{bmAttributes}=="e0"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto':
KERNELS=="xhci-hcd.12.auto"
SUBSYSTEMS=="platform"
DRIVERS=="xhci-hcd"
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform/usb1/fe900000.dwc3':
KERNELS=="fe900000.dwc3"
SUBSYSTEMS=="platform"
DRIVERS=="dwc3"
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="platform"
DRIVERS=="rockchip-dwc3"
ATTRS{driver_override}=="(null)"
ATTRS{dwc3_mode}=="host"
looking at parent device '/devices/platform':
KERNELS=="platform"
SUBSYSTEMS==""
DRIVERS==""
root@rockchip-evb:/userdata/zl/rknn_test#
以及:
root@rockchip-evb:/userdata/zl/rknn_test# udevadm info --attribute-walk --name=/dev/video11
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3/3-1/3-1:1.0/video4linux/video11':
KERNEL=="video11"
SUBSYSTEM=="video4linux"
DRIVER==""
ATTR{dev_debug}=="0"
ATTR{name}=="FULL HD webcam"
ATTR{index}=="1"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3/3-1/3-1:1.0':
KERNELS=="3-1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="uvcvideo"
ATTRS{supports_autosuspend}=="1"
ATTRS{iad_bFunctionSubClass}=="03"
ATTRS{bInterfaceSubClass}=="01"
ATTRS{bInterfaceClass}=="0e"
ATTRS{iad_bFunctionClass}=="0e"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{interface}=="FULL HD webcam"
ATTRS{authorized}=="1"
ATTRS{bNumEndpoints}=="01"
ATTRS{iad_bFirstInterface}=="00"
ATTRS{bAlternateSetting}==" 0"
ATTRS{iad_bInterfaceCount}=="02"
ATTRS{iad_bFunctionProtocol}=="00"
ATTRS{bInterfaceNumber}=="00"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3/3-1':
KERNELS=="3-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{quirks}=="0x0"
ATTRS{urbnum}=="12900"
ATTRS{devnum}=="5"
ATTRS{manufacturer}=="AONI ELECTRONIC CO.LTD"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bDeviceClass}=="ef"
ATTRS{version}==" 2.00"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{idProduct}=="2283"
ATTRS{product}=="FULL HD webcam"
ATTRS{authorized}=="1"
ATTRS{bMaxPower}=="500mA"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="3"
ATTRS{bDeviceSubClass}=="02"
ATTRS{devpath}=="1"
ATTRS{bConfigurationValue}=="1"
ATTRS{ltm_capable}=="no"
ATTRS{configuration}==""
ATTRS{idVendor}=="1bcf"
ATTRS{bNumConfigurations}=="1"
ATTRS{serial}=="20200523001"
ATTRS{bNumInterfaces}==" 4"
ATTRS{removable}=="unknown"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="0005"
ATTRS{speed}=="480"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto/usb3':
KERNELS=="usb3"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bMaxPower}=="0mA"
ATTRS{bDeviceClass}=="09"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bConfigurationValue}=="1"
ATTRS{idProduct}=="0002"
ATTRS{maxchild}=="1"
ATTRS{authorized_default}=="1"
ATTRS{product}=="xHCI Host Controller"
ATTRS{devnum}=="1"
ATTRS{interface_authorized_default}=="1"
ATTRS{configuration}==""
ATTRS{authorized}=="1"
ATTRS{bNumConfigurations}=="1"
ATTRS{ltm_capable}=="no"
ATTRS{speed}=="480"
ATTRS{idVendor}=="1d6b"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bmAttributes}=="e0"
ATTRS{version}==" 2.00"
ATTRS{manufacturer}=="Linux 4.4.194 xhci-hcd"
ATTRS{removable}=="unknown"
ATTRS{busnum}=="3"
ATTRS{bcdDevice}=="0404"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bDeviceProtocol}=="01"
ATTRS{serial}=="xhci-hcd.12.auto"
ATTRS{quirks}=="0x0"
ATTRS{devpath}=="0"
ATTRS{urbnum}=="210"
looking at parent device '/devices/platform/usb1/fe900000.dwc3/xhci-hcd.12.auto':
KERNELS=="xhci-hcd.12.auto"
SUBSYSTEMS=="platform"
DRIVERS=="xhci-hcd"
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform/usb1/fe900000.dwc3':
KERNELS=="fe900000.dwc3"
SUBSYSTEMS=="platform"
DRIVERS=="dwc3"
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="platform"
DRIVERS=="rockchip-dwc3"
ATTRS{dwc3_mode}=="host"
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform':
KERNELS=="platform"
SUBSYSTEMS==""
DRIVERS==""
root@rockchip-evb:/userdata/zl/rknn_test#
鉴于前面的0-9我们也没有用到,于是我们考虑重新进行映射,将video10映射到video0,而video11映射到video1,具体操作也就是问题解决方法如下:
使用udev规则创建usb摄像头挂载点映射
在 /etc/udev/rules.d/*.rules (任意rules下,也可以自己新建一个.rules文件),添加如下规则:
SUBSYSTEM=="video*",ATTRS{idVendor}=="1bcf",ATTRS{idProduct}=="2283",ATTR{index}=="0",MODE="0666",SYMLINK+="video0"
SUBSYSTEM=="video*",ATTRS{idVendor}=="1bcf",ATTRS{idProduct}=="2283",ATTR{index}=="1",MODE="0666",SYMLINK+="video1"
上面出现的几个字段的意义以及如何取值说明如下:
1.SUBSYSTEM。该字段是固定的,就是进入的uvc设备的挂载点
2.ATTRS{idVendor}和ATTRS{idProduct}。这两个字段是uvc设备的信息,可以从前面udevadm info命令结果中查看,或者是从uvc设备接到开发版上时的log中查看,如下:
[ 182.088957] usb 3-1: USB disconnect, device number 4
[ 184.492728] usb 2-1.2: new high-speed USB device number 3 using ehci-platform
[ 184.756950] usb 2-1.2: New USB device found, idVendor=1bcf, idProduct=2283
[ 184.757687] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 184.758353] usb 2-1.2: Product: FULL HD webcam
[ 184.758883] usb 2-1.2: Manufacturer: AONI ELECTRONIC CO.LTD
[ 184.759399] usb 2-1.2: SerialNumber: 20200523001
[ 184.981127] uvcvideo: Found UVC 1.00 device FULL HD webcam (1bcf:2283)
[ 185.057555] usb 2-1.2: Warning! Unlikely big volume range (=4096), cval->res is probably wrong.
[ 185.058425] usb 2-1.2: [5] FU [Mic Capture Volume] ch = 1, val = 0/4096/1
从上面的log中也能看出idVendor和idProduct。
3.ATTR{index}。这个值需要从udevadm info命令结果中查看,通过这个可以区分一个uvc设备接入后的两个挂载点。
4.MODE。挂载点的访问权限。
5.SYMLINK+=。映射到某个挂载点。
重启设备,并重新接入uvc设备,查看如下:
这样,我们就可以通过下面命令获取摄像头数据了,用的0是因为实际有效的是video10:
capture = cv.VideoCapture(0);
另外,属性读取如下:
capture.get(self, propId):函数的作用是获取摄像头设置的相关属性值,官方给出的定义如下:
参数 | propld | 功能 |
---|---|---|
cv2.CAP_PROP_POS_MSEC | 0 | 视频文件的当前位置(以毫秒为单位)或视频捕获时间戳 |
cv2.CAP_PROP_POS_FRAMES | 1 | 基于0的索引将被解码/捕获下一帧 |
cv2.CAP_PROP_POS_AVI_RATIO | 2 | 视频文件的相对位置:0 - 视频的开始,1 - 视频的结束 |
cv2.CAP_PROP_FRAME_WIDTH | 3 | 帧的宽度 |
cv2.CAP_PROP_FRAME_HEIGHT | 4 | 帧的高度 |
cv2.CAP_PROP_FPS | 5 | 帧速 |
cv2.CAP_PROP_FOURCC | 6 | 4个字符表示的视频编码器格式 |
cv2.CAP_PROP_FRAME_COUNT | 7 | 帧数 |
cv2.CAP_PROP_FORMAT | 8 | byretrieve()返回的Mat对象的格式 |
cv2.CAP_PROP_MODE | 9 | 指示当前捕获模式的后端特定值 |
cv2.CAP_PROP_BRIGHTNESS | 10 | 图像的亮度(仅适用于相机) |
cv2.CAP_PROP_CONTRAST | 11 | 图像对比度(仅适用于相机) |
cv2.CAP_PROP_SATURATION | 12 | 图像的饱和度(仅适用于相机) |
cv2.CAP_PROP_HUE | 13 | 图像的色相(仅适用于相机) |
cv2.CAP_PROP_GAIN | 14 | 图像的增益(仅适用于相机) |
cv2.CAP_PROP_EXPOSURE | 15 | 曝光(仅适用于相机) |
cv2.CAP_PROP_CONVERT_RGB | 16 | 表示图像是否应转换为RGB的布尔标志 |
cv2.CAP_PROP_WHITE_BALANCE | 17 | 目前不支持 |
cv2.CAP_PROP_RECTIFICATION | 18 | 立体摄像机的整流标志 |
- 分享
- 举报
-
浏览量:975次2023-12-16 16:39:06
-
浏览量:4823次2021-07-22 18:16:29
-
浏览量:2583次2023-12-29 17:55:25
-
浏览量:648次2023-12-21 18:17:30
-
浏览量:669次2023-12-21 18:18:43
-
浏览量:1155次2023-12-29 17:53:39
-
浏览量:2271次2022-05-17 09:00:33
-
浏览量:861次2023-12-07 01:07:22
-
浏览量:1685次2024-01-02 22:42:19
-
浏览量:1966次2020-04-15 10:28:57
-
浏览量:2069次2020-04-01 10:07:10
-
浏览量:2988次2022-05-17 09:00:35
-
浏览量:1862次2020-01-17 14:35:18
-
浏览量:2161次2020-08-05 21:02:35
-
浏览量:3641次2018-02-20 00:36:12
-
浏览量:752次2023-06-12 14:35:58
-
浏览量:3404次2020-10-29 17:26:12
-
浏览量:1567次2024-02-04 17:13:47
-
浏览量:1073次2024-01-11 17:32:51
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
林
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明