How can I get the ID of the currently open android camera from an android camera instance? I can't see it in the parameters and getCameraInfo requires the id as a parameter.
The Camera ID is a UUID that the system assigns to each camera, usually in a format that looks similar to f93369eb-e530-27b7-78ba-16978cbd3061 . The Camera ID is preferred when performing API calls. It is also used for “devices” such as virtual camera instances, encoders, I/O units, etc.
↳ android.hardware.camera2.CameraManager. A system service manager for detecting, characterizing, and connecting to CameraDevices . For more details about communicating with camera devices, read the Camera developer guide or the camera2 package documentation.
There isn't a way to get the id of the currently open android camera. I ended up storing the id when I opened it.
It is just a number of the camera, so you loop through looking for the camera you want.
Here is a snippet to find the front-facing camera:
int cameraId = -1; int numberOfCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numberOfCameras; i++) { CameraInfo info = new CameraInfo(); Camera.getCameraInfo(i, info); if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { Log.d(DEBUG_TAG, "Camera found"); cameraId = i; break; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With