val imageCaptureConfig = ImageCaptureConfig.Builder().apply {
setLensFacing(CameraX.LensFacing.FRONT)
setCaptureMode(CaptureMode.MAX_QUALITY)
setBufferFormat(ImageFormat.YUV_420_888)
setTargetResolution(Size(3264, 2448))
// We request aspect ratio but no resolution to match preview config but letting
// CameraX optimize for whatever specific resolution best fits requested capture mode
setTargetAspectRatio(Rational(3,4))
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
setTargetRotation(viewFinder.display.rotation)
}.build()
imageCapture.takePicture(object : ImageCapture.OnImageCapturedListener() {
override fun onCaptureSuccess(image: ImageProxy?, rotationDegrees: Int) {
println("captureSuccess h: ${image?.height} w: ${image?.width}")
}
override fun onError(imageCaptureError: ImageCapture.ImageCaptureError, message: String, cause: Throwable?) {
println(message)
}
})
Above is the code I set for capture image from Samsung S8 US version, I want to have YUV format with max output resolution which is 3264*2448. However, the result I got is 1440*1080 instead. I tried on S9, and S8 asian version, the code works fine on both phones. It is strange, when I set the format to JPEG it will work on this phone.
and I tried on S7 and pixel 2 as well, pixel 2 can output YUV at the max supported resolution (not the code above), but S7 cannot, also giving me 1080*1440 instead.
Is this a CameraX bug? If it is, is there any work around besides using back to Camera2?
Thanks!