相机2相机特性似乎显示不正确的数据 [英] Camera 2 CameraCharacteristics seem to show incorrect data

查看:126
本文介绍了相机2相机特性似乎显示不正确的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载并更改了Google的 Camera 2 Basic 示例.我所做的更改增加了通过摄像头设备进行迭代的过程,并显示了它们的某些特征.我创建了此函数:

I have downloaded and changed Google's Camera 2 Basic example. My changes add iterating through camera devices and showing some of their characteristics. I created this function:

private void printCameraCharacteristics() {
    Log.d(TAG, "printCameraCharacteristics");
    Activity activity = getActivity();
    CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
    try {
        for (String cameraId : manager.getCameraIdList()) {
            Log.d(TAG, "------------------------------ "+ cameraId +" ----------------------------------");
            CameraCharacteristics characteristics
                    = manager.getCameraCharacteristics(cameraId);

            // Examine the LENS_FACING characteristic
            Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
            if(facing == null){
                Log.d(TAG, "Facing: NULL");
            }
            else if(facing == CameraCharacteristics.LENS_FACING_BACK){
                Log.d(TAG, "Facing: BACK");
            } else if(facing == CameraCharacteristics.LENS_FACING_FRONT){
                Log.d(TAG, "Facing: FRONT");
            } else if(facing == CameraCharacteristics.LENS_FACING_EXTERNAL){
                Log.d(TAG, "Facing: EXTERNAL");
            } else {
                Log.d(TAG, "Facing: UNKNOWN");
            }

            // Check if the flash is supported.
            Boolean available = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
            if(available == null){
                Log.d(TAG, "Flash unknown");
            }
            else if(available){
                Log.d(TAG, "Flash supported");
            } else {
                Log.d(TAG, "Flash unsupported");
            }

            // Check how much the zoom is supported
            Float zoom = characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
            Log.d(TAG, "Max supported digital zoom: " + zoom);

            // Write all the available focal lengths
            float[] focalLengths = characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS);
            Log.d(TAG, "Available focal lengths: " + Arrays.toString(focalLengths));

            // Check the distortion
            if (Build.VERSION.SDK_INT >= 23) {
                float[] lensDistortionCoefficients = characteristics.get(CameraCharacteristics.LENS_RADIAL_DISTORTION);
                Log.d(TAG, "Lens distortion coefficients : " + Arrays.toString(lensDistortionCoefficients));
            }

            Log.d(TAG, "----------------------------------------------------------------");
        }
    } catch (CameraAccessException e) {
        Log.d(TAG, "CameraAccessException: " + e.getMessage());
    } catch (NullPointerException e) {
        Log.d(TAG, "NullPointerException: " + e.getMessage());
    }
}

我只是通过更改onCreateView将其添加到示例中:

And I just added it to the example by changing onCreateView:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    printCameraCharacteristics();
    return inflater.inflate(R.layout.fragment_camera2_basic, container, false);
}

我得到了华为P30 Pro的以下输出:

And I got the following output for Huawei P30 Pro:

D/Camera2BasicFragment: ------------------------------ 0 ----------------------------------
D/Camera2BasicFragment: Facing: BACK
    Flash supported
    Max supported digital zoom: 10.0
D/Camera2BasicFragment: Available focal lengths: [5.56]
    Lens distortion coefficients : [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]        
    ----------------------------------------------------------------
    ------------------------------ 1 ----------------------------------
    Facing: FRONT
    Flash unsupported
    Max supported digital zoom: 6.0
    Available focal lengths: [3.36]
    Lens distortion coefficients : [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]        
    ----------------------------------------------------------------
D/Camera2BasicFragment: ------------------------------ 2 ----------------------------------
    Facing: BACK
    Flash unsupported
    Max supported digital zoom: 10.0
    Available focal lengths: [5.56]
    Lens distortion coefficients : [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]    
    ----------------------------------------------------------------
    ------------------------------ 3 ----------------------------------
D/Camera2BasicFragment: Facing: BACK
    Flash unsupported
    Max supported digital zoom: 10.0
    Available focal lengths: [2.35]
    Lens distortion coefficients : [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]       
    ----------------------------------------------------------------
    ------------------------------ 4 ----------------------------------
    Facing: BACK
    Flash unsupported
    Max supported digital zoom: 10.0
    Available focal lengths: [14.46]
D/Camera2BasicFragment: Lens distortion coefficients : [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]        
    ----------------------------------------------------------------

但是,某些输出似乎不一致. P30 Pro具有一台具有5倍变焦和文档说的相机对于支持光学变焦的相机,LENS_INFO_AVAILABLE_FOCAL_LENGTHS参数的get将返回一个大于1的数组.华为P30 Pro也有一个超宽相机,据我了解,LENS_RADIAL_DISTORTION应该返回除0之外的其他一些参数.

However, some of the output seems inconsistent. P30 Pro has one camera with 5x zoom and the documentation says that the get for the LENS_INFO_AVAILABLE_FOCAL_LENGTHS parameter will return an array longer than 1 for a camera that supports optical zoom. Huawei P30 Pro also has an ultrawide camera and, from my understanding, the LENS_RADIAL_DISTORTION should return some other parameters than 0.

我已经用具有4个摄像头的小米Mi 9测试了这个示例,而我只有2个.

I have tested this example with Xiaomi Mi 9, which has 4 cameras, and I only get 2.

我的问题是:这是怎么回事?为什么我得到所有与应显示的数据不一致的数据?我对应该显示的内容的理解是否正确,因此我的示例是否正确?

My question is: what is going on here? Why am I getting all this data that is inconsistent with what should be shown? Is my understanding of what should be shown, and thus my example, wrong?

推荐答案

这种观察是非常悲伤和真实的.从第一天开始,错误的报告就困扰着Android相机.多个制造商没有足够的动力为安装在其多个设备上的多个摄像机提供准确的价格.

This observation is very sad and very true. Wrong reporting has haunted Android cameras since day one. The multiple manufacturers have not enough incentive to provide accurate values for multiple cameras they install on their multiple devices.

他们只会确保预先安装的相机应用程序运行正常,并测试一些重量级的第三方应用程序,如Instagram和Snapchat.这些应用未使用的参数可以具有任意值.

They would only make sure that their preinstalled camera app works decently, and test few heavyweight 3rd party apps like Instagram and Snapchat. Parameters that are not used by these apps may have arbitrary values.

我们最终保留了基于设备型号和内部版本号的调整列表.有时类似的设备有类似的错误,有时却没有. OTA更新修复了一些错误,此类更新引入了其他错误.这些调整中的大多数都可以推送到设备,而无需强制从PlayStore升级应用.

We end up keeping a list of tweaks, based on device model and build number. Sometimes similar devices have similar bugs, sometimes they don't. Some bugs are fixed with OTA updates, other bugs are introduced with such updates. Most of these tweaks can be pushed to the devices without forcing app upgrade from PlayStore.

很抱歉没有为这种常见的麻烦准备神奇的药.

Sorry for not having a magic pill for this common trouble.

这篇关于相机2相机特性似乎显示不正确的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆