Home:ALL Converter>Android: How can I check if a device has Camera2 api features implemented or not?

Android: How can I check if a device has Camera2 api features implemented or not?

Ask Time:2015-06-21T14:13:40         Author:Vivek Sasidharan

Json Formatter

Well, how can I check if an android device has Camera2 api features implemented or not? There are many new features in camera2 api such as manual controls. So how can I know whether, which Camera2 api features are implemented or not, programmatically?

Author:Vivek Sasidharan,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30961802/android-how-can-i-check-if-a-device-has-camera2-api-features-implemented-or-not
SpiralDev :

In cases if someone needs full snippet of how to determine which camera in the device has Camera2 API support (at least limited support):\n\n@TargetApi(Build.VERSION_CODES.LOLLIPOP)\n public boolean allowCamera2Support(int cameraId) {\n CameraManager manager = (CameraManager)getSystemService(Context.CAMERA_SERVICE);\n try {\n String cameraIdS = manager.getCameraIdList()[cameraId];\n CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraIdS);\n int support = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);\n\n if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY )\n Log.d(TAG, \"Camera \" + cameraId + \" has LEGACY Camera2 support\");\n else if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED )\n Log.d(TAG, \"Camera \" + cameraId + \" has LIMITED Camera2 support\");\n else if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL )\n Log.d(TAG, \"Camera \" + cameraId + \" has FULL Camera2 support\");\n else\n Log.d(TAG, \"Camera \" + cameraId + \" has unknown Camera2 support?!\");\n\n return support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED || support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL;\n }\n catch (CameraAccessException e) {\n e.printStackTrace();\n }\n return false;\n }\n\n @TargetApi(Build.VERSION_CODES.LOLLIPOP)\n private void checkCamera2Support() {\n if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {\n int numberOfCameras = 0;\n CameraManager manager = (CameraManager)getSystemService(Context.CAMERA_SERVICE);\n\n try {\n numberOfCameras = manager.getCameraIdList().length;\n } catch (CameraAccessException e) {\n e.printStackTrace();\n } catch(AssertionError e) {\n e.printStackTrace();\n }\n\n if( numberOfCameras == 0 ) {\n Log.d(TAG, \"0 cameras\");\n }else {\n for (int i = 0; i < numberOfCameras; i++) {\n if (!allowCamera2Support(i)) {\n Log.d(TAG, \"camera \" + i + \" doesn't have limited or full support for Camera2 API\");\n }else{\n // here you can get ids of cameras that have limited or full support for Camera2 API\n }\n }\n }\n }\n }\n",
2016-10-16T10:24:54
StMulligan :

Install the app: Manual Camera Compatibility. It checks for Manual Focus, WB, ISO, Shutter speed and RAW support. All exposed via the camera2 HAL driver. I've installed the above in the AT&T store to check phones before buying. A great way to know if you're buying yesterday's model.\n\nhttps://play.google.com/store/apps/details?id=pl.vipek.camera2_compatibility_test&hl=en",
2016-02-04T20:01:39
Pgo :

Install the App A Better Camera. You'll be able tout check if it is full, legacy, limited or mot supporter.\nThat's how I found Samsung galaxy Tab 3 SMT820 iscamera2 api full.",
2017-05-22T21:36:42
user2924714 :

Indeed, the camera2 api is only supported from API level 21. But only this check is not enough. There are devices with API level 21, but that support the camera 2 only partially. To check this, you should check the value of CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL. It can be FULL, LEGACY or LIMITED.\nCheck here for details: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html\n\nHere is how to get it:\n\nCameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);\n\nfor (String cameraId : manager.getCameraIdList()) {\n CameraCharacteristics characteristics\n = manager.getCameraCharacteristics(cameraId);\n\n\n Log.d(\"Img\", \"INFO_SUPPORTED_HARDWARE_LEVEL \" + characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL));\n }\n",
2015-07-06T08:19:44
rcsumner :

Actually, checking for API version 21+ will work. The camera2 API, including CameraManager is part of the system, not dependent on the hardware present. So you can always ask the CameraManager for a list of CameraDevices, which you can then query individually.\n\nHowever, I think what you actually mean is \"how can I tell if I can set photographic parameters manually using the camera2 API?\", which is dependent on the device you have. It depends on what control you need, but the information you need can be gleaned by getting the REQUEST_AVAILABLE_CAPABILITIES metadata field. Hint: look for MANUAL_SENSOR.",
2015-06-21T16:54:08
TobiasWeis :

I also needed this for another project, so I wrote a small app that probes all camera2 features and shows which ones are available on the phone: https://play.google.com/store/apps/details?id=de.weis.camera2probe\n\nYou can email this report in-app. I list all reports that I received here: https://github.com/TobiasWeis/android-camera2probe/wiki\n(The code of the app is also available there, in case someone needs to integrate into their own project)",
2016-12-29T18:34:30
yy