Philippe Geoffroy

Fix: with the "noDuplicates" detection speed, the same code is no longer detecte…

…d after stopping and restarting the scanner.
Fix: spamming code detection with "noDuplicates" detection speed on iOS.
... ... @@ -70,7 +70,7 @@ class MobileScanner(
scanner.process(inputImage)
.addOnSuccessListener { barcodes ->
if (detectionSpeed == DetectionSpeed.NO_DUPLICATES) {
val newScannedBarcodes = barcodes.map { barcode -> barcode.rawValue }
val newScannedBarcodes = barcodes.mapNotNull({ barcode -> barcode.rawValue }).sorted()
if (newScannedBarcodes == lastScanned) {
// New scanned is duplicate, returning
return@addOnSuccessListener
... ... @@ -224,6 +224,7 @@ class MobileScanner(
throw AlreadyStarted()
}
lastScanned = null
scanner = if (barcodeScannerOptions != null) {
BarcodeScanning.getClient(barcodeScannerOptions)
} else {
... ...
... ... @@ -117,12 +117,13 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
imagesCurrentlyBeingProcessed = false
if (detectionSpeed == DetectionSpeed.noDuplicates) {
let newScannedBarcodes = barcodes?.map { barcode in
let newScannedBarcodes = barcodes?.compactMap({ barcode in
return barcode.rawValue
}
}).sorted()
if (error == nil && barcodesString != nil && newScannedBarcodes != nil && barcodesString!.elementsEqual(newScannedBarcodes!)) {
return
} else {
} else if (newScannedBarcodes?.isEmpty == false) {
barcodesString = newScannedBarcodes
}
}
... ... @@ -139,6 +140,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
throw MobileScannerError.alreadyStarted
}
barcodesString = nil
scanner = barcodeScannerOptions != nil ? BarcodeScanner.barcodeScanner(options: barcodeScannerOptions!) : BarcodeScanner.barcodeScanner()
captureSession = AVCaptureSession()
textureId = registry?.register(self)
... ...