Skip to content

Commit

Permalink
fix: Improve CodeScanner performance by choosing resolution automatic…
Browse files Browse the repository at this point in the history
…ally (#2997)

* fix: remove hardcoded resolution selector

* fix: remove unused import

---------

Co-authored-by: Maksim Efimov <[email protected]>
  • Loading branch information
mgefimov and Maksim Efimov authored Jun 24, 2024
1 parent 1723408 commit 2c8f766
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.mrousavy.camera.core
import android.annotation.SuppressLint
import android.util.Log
import android.util.Range
import android.util.Size
import androidx.annotation.OptIn
import androidx.camera.core.CameraSelector
import androidx.camera.core.CameraState
Expand Down Expand Up @@ -211,11 +210,7 @@ internal fun CameraSession.configureOutputs(configuration: CameraConfiguration)
val codeScannerConfig = configuration.codeScanner as? CameraConfiguration.Output.Enabled<CameraConfiguration.CodeScanner>
if (codeScannerConfig != null) {
Log.i(CameraSession.TAG, "Creating CodeScanner output...")
val analyzer = ImageAnalysis.Builder().also { analysis ->
val targetSize = Size(1280, 720)
val resolutionSelector = ResolutionSelector.Builder().forSize(targetSize).build()
analysis.setResolutionSelector(resolutionSelector)
}.build()
val analyzer = ImageAnalysis.Builder().build()
val pipeline = CodeScannerPipeline(codeScannerConfig.config, callback)
analyzer.setAnalyzer(CameraQueues.analyzerExecutor, pipeline)
codeScannerOutput = analyzer
Expand Down

0 comments on commit 2c8f766

Please sign in to comment.