Preview freeze when setting resolution strategy for ImageAnalysis on Samsung SM-A057G

88 views
Skip to first unread message
Assigned to charco...@google.com by wuj...@google.com

Anton Ivanov

unread,
Sep 4, 2024, 1:30:39 PMSep 4
to Android CameraX Discussion Group
Hello,
I'm trying to use Preview + Video + ImageAnalysis and in general it works. 
Unfortunately on SM-A057G when doing this:
setResolutionSelector(
ResolutionSelector
.Builder()
.setResolutionStrategy(
ResolutionStrategy(Size(720, 1280), ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER)
).build()
)
something gets broken, preview freezes and no analysis frames are emitted.
If I change size to Size(480, 720) or don't set strategy at all it works as expected, however it seems that freezing is not intended behaviour as API documentation states that the strategy will return supported resolution.
Use case group is set up like this:
UseCaseGroup
.Builder()
.setViewPort(preview.getViewPort())
.addUseCase(preview.useCase())
.addUseCase(videoCapture.useCase())
.addUseCase(imageAnalysis.useCase())
.build()

Charcoal Chen

unread,
Sep 4, 2024, 10:36:15 PMSep 4
to Anton Ivanov, Android CameraX Discussion Group
Hi,

Could you help to provide the following info?
1. Is there an IllegalArgumentException thrown when the issue happens? If yes, please provide us what the message and stack trace is.
2. If no IllegalArgumentException is thrown, please let us know what is the selected resolution for each UseCase. Sometimes, some devices might have some problems on some specific stream sizes or combinations.
3. What is the camera hardware level of the target camera? (INFO_SUPPORTED_HARDWARE_LEVEL)
4. Is it possible to provide the bugreport so that we can check whether any other problems happen?

One thing related to the bound size of the ResolutionStrategy to mention. The ResolutionSelector tries to select the best resolution from available resolutions obtained from the getOutputSizes method from the stream configuration map. Generally, the output sizes are expressed in landscape orientation. Therefore, the bound size you want to specify on the SM-A057G device should be Size(1280, 720) or Size(720, 480). You will also need to specify a matching AspectRatioStrategy (RATIO_16_9_FALLBACK_AUTO_STRATEGY for Size(1280, 720)). Otherwise, ResolutionSelector's default AspectRatioStrategy is 4:3. The 4:3 output size closest to Size(1280, 720) will be selected for your current setting.



CONFIDENTIAL

This  e-mail  and  any  attachments  are  confidential  and  intended  solely  for  the  addressee  and  may  also  be privileged or exempt from disclosure under applicable law. If you are not the addressee, or have received this e-mail in error, please notify the sender immediately, delete it from your system and do not copy, disclose or otherwise act upon any part of this e-mail or its attachments. Internet communications are not guaranteed to be secure or virus-free. Revolut does not accept responsibility for any loss arising from unauthorised access to, or interference with, any Internet communications by any third party, or from the transmission of any viruses. Replies to this e-mail may be monitored by Revolut for operational or business reasons. Any  opinion  or  other  information  in  this  e-mail  or  its  attachments  that  does  not  relate  to  the  business  of Revolut is personal to the sender and is not given or endorsed by Revolut. Registered  Office: 7  Westferry  Circus,  Canary  Wharf, London,  E14  4HD,  United  Kingdom.  Main  Office: 7 Westferry  Circus,  Canary  Wharf, London,  E14  4HD, United  Kingdom. Revolut  Ltd  is  authorised  and regulated by the Financial Conduct Authority under the Electronic Money Regulations 2011, Firm Reference 900562.

--
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/452fb486-a3f4-4bfd-8275-e777e6096328n%40android.com.

Anton Ivanov

unread,
Sep 5, 2024, 10:32:43 AMSep 5
to Android CameraX Discussion Group, charco...@google.com, Android CameraX Discussion Group, Anton Ivanov
Hi,

1. No exception is thrown
2. Resolutions are: Preview = 570x1266, Video = 1266x570, Analysis = 1920x1440

3. Reported as LEVEL_3

4. Didn't quite get this


Thanks for your advice, I tried it with landscape resolution and it started working.


Anton Ivanov

unread,
Sep 5, 2024, 2:56:15 PMSep 5
to Android CameraX Discussion Group, Anton Ivanov, charco...@google.com, Android CameraX Discussion Group
Follow up,
You said that w > h generally. How many known exceptions are there for this case?

Charcoal Chen

unread,
Sep 6, 2024, 5:46:30 AMSep 6
to Anton Ivanov, Android CameraX Discussion Group
For "4. Didn't quite get this", this means to use "adb bugreport" command to dump the log files when the issue happens. Maybe the capture session can't be configured successfully for some specific stream/resolution combination on the device. We might be able to get some info from the log file.

For "You said that w > h generally.", I do not have the number, but as I know, about 150 devices in our lab are w > h. Precisely, apps can check the camera sensor size or the output sizes to have the correct setting. I will add more descriptions in javadoc for this.

For this issue, I guess that the device might have some problem with the UseCases combination when ImageAnalysis' resolution is 1920x1440 or some other sizes.

We do not have the SM-A057G device. Can you help to retrieve the supported output sizes via getOutputSizes and set a ResolutionSelector with ResolutionFilter to check which output sizes can cause the problem? Then, I can create a quirk based on the checking results to not use those problematic output sizes for the device.

The sample code is:

  ImageAnalysis imageAnalysis = new ImageAnalysis.Builder().setResolutionSelector(

            new ResolutionSelector.Builder().setResolutionFilter(

                    new ResolutionFilter() {

                        @NonNull

                        @Override

                        public List<Size> filter(

                                @NonNull List<Size> supportedSizes,

                                int rotationDegrees) {

                            return Collections.singletonList($OUTPUT_SIZE);

                        }

                    }

            ).build()

    ).build();


Thanks.


Anton Ivanov

unread,
Sep 10, 2024, 11:27:35 AMSep 10
to Android CameraX Discussion Group, charco...@google.com, Android CameraX Discussion Group, Anton Ivanov
Hi,
this method
fun Camera.getSupportedResolutions(): List<Size> {
val camera2Info = Camera2CameraInfo.from(cameraInfo)
val configs = checkNotNull(camera2Info.getCameraCharacteristic(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP))
val resolutions = configs.getOutputSizes(
ImageFormat.YUV_420_888)
return resolutions.toList()
}

returned this
Screenshot 2024-09-10 at 16.25.54.png
I haven't tried them yet as it takes some time but it definetely contains problematic resolution: 1920x1440

Charcoal Chen

unread,
Sep 10, 2024, 11:02:47 PMSep 10
to Android CameraX Discussion Group, anton....@revolut.com, Charcoal Chen, Android CameraX Discussion Group
Hi,

Thanks for the update.

I have created https://issuetracker.google.com/issues/365877975 to track this issue. Once you get the testing results, please update to the buganizer issue.

Anton Ivanov

unread,
Sep 11, 2024, 7:45:35 AMSep 11
to Android CameraX Discussion Group, charco...@google.com, Anton Ivanov, Android CameraX Discussion Group
Hi,
Just checked the resolutions. Everything in the resolution array A with i <= 6 fails to initialize.

Reply all
Reply to author
Forward
0 new messages