Reputation: 474
I am trying to analyse the image using CameraX. Some devices with a wide-angle camera do not provide proper images. The image in the analyser is entirely different from the image in the preview. I am using an aspect ratio of 4:3 in both the preview and image analyser. I am cropping the image based on the cropRect coming from the image proxy.
Please see the code snippet for the image analyser below. This issue can be reproduced on Samsung A23 devices.
val myPreview = Preview.Builder().setTargetAspectRatio(AspectRatio.RATIO_4_3)
.build().also {
it.setSurfaceProvider(myPreviewView.surfaceProvider)
}
val myImageAnalyzer = ImageAnalysis.Builder()
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
.build()
.also {
it.setAnalyzer(executer, MyImageAnalyser() { result ->
})
}
val myPreview = Preview.Builder().setTargetResolution(Size(1280, 720))
.build().also {
it.setSurfaceProvider(myPreviewView.surfaceProvider)
}
val myImageAnalyzer = ImageAnalysis.Builder()
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.setTargetResolution(Size(1280, 720))
.build()
.also {
it.setAnalyzer(executer, MyImageAnalyser() { result ->
})
}
Upvotes: 1
Views: 305