Android UVC摄像头方向调试

本文主要介绍了在RK3368平台、Android 6.0系统上,针对3.10.0内核的UVC摄像头进行方向调试的方法。提供了两种解决方案:一是修改CameraHal中的facing_info,二是调整驱动,通过修改capability card为"facing-orientation"来指定摄像头的朝向。同时,还提到为了实现多摄像头兼容,可以结合VID与PID进行匹配。

Platform: RK3368

OS: Android 6.0

Kernel: 3.10.0


UVC摄像头方向调试
方法1修改CameraHal

修改代码位置hardware/rockchip/camera/CameraHal
直接在CameraHal中修改facing_info.

diff --git a/CameraHal/CameraHal_Module.cpp b/CameraHal/CameraHal_Module.cpp
index ec56a08..78500e3 100755
--- a/CameraHal/CameraHal_Module.cpp
+++ b/CameraHal/CameraHal_Module.cpp
@@ -771,14 +771,14 @@ int camera_get_number_of_cameras(void)
                 if (strstr((char*)&capability.card[0], "front") != NULL) {
                     camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;
                 } else {
-                    camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;
+                    camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;
                 }  
                 ptr = strstr((char*)&capability.card[0],"-");
                 if (ptr != NULL) {
                     ptr++;
                     camInfoTmp[cam_cnt&0x01].facing_info.orientation = atoi(ptr);
                 } else {
-                    camInfoTmp[cam_cnt&0x01].facing_info.orientation = 0;
+                    camInfoTmp[cam_cnt&0x01].facing_info.orientation = 180;
                 }
 
                 memset(version,0x00,sizeof(version));

方法2修改驱动

将capability card改为"facing-orientation".
例如facing(1), orientation(180)就是"front-180",android的CameraHal会根据命名规则来解析是前置摄像头还是后置摄像头,以及摄像头的方向.如果要做多个摄像头兼容可以加上VID与PID匹配.

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 196198f..d81586f 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -564,6 +564,14 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
                memset(cap, 0, sizeof *cap);
                strlcpy(cap->driver, "uvcvideo", sizeof cap->driver);
                strlcpy(cap->card, vdev->name, sizeof cap->card);
+
+               if(le16_to_cpu(stream->dev->udev->descriptor.idVendor)==0x058f &&
+                       le16_to_cpu(stream->dev->udev->descriptor.idProduct)==0x3841){//058f:3841
+                       pr_info("uvc vendor product matched\n");
+                       memset(cap->card, 0, sizeof cap->card);
+                       strlcpy(cap->card, "front-180", sizeof cap->card);
+               }
+
                usb_make_path(stream->dev->udev,
                              cap->bus_info, sizeof(cap->bus_info));
                cap->version = LINUX_VERSION_CODE;

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值