那么,如何检查Android设备是否已实现Camera2 api功能? camera2 api中有许多新功能,例如手动控制。那么我如何能够以编程方式知道是否实现了哪些Camera2 api功能?
答案 0 :(得分:24)
事实上,camera2 api仅支持API级别21.但只有这种检查是不够的。有些级别为21的设备,但仅部分支持摄像头2。要检查这一点,您应该检查CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL的值。它可以是FULL,LEGACY或LIMITED。 点击此处查看详细信息:https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html
以下是如何获得它:
CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
for (String cameraId : manager.getCameraIdList()) {
CameraCharacteristics characteristics
= manager.getCameraCharacteristics(cameraId);
Log.d("Img", "INFO_SUPPORTED_HARDWARE_LEVEL " + characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL));
}
答案 1 :(得分:6)
实际上,检查API版本21+将起作用。 camera2 API(包括CameraManager
)是系统的一部分,不依赖于硬件。因此,您随时可以向CameraManager
询问CameraDevice
的列表,然后您可以单独查询。
但是,我认为你的实际意思是“如何使用camera2 API手动设置摄影参数?”, 依赖于您拥有的设备。这取决于您需要什么样的控制,但是获取REQUEST_AVAILABLE_CAPABILITIES
metadata field可以收集您需要的信息。提示:寻找MANUAL_SENSOR
。
答案 2 :(得分:5)
我还需要这个用于另一个项目,所以我写了一个小应用程序,探测所有camera2功能,并显示手机上有哪些功能:https://play.google.com/store/apps/details?id=de.weis.camera2probe
您可以在应用内通过电子邮件发送此报告。我列出了我在此收到的所有报告:https://github.com/TobiasWeis/android-camera2probe/wiki (应用程序的代码也可以在那里使用,以防有人需要集成到他们自己的项目中)
答案 3 :(得分:2)
如果有人需要完整的片段,说明如何确定设备中哪个摄像头具有Camera2 API支持(至少有限的支持):
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public boolean allowCamera2Support(int cameraId) {
CameraManager manager = (CameraManager)getSystemService(Context.CAMERA_SERVICE);
try {
String cameraIdS = manager.getCameraIdList()[cameraId];
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraIdS);
int support = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY )
Log.d(TAG, "Camera " + cameraId + " has LEGACY Camera2 support");
else if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED )
Log.d(TAG, "Camera " + cameraId + " has LIMITED Camera2 support");
else if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL )
Log.d(TAG, "Camera " + cameraId + " has FULL Camera2 support");
else
Log.d(TAG, "Camera " + cameraId + " has unknown Camera2 support?!");
return support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED || support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL;
}
catch (CameraAccessException e) {
e.printStackTrace();
}
return false;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void checkCamera2Support() {
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
int numberOfCameras = 0;
CameraManager manager = (CameraManager)getSystemService(Context.CAMERA_SERVICE);
try {
numberOfCameras = manager.getCameraIdList().length;
} catch (CameraAccessException e) {
e.printStackTrace();
} catch(AssertionError e) {
e.printStackTrace();
}
if( numberOfCameras == 0 ) {
Log.d(TAG, "0 cameras");
}else {
for (int i = 0; i < numberOfCameras; i++) {
if (!allowCamera2Support(i)) {
Log.d(TAG, "camera " + i + " doesn't have limited or full support for Camera2 API");
}else{
// here you can get ids of cameras that have limited or full support for Camera2 API
}
}
}
}
}
答案 4 :(得分:0)
安装应用程序:手动相机兼容性。它检查手动聚焦,WB,ISO,快门速度和RAW支持。全部通过camera2 HAL驱动程序曝光。我已经在AT&amp; T商店安装了上述产品,以便在购买之前检查手机。了解你是否购买了昨天的模特的好方法。
https://play.google.com/store/apps/details?id=pl.vipek.camera2_compatibility_test&hl=en
答案 5 :(得分:0)
安装应用程序更好的相机。您将能够检查它是否是完整的,遗留的,有限的或mot支持者。 这就是我发现三星Galaxy Tab 3 SMT820 iscamera2 api的全部内容。
答案 6 :(得分:-1)
相机API2
Camera API2框架向应用程序公开了较低级别的相机控制,包括有效的零拷贝连拍/流传输以及曝光,增益,白平衡增益,颜色转换,降噪,锐化等更多的按帧控制。有关详细信息,请观看Google I / O视频概述。
Android 5.0及更高版本包含Camera API2;但是,运行Android 5.0及更高版本的设备可能不支持所有Camera API2功能。应用程序可以通过Camera API2界面查询的android.info.supportedHardwareLevel属性报告以下支持级别之一:
LEGACY: These devices expose capabilities to apps through the Camera API2 interfaces that are approximately the same capabilities as those exposed to apps through the Camera API1 interfaces. The legacy frameworks code conceptually translates Camera API2 calls into Camera API1 calls; legacy devices do not support Camera API2 features such as per-frame controls.
LIMITED: These devices support some Camera API2 capabilities (but not all) and must use Camera HAL 3.2 or later.
FULL: These devices support all of major capabilities of Camera API2 and must use Camera HAL 3.2 or later and Android 5.0 or later.
LEVEL_3: These devices support YUV reprocessing and RAW image capture, along with additional output stream configurations.
EXTERNAL: These devices are similar to LIMITED devices with some exceptions; for example, some sensor or lens information may not be reported or have less stable frame rates. This level is used for external cameras such as USB webcams.
此What is Camera2 API? Check if your Smartphone supports it可以帮助您找出答案!