Android Camera2 Optical Stablization

Viewed 448

I am developing android app for capturing videos and i am using camera2 api. I have troubles with optical stabilization option.

in one device with this data :

  • Model: SM-G950F
  • Product: dreamltexx
  • Brand: samsung
  • Device: dreamlte
  • Version-Release: 9

    characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION)

result is:

[LENS_OPTICAL_STABILIZATION_MODE_ON , LENS_OPTICAL_STABILIZATION_MODE_OFF]

but in the other device with this data:

  • Model: SM-G950W
  • Product: dreamqltevl
  • Brand: samsung
  • Device: dreamqltecan
  • Version-Release: 9

    characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION)

result is:

[LENS_OPTICAL_STABILIZATION_MODE_OFF, LENS_OPTICAL_STABILIZATION_MODE_OFF]

this is my stabilization method:

private fun chooseStabilizationMode(builder: CaptureRequest.Builder?) {
    val availableOpticalStabilization = characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION)
    if (availableOpticalStabilization != null) {
        for (mode in availableOpticalStabilization) {
            if (mode == CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_ON) {
                builder?.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_ON)
                builder?.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_OFF)
                showToast("Using optical stabilization.")
                return
            }
        }
    }

    // If no optical mode is available, try software.
    val availableVideoStabilization = characteristics.get(CameraCharacteristics.CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES)
    for (mode in availableVideoStabilization) {
        if (mode == CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_ON) {
            builder?.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE_ON)
            builder?.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_OFF)
            showToast("Using video stabilization.")
            return
        }
    }

    showToast("Stabilization not available.")
}

in the one S8 say “Using optical stabilization.” and the other S8 say "Stabilization not available."

anyone can help me to understand it?

Thanks in advance.

0 Answers
Related