CameraX OS 10 out of Bound

28 views
Skip to first unread message

manika...@ivymobility.com

unread,
Sep 11, 2023, 10:44:28 AM9/11/23
to Android CameraX Discussion Group
Hi,
      I am using Camerax API for image capturing. PreviewView Android 10 is extending outside the bounds, see the below screenshot before and after image capture.
And try the scaletype for ,
//if using this top portion aligned properly
viewFinder!!.scaleType = PreviewView.ScaleType.FILL_START
//if using this bottom portion aligned properly
 viewFinder!!.scaleType = PreviewView.ScaleType.FILL_END  

 how to use both scale type or any other options are available.


Code snippet

val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
            val preview = Preview.Builder()
                //.setTargetResolution(Size(frame_rect!!.width, frame_rect!!.height))
                .build()
                .also {
                    it.setSurfaceProvider(viewFinder!!.surfaceProvider)
                }
            imageCapture = ImageCapture.Builder().build()

             
            val imageAnalysis = ImageAnalysis.Builder()
                .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
                .build()
            imageAnalysis.setAnalyzer(cameraExecutor, ImageAnalysis.Analyzer { image ->
                Log.d("IVYCAMERA", "Captured Image...!!!")
                // insert your code here.
            })
           
            val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

            try {
                // Unbind use cases before rebinding
                cameraProvider.unbindAll()
                 
                camera = cameraProvider.bindToLifecycle(
                    this, cameraSelector, imageAnalysis, preview, imageCapture
                )
            } catch (exc: Exception) {
                Log.e(TAG, "Use case binding failed", exc)
            }

        }, Co

beforecapture.png

aftercapture.png

Xi Zhang (张熹)

unread,
Sep 11, 2023, 11:31:56 AM9/11/23
to manika...@ivymobility.com, Android CameraX Discussion Group
Does it only happen on Android 10, not other versions? Are both the images screenshots for preview, or is the second one a capture image? If you are looking for a WYSIWYG effect across preview and image capture, I would suggest using the CameraController API. You can find a code sample here.

Otherwise, if you can upload a minimal reproducible example to GitHub, I can take a look.

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/1cdd9ebe-5815-4989-853f-5238220fff45n%40android.com.

Manikandan R

unread,
Sep 12, 2023, 1:40:53 AM9/12/23
to Xi Zhang (张熹), Android CameraX Discussion Group
Hi, Xi Zhang
                    Thanks for the reply.
 
Does it only happen on Android 10, not other versions?- All the device, I have Android 10 just now check other device.

Are both the images screenshots for preview, or is the second one a capture image?
First one previewView and second one captured image(after taking photo).

Yes, I am looking  WYSIWYG effect across preview and image capture.

GitHub Link: https://github.com/saecmca/Burstimage
                  




Thanks & Regards,
R. Manikandan

Xi Zhang (张熹)

unread,
Sep 12, 2023, 5:36:08 PM9/12/23
to Manikandan R, Android CameraX Discussion Group
If it's WYSIWYG you are looking for, you need to either use LifecycleCameraController or UseCaseGroup. (LifecycleCameraController is a high level API that uses UseCaseGroup internally)

Once they are used, the image saved will be cropped to match the visible rect of PreviewView.
Reply all
Reply to author
Forward
0 new messages