Android Camera2 not getting physical cameras

4.3k views Asked by At

I am working on a React Native package to get information about the cameras on an Android device. The issue is that not all the cameras are showing up.

My code is the following:

try {
    Context context = getReactApplicationContext();
    CameraManager cameraManager = (CameraManager)context.getSystemService(Context.CAMERA_SERVICE);

    for (String cameraId : cameraManager.getCameraIdList()) {
        CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);

        Set<String> physicalCameraIds = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
            physicalCameraIds = cameraCharacteristics.getPhysicalCameraIds();
        }

        Log.d(TAG, "logic ID: " + cameraId + " Physics under ID: " + Arrays.toString(physicalCameraIds.toArray()));

        int[] capabilities = cameraCharacteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
        Log.d(TAG, Arrays.toString(capabilities));
    }

} catch(Exception e) {
    promise.reject("Error", e);
}

This piece of code returns the following:

D/Debug: logic ID: 0 Physics under ID: []
D/Debug: [0, 9, 3, 7, 4, 5, 1, 6, 2]

D/Debug: logic ID: 1 Physics under ID: []
D/Debug: [0, 3, 5, 1, 6, 2]

This suggests that it is missing the REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA. However the phone I am testing this on has 3 back cameras and 1 front facing camera. What am I missing?

1

There are 1 answers

0
Eddy Talvala On BEST ANSWER

Unfortunately, not all manufacturers support the logical camera APIs, even when they ship a camera cluster. Until they do, it may not be possible to directly access the physical cameras.

Sometimes, there's not automatic switching on zoom either, so you are stuck with just the regular FOV camera entirely.

Most of these devices have OEM-specific ways to access all the cameras, but those vary by device, and may not be accessible to regular apps at all.