问题
Is there any way to detect whether the given camera is regular camera or wide angle camera?
With devices like Oppo, Vivo, LG, etc. they provide the access to each of their camera using Camera2 API. but how to know which camera is primary camera and which camera is wide angle camera?
回答1:
You can calculate the field of view of each camera, and decide if it's wide enough to count.
The standard formula for horizontal field of view in degrees is:
FOV = 2 * arctan(sensor_width / (2 * lens_focal_length) )
and for the vertical FOV, use the sensor height.
From the camera2 API, the focal length is listed in AVAILABLE_FOCAL_LENGTHS and the sensor physical dimensions in PHYSICAL_SIZE.
If you want to be completely accurate about it, you should also factor in the active array, which is the subset of the physical pixel array that is actually used to produce an image. But that's usually only a few rows of pixels out of thousands. But if you want to take it into account, you'll want something like:
active_width = sensor_width * active_array_width / pixel_array_width
to calculate the FOV with. Also, sometimes the FOV reported is the diagonal one, in which case the sensor dimension you want is
sensor_diagonal = sqrt(sensor_width^2 + sensor_height^2)
There's no single definition for what counts as a wide-angle camera, especially since most mobile device cameras are already in the 65-75 degree FOV range.
The Samsung S8 front camera has an 80 degree FOV, and Samsung calls it 'wide selfie', while the back camera has a 77 degree FOV. But not sure if these are horizontal or diagonal FOVs.
来源:https://stackoverflow.com/questions/47929422/how-to-check-whether-given-camera-is-regular-camera-or-wide-angle-camera