Showing
1 changed file
with
6 additions
and
1 deletions
| @@ -113,6 +113,7 @@ class MobileScanner(private val activity: Activity, private val textureRegistry: | @@ -113,6 +113,7 @@ class MobileScanner(private val activity: Activity, private val textureRegistry: | ||
| 113 | 113 | ||
| 114 | 114 | ||
| 115 | private var scanner = BarcodeScanning.getClient() | 115 | private var scanner = BarcodeScanning.getClient() |
| 116 | + private lateinit var imageCapture: ImageCapture | ||
| 116 | 117 | ||
| 117 | @ExperimentalGetImage | 118 | @ExperimentalGetImage |
| 118 | private fun start(call: MethodCall, result: MethodChannel.Result) { | 119 | private fun start(call: MethodCall, result: MethodChannel.Result) { |
| @@ -161,10 +162,14 @@ class MobileScanner(private val activity: Activity, private val textureRegistry: | @@ -161,10 +162,14 @@ class MobileScanner(private val activity: Activity, private val textureRegistry: | ||
| 161 | } | 162 | } |
| 162 | val analysis = analysisBuilder.build().apply { setAnalyzer(executor, analyzer) } | 163 | val analysis = analysisBuilder.build().apply { setAnalyzer(executor, analyzer) } |
| 163 | 164 | ||
| 165 | + imageCapture = ImageCapture.Builder() | ||
| 166 | + .setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY) | ||
| 167 | + .build() | ||
| 168 | + | ||
| 164 | // Select the correct camera | 169 | // Select the correct camera |
| 165 | val selector = if (facing == 0) CameraSelector.DEFAULT_FRONT_CAMERA else CameraSelector.DEFAULT_BACK_CAMERA | 170 | val selector = if (facing == 0) CameraSelector.DEFAULT_FRONT_CAMERA else CameraSelector.DEFAULT_BACK_CAMERA |
| 166 | 171 | ||
| 167 | - camera = cameraProvider!!.bindToLifecycle(activity as LifecycleOwner, selector, preview, analysis) | 172 | + camera = cameraProvider!!.bindToLifecycle(activity as LifecycleOwner, selector, preview, imageCapture) |
| 168 | 173 | ||
| 169 | val analysisSize = analysis.resolutionInfo?.resolution ?: Size(0, 0) | 174 | val analysisSize = analysis.resolutionInfo?.resolution ?: Size(0, 0) |
| 170 | val previewSize = preview.resolutionInfo?.resolution ?: Size(0, 0) | 175 | val previewSize = preview.resolutionInfo?.resolution ?: Size(0, 0) |
-
Please register or login to post a comment