When using ZERO_SHUTTER_LAG on a Pixel 8 Pro some unexpected cropping occurs when capturing images.
The issue is not encountered using the same implementation on a Samsung S20 5G.
Important to note is that the Pixel does not support ZSL (i.e. isZslSupported() returns false) while it is on the Samsung.
However when using either CAPTURE_MODE_MINIMIZE_LATENCY (which should be the fallback mode when ZERO_SHUTTER_LAG is not supported) or CAPTURE_MODE_MAXIMIZE_QUALITY, cropping does not occur on the Pixel.
I managed to replicate the issue using the the CameraXBasic sample on Github (with some modifications, mainly in the form of updating dependencies to allow using ZSL). Happy to share a version of that if needed but below is probably the most relevant part of the code:
// Preview
preview = Preview.Builder()
.build()
// ImageCapture
imageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_ZERO_SHUTTER_LAG)
.setTargetRotation(rotation)
.setFlashMode(ImageCapture.FLASH_MODE_OFF)
.build()
// ImageAnalysis
imageAnalyzer = ImageAnalysis.Builder()
.setTargetRotation(rotation)
.build()
// The analyzer can then be assigned to the instance
.also {
it.setAnalyzer(cameraExecutor, LuminosityAnalyzer { luma ->
// Values returned from our analyzer are passed to the attached listener
// We log image analysis results here - you should do something useful
// instead!
Log.d(TAG, "Average luminosity: $luma")
})
}
A quick fix on my end would be to query whether ZSL is supported and change capture mode accordingly rather than rely on the fallback but the behavior I described above makes me wonder if there's anything I'm missing?
Thanks!