@scr2em/capacitor-scanner 6.0.26 → 6.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -838,6 +838,12 @@ public class CapacitorScannerPlugin extends Plugin {
|
|
|
838
838
|
echo("Barcode has no rawValue or rawBytes, skipping");
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
|
+
|
|
842
|
+
// Strip UTF-8 BOM if present
|
|
843
|
+
if (rawValue != null && rawValue.startsWith("\uFEFF")) {
|
|
844
|
+
rawValue = rawValue.substring(1);
|
|
845
|
+
}
|
|
846
|
+
|
|
841
847
|
echo("Processing barcode with rawValue: " + rawValue);
|
|
842
848
|
|
|
843
849
|
// Apply Regex Filter if present
|
|
@@ -1460,7 +1466,10 @@ public class CapacitorScannerPlugin extends Plugin {
|
|
|
1460
1466
|
}
|
|
1461
1467
|
|
|
1462
1468
|
// Check for largest business card rectangle
|
|
1463
|
-
if
|
|
1469
|
+
// Only use the detected rectangle if it was detected within the last 500ms
|
|
1470
|
+
boolean isRectangleCurrentlyDetected = lastRectangleDetectionTime > 0
|
|
1471
|
+
&& (System.currentTimeMillis() - lastRectangleDetectionTime) < 500;
|
|
1472
|
+
if (enabledDetectionTypes.contains("businessCard") && isRectangleCurrentlyDetected && !currentRectangleRects.isEmpty()) {
|
|
1464
1473
|
if (largestRect == null) {
|
|
1465
1474
|
largestRect = currentRectangleRects.get(0);
|
|
1466
1475
|
}
|
|
@@ -6,7 +6,6 @@ import android.graphics.Color;
|
|
|
6
6
|
import android.graphics.Paint;
|
|
7
7
|
import android.graphics.RectF;
|
|
8
8
|
import android.graphics.Path;
|
|
9
|
-
import android.graphics.DashPathEffect;
|
|
10
9
|
import android.util.AttributeSet;
|
|
11
10
|
import android.view.View;
|
|
12
11
|
|
|
@@ -37,12 +36,11 @@ public class DetectionOverlay extends View {
|
|
|
37
36
|
barcodePaint.setStrokeWidth(6f);
|
|
38
37
|
barcodePaint.setAntiAlias(true);
|
|
39
38
|
|
|
40
|
-
//
|
|
41
|
-
rectanglePaint.setColor(Color.
|
|
39
|
+
// Black solid stroke for rectangles (business cards)
|
|
40
|
+
rectanglePaint.setColor(Color.BLACK);
|
|
42
41
|
rectanglePaint.setStyle(Paint.Style.STROKE);
|
|
43
42
|
rectanglePaint.setStrokeWidth(8f);
|
|
44
43
|
rectanglePaint.setAntiAlias(true);
|
|
45
|
-
rectanglePaint.setPathEffect(new DashPathEffect(new float[]{20, 10}, 0));
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
public void updateDetections(List<RectF> barcodeRects) {
|
|
@@ -281,8 +281,18 @@ public class CapacitorScannerPlugin: CAPPlugin, CAPBridgedPlugin, AVCaptureMetad
|
|
|
281
281
|
return
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
// Check if object detection is enabled and we have a detected rectangle
|
|
284
|
+
// Check if object detection is enabled and we have a recently detected rectangle
|
|
285
|
+
// Only use the detected rectangle if it was detected within the last 0.5 seconds
|
|
286
|
+
let isRectangleCurrentlyDetected: Bool = {
|
|
287
|
+
guard let detector = self.rectangleDetector,
|
|
288
|
+
let lastTime = detector.lastDetectionTime else {
|
|
289
|
+
return false
|
|
290
|
+
}
|
|
291
|
+
return Date().timeIntervalSince(lastTime) < 0.5
|
|
292
|
+
}()
|
|
293
|
+
|
|
285
294
|
if self.enabledDetectionTypes.contains("businessCard"),
|
|
295
|
+
isRectangleCurrentlyDetected,
|
|
286
296
|
let detectedRect = self.rectangleDetector?.lastDetectedRectangle {
|
|
287
297
|
// If we have a snapshot from the detection, use it directly
|
|
288
298
|
if let snapshot = detectedRect.snapshot {
|
|
@@ -753,8 +763,12 @@ public class CapacitorScannerPlugin: CAPPlugin, CAPBridgedPlugin, AVCaptureMetad
|
|
|
753
763
|
|
|
754
764
|
// Then process only that barcode if found
|
|
755
765
|
if let bestObservation = highestConfidenceBarcode,
|
|
756
|
-
|
|
766
|
+
var payload = bestObservation.payloadStringValue
|
|
757
767
|
{
|
|
768
|
+
// Strip UTF-8 BOM if present
|
|
769
|
+
if payload.hasPrefix("\u{FEFF}") {
|
|
770
|
+
payload = String(payload.dropFirst())
|
|
771
|
+
}
|
|
758
772
|
// Update the last barcode detection time
|
|
759
773
|
self.lastBarcodeDetectionTime = Date()
|
|
760
774
|
|