当前位置:   article > 正文

RK 解决抖音 流行应用 摄像头画面裁剪放大

RK 解决抖音 流行应用 摄像头画面裁剪放大

问题记录

SOC:RK3568

system:Android12

流行应用 一些APP通过打开板载摄像头出现画面裁剪 画面比例不正常或者是预览方向旋转,但是使用相机APP打开却不会

修改:

hardware\interfaces\camera\device\3.4\default\RgaCropScale.cpp

  1. int RgaCropScale::rga_scale_crop(
  2. int src_width, int src_height,
  3. unsigned long src_fd, int src_format,unsigned long dst_fd,
  4. int dst_width, int dst_height,
  5. int zoom_val, int mirror,bool flipH, bool flipV, bool isNeedCrop,
  6. bool isDstNV21, bool is16Align, bool isYuyvFormat)
  7. {
  8. ...
  9. src.rotation = 0;
  10. if (mirror == 90)
  11. src.rotation = HAL_TRANSFORM_ROT_90;
  12. else if(mirror == 180)
  13. src.rotation = HAL_TRANSFORM_ROT_180;
  14. else if(mirror == 270)
  15. src.rotation = HAL_TRANSFORM_ROT_270;
  16. ...
  17. }

修改src.rotation赋值:

旋转:

HAL_TRANSFORM_ROT_90;

HAL_TRANSFORM_ROT_180;

HAL_TRANSFORM_ROT_270

镜像:

HAL_TRANSFORM_FLIP_H

HAL_TRANSFORM_FLIP_V

上面修改会影响系统相机画面,添加判断哪个app打开摄像头

frameworks/av/services/camera/libcameraservice/common/Camera2ClientBase.cpp

  1. template <typename TClientBase>
  2. Camera2ClientBase<TClientBase>::Camera2ClientBase(
  3. const sp<CameraService>& cameraService,
  4. const sp<TCamCallbacks>& remoteCallback,
  5. const String16& clientPackageName,
  6. const std::optional<String16>& clientFeatureId,
  7. const String8& cameraId,
  8. int api1CameraId,
  9. int cameraFacing,
  10. int sensorOrientation,
  11. int clientPid,
  12. uid_t clientUid,
  13. int servicePid,
  14. bool overrideForPerfClass,
  15. bool legacyClient):
  16. TClientBase(cameraService, remoteCallback, clientPackageName, clientFeatureId,
  17. cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid, clientUid,
  18. servicePid),
  19. mSharedCameraCallbacks(remoteCallback),
  20. mDeviceVersion(cameraService->getDeviceVersion(TClientBase::mCameraIdStr)),
  21. mDevice(new Camera3Device(cameraId, overrideForPerfClass, legacyClient)),
  22. mDeviceActive(false), mApi1CameraId(api1CameraId)
  23. {
  24. ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
  25. String8(clientPackageName).string(), clientPid, clientUid);
  26. ++ int iCameraIDatoi = atoi(cameraId.string());
  27. ++ if(iCameraIDatoi == 0 || iCameraIDatoi == 1){
  28. ++__system_property_set("persist.camera.openCameraAPP",String8(clientPackageName).string());
  29. ++ }
  30. mInitialClientPid = clientPid;
  31. LOG_ALWAYS_FATAL_IF(mDevice == 0, "Device should never be NULL here.");
  32. }

hardware\interfaces\camera\device\3.4\default\RgaCropScale.cpp

  1. ++#include <cutils/properties.h>
  2. int RgaCropScale::rga_scale_crop(
  3. int src_width, int src_height,
  4. unsigned long src_fd, int src_format,unsigned long dst_fd,
  5. int dst_width, int dst_height,
  6. int zoom_val, int mirror,bool flipH, bool flipV, bool isNeedCrop,
  7. bool isDstNV21, bool is16Align, bool isYuyvFormat)
  8. {
  9. ...
  10. -- src.rotation = 0;
  11. -- if (mirror == 90)
  12. -- src.rotation = HAL_TRANSFORM_ROT_90;
  13. -- else if(mirror == 180)
  14. -- src.rotation = HAL_TRANSFORM_ROT_180;
  15. -- else if(mirror == 270)
  16. -- src.rotation = HAL_TRANSFORM_ROT_270;
  17. ++ char CameraAPP[128];
  18. ++ __system_property_get("persist.camera.openCameraAPP",CameraAPP);
  19. ++ if(strcmp(CameraAPP,"tv.danmaku.bili") == 0 ){
  20. ++ src.rotation = HAL_TRANSFORM_ROT_90;
  21. ++ }
  22. ...
  23. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/249883?site
推荐阅读
相关标签
  

闽ICP备14008679号