Camera2 API AutoFocus with Samsung S5

后端 未结 4 730
一生所求
一生所求 2020-12-28 21:30

I\'m working with the new Camera2 API on a Samsung S5. The supported hardware level this device is reporting is LEGACY, which is fine.

However, I canno

4条回答
  •  醉话见心
    2020-12-28 22:17

    The Samsung S5 with autofocus returned INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, which means it does not support Camera2 api.

    I have the below filter for using camera in my application.

    if (Build.VERSION.SDK_INT >= 21 && isDeviceCompatibleOfCamera2()) {
     // Use camera2
    } else {
     // Use old camera
    }
    
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
     public boolean isDeviceCompatibleOfCamera2() {
     try {
        CameraManager manager = (CameraManager) getActivity().getSystemService(Context.CAMERA_SERVICE);
        String backCameraId = manager.getCameraIdList()[0];
        CameraCharacteristics backCameraInfo = manager.getCameraCharacteristics(backCameraId);
    
        int level = backCameraInfo.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
        return level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL;
    
        } catch (CameraAccessException e) {
         ETLog.d(TAG, "Device not compatible of camera2 api" + e);
        }
        return false;
     }
    

提交回复
热议问题