查看: 1934|回复: 0

USB摄像头常见问题修改

[复制链接]

10

主题

0

回帖

3034

积分

论坛元老

Rank: 8Rank: 8

积分
3034
发表于 2019-5-24 10:34:08 | 显示全部楼层 |阅读模式
问题一:不能打开USB摄像头
原因:摄像头不支持驱动固定的预览分辨率
解决:设置固定拍照预览分辨率
  1. hardware/rockchip/camera/CameraHal/CameraUSBAdapter.cpp
  2. @@ -135,7 +135,7 @@ void CameraUSBAdapter::initDefaultParameters(int camFd)
  3.      params.set(KEY_PREVIEW_W_FORCE,"0");
  4.      params.set(KEY_PREVIEW_H_FORCE,"0");
  5.      params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, parameterString.string());
  6. -    params.setPreviewSize(640,480);
  7. +    params.setPreviewSize(320,240);
  8.      /*picture size setting*/      
  9.      params.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, parameterString.string());        
  10.      params.setPictureSize(mCamDriverFrmWidthMax,  mCamDriverFrmHeightMax);  
复制代码


问题二:打开相机后,不能拍照
原因:摄像头不支持驱动固定的拍照分辨率
解决:设置固定拍照分辨率
  1. hardware/rockchip/camera/CameraHal/CameraAdapter.cpp
  2. @@ -168,7 +168,8 @@ bool CameraAdapter::getFlashStatus()
  3. }
  4. status_t CameraAdapter::startPreview(int preview_w,int preview_h,int w, int h, int fmt,bool is_capture)
  5. {
  6. -   
  7. +    w = 640;
  8. +   h = 480;
  9.      //create buffer
  10.         LOG_FUNCTION_NAME
  11.      unsigned int frame_size = 0,i;
复制代码

问题三:不能录像
原因:摄像头不支持驱动固定的录像分辨率
解决:设置录像分辨率
  1. frameworks/av/media/libstagefright/CameraSource.cpp
  2. @@ -493,6 +493,10 @@ status_t CameraSource::init(
  3.          int32_t frameRate,
  4.          bool storeMetaDataInVideoBuffers) {

  5. +        videoSize.width = 640;         
  6. +        videoSize.height = 480;
  7. +       frameRate = 15;
  8. +
  9.      ALOGV("init");
  10.      status_t err = OK;
  11.      int64_t token = IPCThreadState::self()->clearCallingIdentity();
复制代码

问题四:摄像头方向不对
解决:修改摄像头方向
  1. hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp
  2. @@ -781,7 +781,7 @@ int camera_get_number_of_cameras(void)
  3.                      ptr++;
  4.                      camInfoTmp[cam_cnt].facing_info.orientation = atoi(ptr);
  5.                  } else {
  6. -                    camInfoTmp[cam_cnt].facing_info.orientation = 0;
  7. +                    camInfoTmp[cam_cnt].facing_info.orientation = 180;
  8.                  }
复制代码


问题五:预览镜像
解决:前后置调换(修改后预览不镜像,但是照片还是镜像
  1. frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp
  2. @@ -654,7 +656,7 @@ status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {

  3.      if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
  4.          // Mirror the preview if the camera is front-facing.
  5. -        orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
  6. +        orientation = getOrientation(arg1, mCameraFacing == !CAMERA_FACING_FRONT);
  7.          if (orientation == -1) return BAD_VALUE;

  8.          if (mOrientation != orientation) {
复制代码











回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

源创嵌入式官网

GMT+8, 2024-5-17 19:54 , Processed in 0.081535 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表