首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >照相机2 CameraCharacteristics似乎显示不正确的数据

照相机2 CameraCharacteristics似乎显示不正确的数据
EN

Stack Overflow用户
提问于 2019-07-19 15:03:44
回答 1查看 992关注 0票数 3

我已经下载并更改了Google的照相机2 Basic示例。我的更改增加了对相机设备的迭代,并显示了它们的一些特性。我创建了这个函数:

代码语言:javascript
复制
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将其添加到示例中

代码语言:javascript
复制
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    printCameraCharacteristics();
    return inflater.inflate(R.layout.fragment_camera2_basic, container, false);
}

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

代码语言:javascript
复制
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有一个带有5x变焦和文件上说的相机,LENS_INFO_AVAILABLE_FOCAL_LENGTHS参数的get将返回一个大于1的阵列,用于支持光学变焦的摄像机。华为P30 Pro还配备了一款超宽摄像头,据我所知,LENS_RADIAL_DISTORTION还应该返回0以外的一些参数。

我用小米米9测试了这个例子,它有4个摄像头,我只得到2个。

我的问题是:这是怎么回事?为什么我得到的这些数据与应该显示的内容不一致?我对应该展示的东西以及我的榜样的理解是错误的吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-19 15:33:19

这一看法是非常可悲和非常真实的。错误的报道从第一天起就一直困扰着安卓摄像头。多家制造商没有足够的动力为他们安装在多台设备上的多台相机提供准确的值。

他们只会确保他们预先安装的摄像头应用程序正常工作,并且测试了很少有重量级的第三方应用,比如Instagram和Snapchat。这些应用程序不使用的参数可能具有任意的值。

最后,我们会根据设备模型和版本号保留一个调整列表。有时类似的设备有类似的错误,有时则没有。有些bug是通过OTA更新修复的,而其他的bug则是在这样的更新中引入的。这些调整中的大多数都可以被推到设备上,而无需强制从PlayStore升级应用程序。

很抱歉没有给这个常见的麻烦开一粒神奇药丸。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57115158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档