RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.81k stars 405 forks source link

Problem trying to set the pictureResolution #397

Open stylphub opened 4 years ago

stylphub commented 4 years ago

What are you trying to achieve or the steps to reproduce?

Hello,

I'm using the library version 2.7.0 and i have got really good results, but there is one problem that I detected and I don't know if it's a bug or I'm doing something wrong.

I'm using Kotlin and creating a Camera Configuration to set all the needed configurations I use for the camera. I was setting the pictureResolution to be 1280x720 (which is the one I need) and if it's not available for the device, to use the highest resolution that it has with firstAvailable() has shown below.

pictureResolution = firstAvailable(
                        {Resolution(1280,720)},
                        highestResolution()
                ),

I though that whith this, the library was going to test if the first resolution was available and if not it was going to try with the highest resolutionm but when the device don't have a 1280x720 resolution it gives an error and don't try to go to the second option of the highestResolution().

I tried to get a list of supported Resolutions and solve it before creating the cameraConfiguration, but I haven't managed to get the supported resolutions out of the library.

Is there a bug with firstAvailable or I'm misunderstanding something? Is there a way to solve it that's not starting the camera to get the capabilities and then updating it?

How did you initialize FA?

val cameraConfiguration = CameraConfiguration(
                pictureResolution = firstAvailable(
                        {Resolution(1280,720)},
                        highestResolution()
                ),
                previewResolution = firstAvailable(
                        wideRatio({ Resolution(1280,720) }),
                        wideRatio(highestResolution())
                ),
                previewFpsRange = highestFps(),
                focusMode = firstAvailable(
                        continuousFocusPicture(),
                        autoFocus(),
                        fixed()
                ),
                jpegQuality = manualJpegQuality(90), 
                frameProcessor = { frame ->  processFrame(frame)}
        )

        camera = Fotoapparat(
                context = this,
                view = cameraView!!,
                scaleType = ScaleType.CenterCrop,
                lensPosition = front(),
                cameraConfiguration = cameraConfiguration,
                cameraErrorCallback = { error -> PrintError(error)}
        )

What was the result you received?

This is the error I'm receiving

io.fotoapparat.exception.camera.InvalidConfigurationException: Resolution configuration selector selected value Resolution(width=1280, height=720). However it's not in the supported set of values. Supported parameters: [Resolution(width=800, height=600), Resolution(width=640, height=480), Resolution(width=320, height=240), Resolution(width=176, height=144)]

Context:

IvanAkhmylin commented 1 year ago

Same here, did you find solution ?