admin 管理员组

文章数量: 1184232

开发环境

OpenHarmony5.0.2 RK3568

USB摄像头

遇到问题

编译后插上USB摄像头后打开相机无图像

解决思路

5.0.2版本是支持USB摄像头的,需要修改默认的板载相机配置即可。

修改代码
1、修改HCS 配置

文件地址:vendor/hihope/rk3568/hdf_config/uhdf/camera/hdi_impl/camera_host_config.hcs

删除ability_01 :: ability {}

2、删除缓存后编译

修改hcs后编译时可能会有缓存,最后先在代码根目录下执行下面的命令后再编译。
find ./out -type f -name "*.hcb" -exec rm -v {} \;
find ./out -type f -name "*.cfg" -exec rm -v {} \;

3、调试排查步骤

linux安装v4l2-ctl查看USB摄像头支持的格式

/dev$ sudo v4l2-ctl -d video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
	Index       : 0
	Type        : Video Capture
	Pixel Format: 'MJPG' (compressed)
	Name        : Motion-JPEG
	Index       : 1
	Type        : Video Capture
	Pixel Format: 'YUYV'
	Name        : YUYV 4:2:2

Windows 环境安装AMCap查看摄像头支持格式

查看插入的串口日志包含USB Camera

插入串口日志[ 4245.564927] usb 5-1.3: new high-speed USB device number 13 using xhci-hcd
[ 4245.685701] usb 5-1.3: New USB device found, idVendor=0bda, idProduct=5b05, bcdDevice= 0.00
[ 4245.685741] usb 5-1.3: New USB device strings: Mfr=3, Product=1, SerialNumber=2
[ 4245.685751] usb 5-1.3: Product: USB Camera
[ 4245.685759] usb 5-1.3: Manufacturer: Generic
[ 4245.685767] usb 5-1.3: SerialNumber: 200901010001
[ 4245.687188] [AUTH_CTRL] no auth data for this pid = 578
[ 4245.687188] , tgid
[ 4245.687199] [QOS_CTRL] do_qos_ctrl_ioctl: pid not authorized
[ 4245.745061] uvcvideo: Found UVC 1.00 device USB Camera (0bda:5b05)
[ 4245.757268] [I/USB_PNP_NOTIFY] UsbPnpNotifyCallback: action=0x1
[ 4245.757323] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=0, interfaceInfo=0xe-0x1-0x0-0x0
[ 4245.757335] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=1, interfaceInfo=0xe-0x2-0x0-0x1
[ 4245.757377] [I/USB_PNP_NOTIFY] UsbPnpNotifyReportThread: UsbPnpNotifyReportThread start!
[ 4245.757409] [I/USB_PNP_NOTIFY] UsbPnpNotifyHdfSendEvent:375 device information, 3 usbDevAddr=18446743525960148992, devNum=13, busNum=5, infoTable=2-0xbda-0x5b05!
[ 4245.777467] [AUTH_CTRL] no auth data for this pid = 643

确定Linux 内核UVC协议已生效以及USB UVC camera被识别

# lsusb
Bus 005 Device 001: ID 1d6b:0002
Bus 003 Device 001: ID 1d6b:0001
Bus 001 Device 001: ID 1d6b:0002
Bus 005 Device 013: ID 0bda:5b05
Bus 005 Device 007: ID 34d1:0608
Bus 006 Device 001: ID 1d6b:0003
Bus 004 Device 001: ID 1d6b:0001
Bus 002 Device 001: ID 1d6b:0002
Bus 005 Device 008: ID 0000:3825
Bus 003 Device 002: ID 34d1:0608

查看USB设备信息

cat /sys/kernel/debug/usb/devices
T:  Bus=05 Lev=02 Prnt=07 Port=02 Cnt=01 Dev#= 13 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0bda ProdID=5b05 Rev= 0.00
S:  Manufacturer=Generic
S:  Product=USB Camera
S:  SerialNumber=200901010001
C:* #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
A:  FirstIf#= 0 IfCount= 2 Cls=0e(video) Sub=03 Prot=00
I:* If#= 0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo
E:  Ad=83(I) Atr=03(Int.) MxPS=  16 Ivl=4ms
I:* If#= 1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
I:  If#= 1 Alt= 1 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
E:  Ad=81(I) Atr=05(Isoc) MxPS= 128 Ivl=125us
I:  If#= 1 Alt= 2 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
E:  Ad=81(I) Atr=05(Isoc) MxPS= 512 Ivl=125us
I:  If#= 1 Alt= 3 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
E:  Ad=81(I) Atr=05(Isoc) MxPS=1024 Ivl=125us
I:  If#= 1 Alt= 4 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
E:  Ad=81(I) Atr=05(Isoc) MxPS=1536 Ivl=125us
I:  If#= 1 Alt= 5 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
E:  Ad=81(I) Atr=05(Isoc) MxPS=2048 Ivl=125us
I:  If#= 1 Alt= 6 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
E:  Ad=81(I) Atr=05(Isoc) MxPS=2688 Ivl=125us
I:  If#= 1 Alt= 7 #EPs= 1 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
E:  Ad=81(I) Atr=05(Isoc) MxPS=3072 Ivl=125u

查看节点信息是否新增video9和video10

# ls -l /dev/video*
crw-rw---- 1 camera_host camera_host 81,   0 2017-08-05 17:03 /dev/video0
crw-rw---- 1 camera_host camera_host 81,   1 2017-08-05 17:03 /dev/video1
crw-rw---- 1 camera_host camera_host 81,  13 2017-08-05 17:04 /dev/video10
crw-rw---- 1 camera_host camera_host 81,   2 2017-08-05 17:03 /dev/video2
crw-rw---- 1 camera_host camera_host 81,   3 2017-08-05 17:03 /dev/video3
crw-rw---- 1 camera_host camera_host 81,   4 2017-08-05 17:03 /dev/video4
crw-rw---- 1 camera_host camera_host 81,   5 2017-08-05 17:03 /dev/video5
crw-rw---- 1 camera_host camera_host 81,   6 2017-08-05 17:03 /dev/video6
crw-rw---- 1 camera_host camera_host 81,   7 2017-08-05 17:03 /dev/video7
crw-rw---- 1 camera_host camera_host 81,   8 2017-08-05 17:03 /dev/video8
crw-rw---- 1 camera_host camera_host 81,  12 2017-08-05 17:04 /dev/video9

开启CameraDumper排查采集的数据格式

参考网站:

其他板载相机适配可参考

5、相机图片视频分辨率大小设置

文件位置:

applications/standard/camera/common/src/main/ets/default/camera/CameraService.ts

如果你使用的系统应用的话,可以尝试改改应用,在cameraService.ts文件里面,把

createPreviewOutput()  createPhotoOutput()  createVideoOutput()

三个函数里面的 previewProfile 后面获取的数组下标,从0改成1 先试下。

可以先在createCameraInput()函数里面,把 outputCapability 输出能力 先打印出来

this.outputCapability = this.mCameraManager.getSupportedOutputCapability();
// 打印设备支持的分辨率
Log.info(`${TAG} createCameraInput previewProfiles = ${JSON.stringify(this.outputCapability.previewProfiles)}`);
Log.info(`${TAG} createCameraInput photoProfiles = ${JSON.stringify(this.outputCapability.photoProfiles)}`);
Log.info(`${TAG} createCameraInput videoProfiles = ${JSON.stringify(this.outputCapability.videoProfiles)}`);

注意:APP的源码需要在DevEco Studio 软件中修改编译后放到SDK中编译,SDK直接改源码不生效,是打包的hap,可以本地修改后直接安装到板子测试效果。

本地需要安装full SDK 请参考如下链接

本文标签: 查看 安装 系统