Search code examples
androidandroid-camerax

How to set Video Stabilisation parameter in CameraX?


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?


Solution

  • 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