@scr2em/capacitor-scanner 6.0.27 → 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.
|
@@ -1466,7 +1466,10 @@ public class CapacitorScannerPlugin extends Plugin {
|
|
|
1466
1466
|
}
|
|
1467
1467
|
|
|
1468
1468
|
// Check for largest business card rectangle
|
|
1469
|
-
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()) {
|
|
1470
1473
|
if (largestRect == null) {
|
|
1471
1474
|
largestRect = currentRectangleRects.get(0);
|
|
1472
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 {
|