rkdown_views prism-atom-one-dark">
一,描述
UVC(USB Video Class)是一种 USB 设备类标准,允许通过 USB 连接的视频设备(如摄像头、网络摄像头和其他视频捕捉设备)与计算机或其他主机设备进行通信。UVC 使得视频设备的使用变得更加简单和通用,因为它不需要特定的驱动程序,主机操作系统通常可以直接识别和使用这些设备。
UVC 的主要特点
- 即插即用:
UVC 设备可以在连接到主机时自动识别,无需安装额外的驱动程序。这使得用户能够快速方便地使用视频设备。- 跨平台支持:
UVC 设备通常可以在多种操作系统上工作,包括 Windows、macOS 和 Linux。这种跨平台的兼容性使得 UVC 成为视频设备的标准选择。- 视频格式支持:
UVC 支持多种视频格式和分辨率,包括 MJPEG、YUY2、H.264 等。设备可以根据主机的能力和应用程序的需求选择合适的格式。- 控制功能:
UVC 设备通常支持多种控制功能,例如亮度、对比度、饱和度、焦距等。这些控制可以通过 USB 接口进行调整。- 流媒体支持:
UVC 设备可以用于实时视频流传输,适用于视频会议、直播、监控等应用场景。
二,问题现象
把摄像头接入到PC上,会发现实际支持的最大预览分辨率是:4656x3496,但是Android系统中显示支持的分辨率却没有,最大是1920x1080。缺少的分辨率为什么没有?到哪里去了?
使用 v4l2-ctl 命令行工具来列出连接的 UVC 设备:
1.列出所有视频设备
v4l2-ctl --list-devices
rk3568:/ # v4l2-ctl --list-devices
rkisp-statistics (platform: rkisp):/dev/video12/dev/video13/dev/video21/dev/video22rkcif (platform:rkcif_mipi_lvds):/dev/video0/dev/video1/dev/video2/dev/video3/dev/video4rkisp_mainpath (platform:rkisp-vir0):/dev/video5/dev/video6/dev/video7/dev/video8/dev/video9/dev/video10/dev/video11rkisp_mainpath (platform:rkisp-vir1):/dev/video14/dev/video15/dev/video16/dev/video17/dev/video18/dev/video19/dev/video20HK 16M CAM: HK 16M CAM (usb-xhci-hcd.2.auto-1):/dev/video23/dev/video24
2. 获取特定设备的支持格式
v4l2-ctl --device=/dev/video23 --list-formats
rk3568:/ # v4l2-ctl --device=/dev/video23 --list-formats
ioctl: VIDIOC_ENUM_FMTIndex : 0Type : Video CapturePixel Format: 'MJPG' (compressed)Name : Motion-JPEGIndex : 1Type : Video CapturePixel Format: 'YUYV'Name : YUYV 4:2:2
3. 设备支持分辨率
v4l2-ctl -d /dev/video23 --list-framesizes=YUYV
rk3568:/ # v4l2-ctl -d /dev/video23 --list-framesizes=YUYV
ioctl: VIDIOC_ENUM_FRAMESIZESSize: Discrete 1920x1080Size: Discrete 4656x3496Size: Discrete 4208x3120Size: Discrete 4160x3120Size: Discrete 4000x3000Size: Discrete 3264x2448Size: Discrete 2592x1944Size: Discrete 2320x1744Size: Discrete 2304x1728Size: Discrete 2048x1536Size: Discrete 1600x1200Size: Discrete 1280x960Size: Discrete 1280x720Size: Discrete 1024x768Size: Discrete 800x600Size: Discrete 640x480
三,解决办法
1.关于摄像头部分的源码目录:
#SDK 接口
frameworks/base/core/java/android/hardware/Camera.java
frameworks/base/core/jni/android_hardware_Camera.cpp#上层 Camera 服务
frameworks/av/camera/# HAL层
hardware/rockchip/camera
hardware/interfaces/camera/# 配置文件,对应USB和CSI之类的摄像头配置
# 包含了支持分辨率,闪光灯等等的一些特性。
device/rockchip/common/external_camera_config.xml
hardware/rockchip/camera/etc/camera/
预览的限制主要存在于HAL和framework层。
2.device
源码路径:device/rockchip/common/external_camera_config.xml
FpsList
中增加对应缺少的分辨率:
diff --git a/device/rockchip/common/external_camera_config.xml b/device/rockchip/common/external_camera_config.xml
index d377826d4e..ce604a4076 100755
--- a/device/rockchip/common/external_camera_config.xml
+++ b/device/rockchip/common/external_camera_config.xml
@@ -64,6 +64,7 @@<Limit width="2592" height="1944" fpsBound="15.0" /><Limit width="2592" height="1944" fpsBound="10.0" /><Limit width="2592" height="1944" fpsBound="5.0" />
+ <Limit width="4656" height="3496" fpsBound="30.0" /><!-- image size larger than the last entry will not be supported--></FpsList><!-- orientation -->
3.HAL
源码路径:hardware/interfaces/camera/device/3.4/default/RgaCropScale.cpp
diff --git a/hardware/interfaces/camera/device/3.4/default/RgaCropScale.cpp b/hardware/interfaces/camera/device/3.4/default/RgaCropScale.cpp
index 55a2c3d08d..d3eb278093 100644
--- a/hardware/interfaces/camera/device/3.4/default/RgaCropScale.cpp
+++ b/hardware/interfaces/camera/device/3.4/default/RgaCropScale.cpp
@@ -21,21 +21,21 @@
namespace android {
namespace camera2 {
-#if (defined(TARGET_RK32) || defined(TARGET_RK3368))
+//#if (defined(TARGET_RK32) || defined(TARGET_RK3368))
#define RGA_VER (2.0)
#define RGA_ACTIVE_W (4096)
#define RGA_VIRTUAL_W (4096)
#define RGA_ACTIVE_H (4096)
#define RGA_VIRTUAL_H (4096)
-#else
-#define RGA_VER (1.0)
-#define RGA_ACTIVE_W (2048)
-#define RGA_VIRTUAL_W (4096)
-#define RGA_ACTIVE_H (2048)
-#define RGA_VIRTUAL_H (2048)
+//#else
+//#define RGA_VER (1.0)
+//#define RGA_ACTIVE_W (2048)
+//#define RGA_VIRTUAL_W (4096)
+//#define RGA_ACTIVE_H (2048)
+//#define RGA_VIRTUAL_H (2048)
-#endif
+//#endif
int RgaCropScale::CropScaleNV12Or21(struct Params* in, struct Params* out)
rks_175">4.frameworks
源码路径:frameworks/av/services/camera/libcameraservice/api1/client2/Parameters.h
上层接口解除1080P的限制。
diff --git a/frameworks/av/services/camera/libcameraservice/api1/client2/Parameters.h b/frameworks/av/services/camera/libcameraservice/api1/client2/Parameters.h
index 3a709c9791..163d060b81 100644
--- a/frameworks/av/services/camera/libcameraservice/api1/client2/Parameters.h
+++ b/frameworks/av/services/camera/libcameraservice/api1/client2/Parameters.h
@@ -199,11 +199,11 @@ struct Parameters {// Max preview size allowed// This is set to a 1:1 value to allow for any aspect ratio that has// a max long side of 1920 pixels
- static const unsigned int MAX_PREVIEW_WIDTH = 1920;
- static const unsigned int MAX_PREVIEW_HEIGHT = 1920;
+ static const unsigned int MAX_PREVIEW_WIDTH = 4656;
+ static const unsigned int MAX_PREVIEW_HEIGHT = 3496;// Initial max preview/recording size bound
- static const int MAX_INITIAL_PREVIEW_WIDTH = 1920;
- static const int MAX_INITIAL_PREVIEW_HEIGHT = 1080;
+ static const int MAX_INITIAL_PREVIEW_WIDTH = 4656;
+ static const int MAX_INITIAL_PREVIEW_HEIGHT = 3496;// Aspect ratio tolerancestatic const CONSTEXPR float ASPECT_RATIO_TOLERANCE = 0.001;// Threshold for slow jpeg mode
至此,系统相机—设置—分辨率与画质,就可以看到对应的最大的分辨率;