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

问题记录

SOC:RK3568

system:Android12

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

修改:

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

int RgaCropScale::rga_scale_crop(
		int src_width, int src_height,
		unsigned long src_fd, int src_format,unsigned long dst_fd,
		int dst_width, int dst_height,
		int zoom_val, int mirror,bool flipH, bool flipV, bool isNeedCrop,
		bool isDstNV21, bool is16Align, bool isYuyvFormat)
{
    ...           
    src.rotation = 0;
    if (mirror == 90)
        src.rotation = HAL_TRANSFORM_ROT_90;
    else if(mirror == 180)
        src.rotation = HAL_TRANSFORM_ROT_180;
    else if(mirror == 270)
        src.rotation = HAL_TRANSFORM_ROT_270;
    ...

}

修改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

template <typename TClientBase>
Camera2ClientBase<TClientBase>::Camera2ClientBase(
        const sp<CameraService>& cameraService,
        const sp<TCamCallbacks>& remoteCallback,
        const String16& clientPackageName,
        const std::optional<String16>& clientFeatureId,
        const String8& cameraId,
        int api1CameraId,
        int cameraFacing,
        int sensorOrientation,
        int clientPid,
        uid_t clientUid,
        int servicePid,
        bool overrideForPerfClass,
        bool legacyClient):
        TClientBase(cameraService, remoteCallback, clientPackageName, clientFeatureId,
                cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid, clientUid,
                servicePid),
        mSharedCameraCallbacks(remoteCallback),
        mDeviceVersion(cameraService->getDeviceVersion(TClientBase::mCameraIdStr)),
        mDevice(new Camera3Device(cameraId, overrideForPerfClass, legacyClient)),
        mDeviceActive(false), mApi1CameraId(api1CameraId)
{
    ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
            String8(clientPackageName).string(), clientPid, clientUid);

++         int iCameraIDatoi = atoi(cameraId.string());
++         if(iCameraIDatoi == 0 || iCameraIDatoi == 1){
  ++__system_property_set("persist.camera.openCameraAPP",String8(clientPackageName).string());
++  }
    mInitialClientPid = clientPid;
    LOG_ALWAYS_FATAL_IF(mDevice == 0, "Device should never be NULL here.");
}

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

++#include <cutils/properties.h>

int RgaCropScale::rga_scale_crop(
		int src_width, int src_height,
		unsigned long src_fd, int src_format,unsigned long dst_fd,
		int dst_width, int dst_height,
		int zoom_val, int mirror,bool flipH, bool flipV, bool isNeedCrop,
		bool isDstNV21, bool is16Align, bool isYuyvFormat)
{
    ...           
--    src.rotation = 0;
--    if (mirror == 90)
--        src.rotation = HAL_TRANSFORM_ROT_90;
--    else if(mirror == 180)
--        src.rotation = HAL_TRANSFORM_ROT_180;
--    else if(mirror == 270)
--        src.rotation = HAL_TRANSFORM_ROT_270;

++    char CameraAPP[128];
++    __system_property_get("persist.camera.openCameraAPP",CameraAPP);
++    if(strcmp(CameraAPP,"tv.danmaku.bili") == 0 ){
++        src.rotation = HAL_TRANSFORM_ROT_90;
++    }

    ...

}

  • 10
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hmbbPdx_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值