react-native-rectangle-doc-scanner 1.8.0 → 1.9.0
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.
- package/ios/RNRDocScannerView.swift +14 -2
- package/package.json +1 -1
|
@@ -262,7 +262,8 @@ class RNRDocScannerView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate, A
|
|
|
262
262
|
effectiveObservation = nil
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
let shouldDisplayOverlay = currentStableCounter > 0 && effectiveObservation != nil
|
|
266
|
+
updateNativeOverlay(with: shouldDisplayOverlay ? effectiveObservation : nil)
|
|
266
267
|
|
|
267
268
|
let payload: [String: Any?]
|
|
268
269
|
if let observation = effectiveObservation {
|
|
@@ -318,13 +319,24 @@ class RNRDocScannerView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate, A
|
|
|
318
319
|
return
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
let
|
|
322
|
+
let rawPoints = [
|
|
322
323
|
self.convertToLayerPoint(observation.topLeft, previewLayer: previewLayer),
|
|
323
324
|
self.convertToLayerPoint(observation.topRight, previewLayer: previewLayer),
|
|
324
325
|
self.convertToLayerPoint(observation.bottomRight, previewLayer: previewLayer),
|
|
325
326
|
self.convertToLayerPoint(observation.bottomLeft, previewLayer: previewLayer),
|
|
326
327
|
]
|
|
327
328
|
|
|
329
|
+
let points: [CGPoint]
|
|
330
|
+
if let previous = self.smoothedOverlayPoints, previous.count == 4 {
|
|
331
|
+
points = zip(previous, rawPoints).map { prev, next in
|
|
332
|
+
CGPoint(x: prev.x * 0.7 + next.x * 0.3, y: prev.y * 0.7 + next.y * 0.3)
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
points = rawPoints
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
self.smoothedOverlayPoints = points
|
|
339
|
+
|
|
328
340
|
let outline = UIBezierPath()
|
|
329
341
|
outline.move(to: points[0])
|
|
330
342
|
outline.addLine(to: points[1])
|