how to use ResolutionSelector with ResolutionStrategy instead of setTargetResolution() in AndroidStudio?
Asked Answered
E

2

7

First of all, I ask for your understanding of the rudimentary question.

I want to get image from camera input and analysis it. but I have a problem to set image resolution. What i know for set format of getting image is the 'ImageAnalysis.Build().setTargetResolution()' function that was deprecated... so I have to use ResolutionSelector with ResolutionStrategy. but I don't know how to use it. Since Analysis is another class, I can't use ResolutionSelector with declaration. And I can't find a way to connect the two.

As a result, what i want to know is other way to play the role of 'setTargetResolution()'.

what i tried for it is use ResolutionSelector.Build()'s method in ImageAnlysis.Build() but, naturally, impossible. and I tried to find way to use ResolutionSelctor. but i can't find what useful....

the reference link about setTargetSolution https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder

Empirin answered 1/11, 2023 at 8:54 Comment(1)
Here is a comment from one of the developers working on ResolutionSelector API: groups.google.com/a/android.com/g/camerax-developers/c/…Shabuoth
K
1

There is a method setResolutionSelector() when you are building the use case.

So you would have ImageAnalysis.Builder().setResolutionSelector(*PUT SELECTOR HERE*).build()

Kimberlite answered 1/11, 2023 at 17:17 Comment(0)
F
6

Maybe this example will help you:

 val screenSize = if (rotation == 0) Size(720, 1280) else Size(1280, 720)
    val resolutionSelector = ResolutionSelector.Builder().setResolutionStrategy(ResolutionStrategy(screenSize,
        ResolutionStrategy.FALLBACK_RULE_NONE)).build()
    val preview = Preview.Builder()
        .setResolutionSelector(resolutionSelector)
        .build()
Frolick answered 8/1 at 7:4 Comment(0)
K
1

There is a method setResolutionSelector() when you are building the use case.

So you would have ImageAnalysis.Builder().setResolutionSelector(*PUT SELECTOR HERE*).build()

Kimberlite answered 1/11, 2023 at 17:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.