gpt4 book ai didi

android - Camera 2 CameraCharacteristics 似乎显示不正确的数据

转载 作者:行者123 更新时间:2023-12-04 01:41:49 25 4
gpt4 key购买 nike

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

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 将其添加到示例中:

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

我得到了华为 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 倍变焦和 the documentation says LENS_INFO_AVAILABLE_FOCAL_LENGTHS 参数的获取将为支持光学变焦的相机返回一个长于 1 的数组。华为 P30 Pro 也有一个超广角相机,据我了解,LENS_RADIAL_DISTORTION 应该返回一些不同于 0 的其他参数。

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

我的问题是:这是怎么回事?为什么我得到的所有这些数据与应显示的内容不一致?我对应该显示的内容的理解以及我的示例是否错误?

最佳答案

这个观察很悲伤也很真实。从第一天起,错误报告就一直困扰着 Android 相机。多家制造商没有足够的动力为他们在多台设备上安装的多台相机提供准确的值。

他们只会确保预装的相机应用正常运行,并测试一些重量级的第 3 方应用,例如 Instagram 和 Snapchat。这些应用未使用的参数可能具有任意值。

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

很抱歉没有解决这个常见问题的 Elixir 。

关于android - Camera 2 CameraCharacteristics 似乎显示不正确的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57115158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com