Ho can i know cameraInfo of physical camera.

62 views
Skip to first unread message
Assigned to tonyt...@google.com by wuj...@google.com

Giuseppe Sorce

unread,
Mar 26, 2024, 4:49:32 AMMar 26
to Android CameraX Discussion Group
Ok i have this code:

val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager val cameraIdList = cameraManager.cameraIdList cameraIdList.forEach { id -> val characteristics: CameraCharacteristics = cameraManager.getCameraCharacteristics(id) val cameraCapabilities = characteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES) val hasMultiLogicalCamera = cameraCapabilities?.contains( CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA ) ?: false

 Now i know if smartphone has physical camera. I need if smaryphone has ultra wide and tele sensor camera.

al ids = characteristics.physicalCameraIds ids.forEach { idCamera -> val characteristicsCameraLogical = cameraManager.getCameraCharacteristics(idCamera) val focalLengths = characteristicsCameraLogical.get( CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS ) ?: floatArrayOf(0F)

tonyt...@google.com

unread,
Mar 27, 2024, 3:52:26 AMMar 27
to Android CameraX Discussion Group, giusepp...@warpmobile.it
The FOV of a camera can be calculated with focal length and sensor size. You may reference to the SO post for more information.

After getting the FOV of each physical camera, compare it with the FOV of the logical camera. If it's larger, it can be considered a wide-angle, otherwise telephoto.

Giuseppe Sorce

unread,
Mar 28, 2024, 2:53:34 AMMar 28
to tonyt...@google.com, Android CameraX Discussion Group
I'm trying this code:

    private fun calculateFOV(characteristics: CameraCharacteristics): Fov {
        var fov = Fov()
        try {

            val maxFocus =
                characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS)
            val size = characteristics.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE)
            val w = size!!.width
            val h = size!!.height
            val horizonalAngle = (2 * atan((w / (maxFocus!![0] * 2)).toDouble())).toFloat()
            val verticalAngle = (2 * atan((h / (maxFocus!![0] * 2)).toDouble())).toFloat()
            fov.orizonalAngle = horizonalAngle
            fov.verticalAngle = verticalAngle

        } catch (e: CameraAccessException) {
            e.printStackTrace()
        }
        return fov
    }

and this log on my Pixel 8Pro .  I found 7 camera id.  1 -> is front camera, 0 -> back camera 
physical camera  2 is the logical camera but i have two physical camera larger than logical camera and other 2 minor... 

   camera id back 0
   fovMain horizonalAngle  1.2342335 verticalAngle 0.98135835
   idCamera physical : 2
   fovCameraId[2] horizonalAngle  1.2342335 verticalAngle 0.98135835

   idCamera physical : 3
   fovCameraId[3] horizonalAngle  1.9243414 verticalAngle 1.6441976
   idCamera physical : 4
   fovCameraId[4] horizonalAngle  0.3110672 verticalAngle 0.23412466
   idCamera physical : 5
   fovCameraId[5] horizonalAngle  0.68185824 verticalAngle 0.52207065
   idCamera physical : 6
   fovCameraId[6] horizonalAngle  0.15647992 verticalAngle 0.11746475




Giuseppe Sorce | Mobile Developer
  skype pepigno75
 




tonyt...@google.com

unread,
Mar 28, 2024, 3:25:54 AMMar 28
to Android CameraX Discussion Group, giusepp...@warpmobile.it, Android CameraX Discussion Group, tonyt...@google.com
Do you mean camera [2 ~ 6] all belong to camera 0? IIRC, the Pixel 8 pro back camera contains three lenses. However, the manufacturer could create multiple cameras for a single lens in order to achieve different feature/configuration.

Giuseppe Sorce

unread,
Mar 28, 2024, 3:29:13 AMMar 28
to tonyt...@google.com, Android CameraX Discussion Group
Ok but how can i know what is ultra wide camera ? i found 2 physical camera with angle less the logical camera.

tonyt...@google.com

unread,
Mar 28, 2024, 3:51:08 AMMar 28
to Android CameraX Discussion Group, giusepp...@warpmobile.it, Android CameraX Discussion Group, tonyt...@google.com
Both cameras should give you an ultra-wide view (wider than the default camera) intrinsically. I think they are based on the same ultra-wide lens with different configuration.
Reply all
Reply to author
Forward
0 new messages