Skip to content

Commit

Permalink
Fixed QR scanner not always picking up clear codes
Browse files Browse the repository at this point in the history
Aspect ratio was sometimes set incorrectly, depending on device
(Pixel 6 and 7 phones had troubles scanning 20x20mm codes)
  • Loading branch information
scarlac committed Oct 11, 2023
1 parent ca798d2 commit 909546e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions android/src/main/java/com/rncamerakit/CKCamera.kt
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,20 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs

// ImageCapture
imageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
// We request aspect ratio but no resolution to match preview config, but letting
// CameraX optimize for whatever specific resolution best fits our use cases
.setTargetAspectRatio(screenAspectRatio)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
.setTargetRotation(rotation)
.build()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
// We request aspect ratio but no resolution to match preview config, but letting
// CameraX optimize for whatever specific resolution best fits our use cases
.setTargetAspectRatio(screenAspectRatio)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
.setTargetRotation(rotation)
.build()

// ImageAnalysis
imageAnalyzer = ImageAnalysis.Builder()
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.setTargetAspectRatio(screenAspectRatio)
.build()

val useCases = mutableListOf(preview, imageCapture)

Expand Down

0 comments on commit 909546e

Please sign in to comment.