react-native-rectangle-doc-scanner 1.7.0 → 1.8.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.
@@ -28,6 +28,7 @@ class RNRDocScannerView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate, A
28
28
  private var previewLayer: AVCaptureVideoPreviewLayer?
29
29
  private let videoOutput = AVCaptureVideoDataOutput()
30
30
  private let photoOutput = AVCapturePhotoOutput()
31
+ private var smoothedOverlayPoints: [CGPoint]?
31
32
  private let outlineLayer = CAShapeLayer()
32
33
  private let gridLayer = CAShapeLayer()
33
34
 
@@ -36,7 +37,7 @@ class RNRDocScannerView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate, A
36
37
  private var isCaptureInFlight = false
37
38
  private var lastObservation: VNRectangleObservation?
38
39
  private var missedDetectionFrames: Int = 0
39
- private let maxMissedDetections = 4
40
+ private let maxMissedDetections = 1
40
41
  private var lastFrameSize: CGSize = .zero
41
42
  private var photoCaptureCompletion: ((Result<RNRDocScannerCaptureResult, Error>) -> Void)?
42
43
 
@@ -203,7 +204,9 @@ class RNRDocScannerView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate, A
203
204
  return
204
205
  }
205
206
 
206
- let weighted: [VNRectangleObservation] = observations.sorted { (lhs: VNRectangleObservation, rhs: VNRectangleObservation) -> Bool in
207
+ let filtered = observations.filter { $0.confidence >= 0.55 }
208
+ let candidates = filtered.isEmpty ? observations : filtered
209
+ let weighted: [VNRectangleObservation] = candidates.sorted { (lhs: VNRectangleObservation, rhs: VNRectangleObservation) -> Bool in
207
210
  let lhsScore: CGFloat = CGFloat(lhs.confidence) * lhs.boundingBox.area
208
211
  let rhsScore: CGFloat = CGFloat(rhs.confidence) * rhs.boundingBox.area
209
212
  return lhsScore > rhsScore
@@ -222,13 +225,13 @@ class RNRDocScannerView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate, A
222
225
 
223
226
  let request = VNDetectRectanglesRequest(completionHandler: requestHandler)
224
227
 
225
- request.maximumObservations = 2
226
- request.minimumConfidence = 0.4
227
- request.minimumAspectRatio = 0.08
228
- request.maximumAspectRatio = 2.2
228
+ request.maximumObservations = 3
229
+ request.minimumConfidence = 0.55
230
+ request.minimumAspectRatio = 0.1
231
+ request.maximumAspectRatio = 2.0
229
232
  request.minimumSize = 0.05
230
233
  if #available(iOS 13.0, *) {
231
- request.quadratureTolerance = 45
234
+ request.quadratureTolerance = 20
232
235
  }
233
236
 
234
237
  let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: orientation, options: [:])
@@ -255,6 +258,7 @@ class RNRDocScannerView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate, A
255
258
  } else {
256
259
  lastObservation = nil
257
260
  missedDetectionFrames = 0
261
+ smoothedOverlayPoints = nil
258
262
  effectiveObservation = nil
259
263
  }
260
264
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",