androidresolutionandroid-camerax

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


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


Solution

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

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