RK3288[android 7.1]调试笔记 修改默认的PreviewSize预览分辨率和PictureSize照片大小
从log中知道自带摄像头应用是会根据支持的分辨率并结合屏的分辨率去选择最优分辨率的
01-18 16:52:13.918 226 706 I CameraHal: initDefaultParameters(170): dsy log:initDefaultParameters(170): params.setPreviewSize(1280,720); //这里我设定PreviewSize预览分辨率是1280x720 即16:9
01-18 16:52:13.918 226 706 I CameraHal: initDefaultParameters(180): dsy log:initDefaultParameters(180): params.setPreviewSize(mCamDriverFrmWidthMax,mCamDriverFrmHeightMax);
01-18 16:52:13.933 537 1026 E ActivityThread: Failed to find provider info for com.android.calendar
01-18 16:52:13.935 537 1026 E ActivityThread: Failed to find provider info for com.android.calendar
01-18 16:52:13.957 226 706 E CameraHal: initDefaultParameters(529): initDefaultParameters(529): mCamDriverCapability.card is error!
01-18 16:52:13.957 226 706 D CameraHal: initDefaultParameters(594): mIsCtsTest:0 Support video sizes:(null)
01-18 16:52:13.957 226 706 D CameraHal: initDefaultParameters(611): Support Preview format: yuv420sp,yuv420p .. yuv420sp
01-18 16:52:13.957 226 706 D CameraHal: initDefaultParameters(613): Support Preview sizes: 1280x720,640x480,352x288,320x240,176x144,160x120,1280x800 1280x720 //这里可以看到支持的PreviewSize预览分辨率 和自己设定的分辨率
01-18 16:52:13.957 226 706 D CameraHal: initDefaultParameters(614): Support Preview FPS range: (30000,30000)
01-18 16:52:13.957 226 706 D CameraHal: initDefaultParameters(615): Support Preview framerate: 30
01-18 16:52:13.957 226 706 D CameraHal: initDefaultParameters(616): Support Picture sizes: 1280x720,640x480,352x288,320x240,176x144,160x120,1280x800 //这里可以看到支持的PictureSize照片大小的分辨率 和自己设定的分辨率,照片大小默认是选择最大的分辨率
01-18 16:52:32.048 1905 1905 D CAM_ResolutionSettings: camera CameraId{Api2='0',Api1:0} getPictureSize
01-18 16:52:32.049 1905 1905 V CAM_PhotoModule: setting preview size. optimal: 1280x800original: 1280x720 //这里看到最优预览分辨率是1280x800即8:5,设定的预览分辨率是1280x720 即16:9
01-18 16:52:32.056 226 2085 D CameraHal: cameraConfig(893): cameraConfig(893): Set anti-banding Disabled
01-18 16:52:32.056 226 2085 D CameraHal: isNeedToRestartPreview(168): mPreviewFrame2AppW (1280x720)
01-18 16:52:32.056 226 2085 D CameraHal: isNeedToRestartPreview(169): mCamPreviewW (0x0)
01-18 16:52:32.056 226 2085 D CameraHal: isNeedToRestartPreview(170): video width (1280x720)
01-18 16:52:32.058 226 2085 D CameraHal: setParameters(700): suppport focus modes:fixed, expect:fixed
01-18 16:52:32.058 226 2085 D CameraHal: isNeedToRestartPreview(168): mPreviewFrame2AppW (1280x720)
01-18 16:52:32.058 226 2085 D CameraHal: isNeedToRestartPreview(169): mCamPreviewW (0x0)
01-18 16:52:32.058 226 2085 D CameraHal: isNeedToRestartPreview(170): video width (1280x720)
01-18 16:52:32.061 226 2085 D CameraHal: setParameters(660): setParameters(660): Set preview size 1280x800//看到设定的分辨率并不生效,相机自动选择最优的预览分辨率
01-18 16:52:32.061 226 2085 D CameraHal: setParameters(676): setParameters(676): Set picture size 1280x800//生成照片的分辨率默认是选择最大即1280x800
01-18 16:52:32.061 226 2085 D CameraHal: setParameters(700): suppport focus modes:fixed, expect:fixed
01-18 16:52:32.061 226 2085 D CameraHal: isNeedToRestartPreview(168): mPreviewFrame2AppW (1280x800)
01-18 16:52:32.061 226 2085 D CameraHal: isNeedToRestartPreview(169): mCamPreviewW (0x0)
01-18 16:52:32.061 226 2085 D CameraHal: isNeedToRestartPreview(170): video width (1280x800)
01-18 16:52:32.063 1905 1905 V CAM_PhotoModule: updating aspect ratio
01-18 16:52:32.063 1905 1905 V CAM_TexViewHelper: updateAspectRatio 1.6
01-18 16:52:32.063 1905 1905 V CAM_TexViewHelper: setAspectRatio: 1.6
01-18 16:52:32.063 1905 1905 V CAM_TexViewHelper: aspect ratio changed from: 0.0
01-18 16:52:32.063 1905 1905 V CAM_TexViewHelper: updateTransform
01-18 16:52:32.063 1905 1905 D CAM_PhotoModule: Preview size is 1280x800//最终看到设定的分辨率并不生效,相机自动选择最优的预览分辨率1280x800
01-18 16:52:32.064 1905 1905 V CAM_FocusOverlayMgr: stored focus setting for camera: continuous-picture
解决方法在路径为/hardware/rockchip/camera/CameraHal/CameraUSBAdapter.cpp文件中可以自行定制预览分辨分辨率,把1280x720设为最大的分辨率为预览。
wangxd@build-server-100:~/work/dsy/rk3288-Android-7.0/hardware/rockchip/camera((1d71794...))$ git diff CameraHal/CameraUSBAdapter.cpp
diff --git a/CameraHal/CameraUSBAdapter.cpp b/CameraHal/CameraUSBAdapter.cpp
index b565930..78c16a0 100755
--- a/CameraHal/CameraUSBAdapter.cpp
+++ b/CameraHal/CameraUSBAdapter.cpp
@@ -164,15 +164,16 @@ void CameraUSBAdapter::initDefaultParameters(int camFd)params.set(KEY_PREVIEW_W_FORCE,"0");params.set(KEY_PREVIEW_H_FORCE,"0");
- params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, parameterString.string());
- if(parameterString.contains("640x480"))
- params.setPreviewSize(640,480);
- else
+ // params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, parameterString.string());
+ params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, "1280x720,640x480,352x288,320x240,176x144,160x120");
+ if(parameterString.contains("1280x720")) //.contains方法---如果1280x720有包含在支持分辨率KEY_SUPPORTED_PREVIEW_SIZES "1280x720,640x480,352x288,320x240,176x144,160x120"中为真,否则为假
+ params.setPreviewSize(1280,720);
+ elseparams.setPreviewSize(mCamDriverFrmWidthMax,mCamDriverFrmHeightMax);/*picture size setting*/
- params.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, parameterString.string());
- params.setPictureSize(mCamDriverFrmWidthMax, mCamDriverFrmHeightMax); + params.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, "1280x720,640x480,352x288,320x240,176x144,160x120");
+ // params.setPictureSize(mCamDriverFrmWidthMax,mCamDriverFrmHeightMax);
+ params.setPictureSize(1280,720);/* set framerate */struct v4l2_streamparm setfps;int fps_min,fps_max;
最终成功可以看到把1280x720(16:9)设置为默认预览分辨率