Reputation: 1997
I am using CameraX
in my application & want to use in build video stabilization feature but I don't know how to do that?
As it is documented in Camera.Parameters, There are 3 methods which we can use public void setVideoStabilization (boolean toggle)
, public boolean isVideoStabilizationSupported ()
and public boolean getVideoStabilization ()
for real time video stabilization but I didn't find any reference to use these functions in CameraX. If it is not possible with CameraX
then should I use Camera2
?
Upvotes: 5
Views: 1876
Reputation: 241
There is now a "proper" way to do this. Starting with version 1.4.0-alpha02
you can now configure stabilization via the VideoCapture builder:
val videoCapture = VideoCapture.Builder(output)
.setVideoStabilizationEnabled(true)
.build()
If you were using VideoCapture.withOutput(output)
before, you can replace this with the code snippet above as it's equivalent (minus the stabilization).
Upvotes: 1
Reputation: 11
Actually and technically you can do it with the latest CameraX. But you have to use the non-public (yet?) API for LIBRARY_GROUP only. Here is how I can disable stabilization in my app:
val configBuilder = Camera2ImplConfig.Builder()
configBuilder.setCaptureRequestOption(
CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE,
CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_OFF
)
configBuilder.setCaptureRequestOption(
CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE,
CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_OFF
)
...
...
//After you bound your use cases
(camera.cameraControl as Camera2CameraControlImpl).addInteropConfig(configBuilder.build())
Upvotes: 1
Reputation: 26
I think with cameraX you can not set these parameters, You need to use either camera-api
or camera2-api
Following is the way to use STABILIZATION
mode in Camera2
...
captureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
//Either of these two mode you can use one.
captureRequestBuilder.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, CameraMetadata.CONTROL_VIDEO_STABILIZATION_MODE_ON);
captureRequestBuilder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE,CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_ON);
You can find explanation of these mode here
Upvotes: 1