Skip to content

Commit

Permalink
feat: Capture better quality photos by using minFps from format (m…
Browse files Browse the repository at this point in the history
…rousavy#3073)

* feat: Capture better quality photos by using `minFps` from `format`

* Update CameraConfiguration.kt
  • Loading branch information
mrousavy authored Jul 12, 2024
1 parent 879e4c6 commit b3e8f25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.mrousavy.camera.core.types.PixelFormat
import com.mrousavy.camera.core.types.QualityBalance
import com.mrousavy.camera.core.types.Torch
import com.mrousavy.camera.core.types.VideoStabilizationMode
import kotlin.math.min

data class CameraConfiguration(
// Input
Expand Down Expand Up @@ -55,9 +54,9 @@ data class CameraConfiguration(

val targetFpsRange: Range<Int>?
get() {
// due to a bug (or feature?) in CameraX, photo resolution will suffer if min FPS is higher than 20.
val maxFps = fps ?: return null
val minFps = min(20, maxFps)
val format = format ?: throw PropRequiresFormatToBeNonNullError("fps")
val minFps = format.minFps.toInt()
return Range(minFps, maxFps)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal fun CameraSession.configureOutputs(configuration: CameraConfiguration)
preview.setResolutionSelector(previewResolutionSelector)
}
}.build()
preview.surfaceProvider = previewConfig.config.surfaceProvider
preview.setSurfaceProvider(previewConfig.config.surfaceProvider)
previewOutput = preview
} else {
previewOutput = null
Expand Down

0 comments on commit b3e8f25

Please sign in to comment.