fix: Run CodeScanner on default queue, fix stalling (#2002)

* fix: Run CodeScanner on default queue, fix stalling

* fix: Use `MAX_IMAGES` of 3
This commit is contained in:
Marc Rousavy 2023-10-14 13:30:21 +02:00 committed by GitHub
parent ea98112a21
commit e8df7148fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -11,7 +11,6 @@ class CameraQueues {
companion object { companion object {
val cameraQueue = CameraQueue("mrousavy/VisionCamera.main") val cameraQueue = CameraQueue("mrousavy/VisionCamera.main")
val videoQueue = CameraQueue("mrousavy/VisionCamera.video") val videoQueue = CameraQueue("mrousavy/VisionCamera.video")
val codeScannerQueue = CameraQueue("mrousavy/VisionCamera.codeScanner")
} }
class CameraQueue(name: String) { class CameraQueue(name: String) {

View File

@ -13,10 +13,10 @@ import java.io.Closeable
class CodeScannerPipeline(val size: Size, val format: Int, val output: CameraOutputs.CodeScannerOutput) : Closeable { class CodeScannerPipeline(val size: Size, val format: Int, val output: CameraOutputs.CodeScannerOutput) : Closeable {
companion object { companion object {
// We want to have a buffer of 2 images, but we always only acquire one. // We want to have a buffer of 3 images, but we always only acquire one.
// That way the pipeline is free to stream frames into the unused buffer, // That way the pipeline is free to stream up to two frames into the unused buffer,
// while the other buffer is being used for code scanning. // while the other buffer is being used for code scanning.
private const val MAX_IMAGES = 2 private const val MAX_IMAGES = 3
} }
private val imageReader: ImageReader private val imageReader: ImageReader
@ -29,7 +29,6 @@ class CodeScannerPipeline(val size: Size, val format: Int, val output: CameraOut
val types = output.codeScanner.codeTypes.map { it.toBarcodeType() } val types = output.codeScanner.codeTypes.map { it.toBarcodeType() }
val barcodeScannerOptions = BarcodeScannerOptions.Builder() val barcodeScannerOptions = BarcodeScannerOptions.Builder()
.setBarcodeFormats(types[0], *types.toIntArray()) .setBarcodeFormats(types[0], *types.toIntArray())
.setExecutor(CameraQueues.codeScannerQueue.executor)
.build() .build()
scanner = BarcodeScanning.getClient(barcodeScannerOptions) scanner = BarcodeScanning.getClient(barcodeScannerOptions)