How to get horizontal viewAngle of current camera.

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

Dante Zhang

unread,
Sep 29, 2020, 12:37:37 AM9/29/20
to Android CameraX Discussion Group
From Camera API (Link), we can get the horizontal view angle or the FOV.

Where I can get it from CameraX library (and I don't know how to get it from Camera2 API as well).

tonyt...@google.com

unread,
Sep 29, 2020, 2:59:04 AM9/29/20
to Android CameraX Discussion Group, dante...@manfrotto.com
Hello,
Thanks for the question. Unfortunately there's no direct API to get it through CameraX (neither through Camera2 from my understanding). For basic usage it could be calculated with SENSOR_INFO_PHYSICAL_SIZE and LENS_FOCAL_LENGTH. Here is a stackoverflow post that you may find more information.

Dante Zhang

unread,
Sep 29, 2020, 3:54:10 AM9/29/20
to Android CameraX Discussion Group, tonyt...@google.com, Dante Zhang
OK, , but it seems we can't get SENSOR_INFO_PHYSICAL_SIZE and LENS_FOCAL_LENGTH from CameraX, we have to get them from CameraManager in the Camera2 API, right?

tonyt...@google.com

unread,
Sep 29, 2020, 4:50:17 AM9/29/20
to Android CameraX Discussion Group, dante...@manfrotto.com, tonyt...@google.com
Yes. Also we are adding new experimental API Camera2CameraInfo#getCameraCharacteristic, which allows you to get it from a CameraInfo. Please note that the APIs are still under review and are subjected to change.

Dante Zhang

unread,
Nov 16, 2020, 9:40:17 PM11/16/20
to Android CameraX Discussion Group, tonyt...@google.com, Dante Zhang
Does CameraX contain these APIs right now? I mean in the latest Beta version?

Another question is how we can get the current Focal Length, because LENS_FOCAL_LENGTH need to be applied to get the focal length after the CaptureSession is done, but we can't have any CaptureSession in CameraX.

So how we can grab the Focal Length when showing the Preview of CameraX?

TY Chang

unread,
Nov 17, 2020, 2:14:08 AM11/17/20
to Android CameraX Discussion Group, dante...@manfrotto.com, TY Chang
Yes it's in current release, just it's marked as Experimental for now.

For setting LENS_FOCAL_LENGTH, there's another experimental API Camera2Interop which allows applying Camera2 options to use case. Typical use may looks like
        Camera2Interop.Extender(useCaseConfigBuilder).setCaptureRequestOption(LENS_FOCAL_LENGTH, focalLength)

If it's a fixed lens, there should be only one value in LENS_INFO_AVAILABLE_FOCAL_LENGTHS and doesn't require setting of LENS_FOCAL_LENGTH.

Dante Zhang

unread,
Nov 17, 2020, 5:55:33 PM11/17/20
to Android CameraX Discussion Group, tonyt...@google.com, Dante Zhang
That looks good.

Another question is how we can change the zoom level from CameraX API? And if we are able to change it, and the focal length will be changed? How we can get the current value?

Scott Nien

unread,
Nov 18, 2020, 1:28:41 AM11/18/20
to Dante Zhang, Android CameraX Discussion Group, tonyt...@google.com
You can use camera.getCameraControl().setZoomRatio() API to change the zoom level. 
Currently on android 11 devices,  CameraX will use camera2 CONTROL_ZOOM_RATIO (and use SCALER_CROP_REGION for pre-android 11 devices).  On some android 11 devices like pixel 4a(5G) and pixel 5, CameraX app will switch wide-angle and tele-photo lenses automatically (focal length will be changed) depending on the zoom ratio.  But for other devices, it really depends whether or not they implement it or not.   

You can hook your capture result callback via Camera2Interop.Extender(useCaseConfigBuilder).setSessionCaptureCallback to check the current LENS_FOCAL_LENGTH

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/a3f8f2f9-0589-45b1-abef-c8a09ff37fd6n%40android.com.
Reply all
Reply to author
Forward
0 new messages