react-native-vision-camera-spoof-detector 1.3.4 → 1.3.5

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/README.md CHANGED
@@ -136,7 +136,7 @@ const styles = StyleSheet.create({
136
136
  });
137
137
  ```
138
138
 
139
- The output is processed natively; the hook returns a `CameraOutput` for Vision Camera's `outputs` array. Callbacks are rate-limited by `uiUpdateIntervalMs` (default 100 ms), except that face-count changes can trigger `onFacesDetected` immediately. `onStableFaceDetected` fires once when its face-stability and liveness gates pass; reset it with `resetFaceAntiSpoofFrameOutput` to allow another stable-face callback.
139
+ The output is processed natively; the hook returns a `CameraOutput` for Vision Camera's `outputs` array. `onResult` and `onFacesDetected` are called for every processed frame. `onStableFaceDetected` fires once when its face-stability and liveness gates pass; reset it with `resetFaceAntiSpoofFrameOutput` to allow another stable-face callback.
140
140
 
141
141
  ## API reference
142
142
 
@@ -167,7 +167,6 @@ interface UseFaceAntiSpoofFrameOutputOptions {
167
167
  requiredLiveFrames?: number;
168
168
  laplacianThreshold?: number;
169
169
  maxNeuralSpoofScore?: number;
170
- uiUpdateIntervalMs?: number;
171
170
  onFacesDetected?: (faces: SpoofDetectedFace[]) => void;
172
171
  onResult?: (result: FaceAntiSpoofingResult) => void;
173
172
  onStableFaceDetected?: (face: SpoofDetectedFace['bounds'], result: FaceAntiSpoofingResult) => void;
@@ -195,7 +194,6 @@ Default output options on both platforms:
195
194
  | `requiredLiveFrames` | `3` | Consecutive score-passing frames required before notification |
196
195
  | `laplacianThreshold` | `1100` | Minimum Laplacian score for a frame to pass |
197
196
  | `maxNeuralSpoofScore` | `0.1` | Neural scores at or above this value fail the liveness gate |
198
- | `uiUpdateIntervalMs` | `100` | Minimum interval between score/face updates when the eligible face count is unchanged |
199
197
  | `targetResolution` | Camera-selected | Optional requested analysis resolution |
200
198
 
201
199
  On Android devices identified by the system as low-RAM, and on iOS devices with 4 GB physical memory or less, a requested resolution wider than 640 pixels is scaled down proportionally. With no `targetResolution`, the camera selects the analysis resolution. Android uses YUV frames and ML Kit; iOS uses BGRA frames and Vision. Platform model runtimes and score calculations may differ, so calibrate thresholds on representative devices and presentation-attack data rather than assuming identical score distributions.
@@ -3,7 +3,6 @@ package com.margelo.nitro.camera.spoofdetector
3
3
  import android.graphics.Matrix
4
4
  import android.graphics.PointF
5
5
  import android.graphics.RectF
6
- import android.os.SystemClock
7
6
  import android.app.ActivityManager
8
7
  import android.content.Context
9
8
  import androidx.annotation.OptIn
@@ -69,7 +68,6 @@ class HybridSpoofDetectorOutput(
69
68
  private val requiredLiveFrames = (options.requiredLiveFrames ?: 3.0).toInt().coerceAtLeast(1)
70
69
  private val laplacianThreshold = options.laplacianThreshold ?: 1100.0
71
70
  private val maxNeuralSpoofScore = options.maxNeuralSpoofScore ?: 0.1
72
- private val uiUpdateIntervalMs = (options.uiUpdateIntervalMs ?: 100.0).toLong().coerceAtLeast(0L)
73
71
  private val isLowRamDevice by lazy {
74
72
  val context = NitroModules.applicationContext
75
73
  val activityManager = context?.getSystemService(Context.ACTIVITY_SERVICE) as? ActivityManager
@@ -80,9 +78,6 @@ class HybridSpoofDetectorOutput(
80
78
  private var lastFaceBounds: SpoofDetectedFaceBounds? = null
81
79
  private var consecutiveLiveFrames = 0
82
80
  private var lastSpoofResult: AntiSpoofingResult? = null
83
- private var lastFaceCount = -1
84
- private var lastFacesUpdateAtMs = 0L
85
- private var lastResultUpdateAtMs = 0L
86
81
  private var imageAnalysis: ImageAnalysis? = null
87
82
  private companion object {
88
83
  private const val MIN_FACE_WIDTH_RATIO = 0.18f
@@ -209,9 +204,6 @@ class HybridSpoofDetectorOutput(
209
204
  .filter { it.isFullFace(frameWidth, frameHeight) }
210
205
  .map { it.toSpoofDetectedFace(transform) }
211
206
  .toTypedArray()
212
- val now = SystemClock.elapsedRealtime()
213
- var shouldNotify = false
214
-
215
207
  synchronized(stateLock) {
216
208
  if (detectedFaces.size == 1) {
217
209
  val bounds = detectedFaces[0].bounds
@@ -225,20 +217,12 @@ class HybridSpoofDetectorOutput(
225
217
  lastSpoofResult = null
226
218
  }
227
219
 
228
- shouldNotify = detectedFaces.size != lastFaceCount ||
229
- now - lastFacesUpdateAtMs >= uiUpdateIntervalMs
230
- if (shouldNotify) {
231
- lastFaceCount = detectedFaces.size
232
- lastFacesUpdateAtMs = now
233
- }
234
220
  }
235
221
 
236
- if (shouldNotify) options.onFacesDetected?.invoke(detectedFaces)
222
+ options.onFacesDetected?.invoke(detectedFaces)
237
223
  }
238
224
 
239
225
  private fun processAntiSpoofResult(result: AntiSpoofingResult) {
240
- val now = SystemClock.elapsedRealtime()
241
- var shouldNotify = false
242
226
  var capture: Pair<SpoofDetectedFaceBounds, AntiSpoofingResult>? = null
243
227
 
244
228
  synchronized(stateLock) {
@@ -257,12 +241,10 @@ class HybridSpoofDetectorOutput(
257
241
  }
258
242
  }
259
243
 
260
- shouldNotify = now - lastResultUpdateAtMs >= uiUpdateIntervalMs
261
- if (shouldNotify) lastResultUpdateAtMs = now
262
244
  capture = readyToCaptureLocked()
263
245
  }
264
246
 
265
- if (shouldNotify) options.onResult.invoke(result)
247
+ options.onResult.invoke(result)
266
248
  capture?.let { (bounds, capturedResult) ->
267
249
  options.onStableFaceDetected?.invoke(bounds, capturedResult)
268
250
  }
@@ -293,9 +275,6 @@ class HybridSpoofDetectorOutput(
293
275
  lastFaceBounds = null
294
276
  consecutiveLiveFrames = 0
295
277
  lastSpoofResult = null
296
- lastFaceCount = -1
297
- lastFacesUpdateAtMs = 0L
298
- lastResultUpdateAtMs = 0L
299
278
  }
300
279
  }
301
280
 
package/index.d.ts CHANGED
@@ -278,7 +278,6 @@ export interface UseFaceAntiSpoofFrameOutputOptions extends Partial<FrameOutputO
278
278
  requiredLiveFrames?: number;
279
279
  laplacianThreshold?: number;
280
280
  maxNeuralSpoofScore?: number;
281
- uiUpdateIntervalMs?: number;
282
281
  onResult?: (result: FaceAntiSpoofingResult) => void;
283
282
  onFacesDetected?: (faces: SpoofDetectedFace[]) => void;
284
283
  onStableFaceDetected?: (face: FaceRect, result: FaceAntiSpoofingResult) => void;
package/index.js CHANGED
@@ -40,7 +40,6 @@ export const useFaceAntiSpoofFrameOutput = ({
40
40
  requiredLiveFrames: options.requiredLiveFrames,
41
41
  laplacianThreshold: options.laplacianThreshold,
42
42
  maxNeuralSpoofScore: options.maxNeuralSpoofScore,
43
- uiUpdateIntervalMs: options.uiUpdateIntervalMs,
44
43
  onResult(result) {
45
44
  resultRef.current?.(result);
46
45
  },
@@ -62,7 +61,6 @@ export const useFaceAntiSpoofFrameOutput = ({
62
61
  options.requiredLiveFrames,
63
62
  options.laplacianThreshold,
64
63
  options.maxNeuralSpoofScore,
65
- options.uiUpdateIntervalMs,
66
64
  hasFaceCallback,
67
65
  hasStableFaceCallback,
68
66
  ],
@@ -25,16 +25,12 @@ final class HybridSpoofDetectorOutput: HybridCameraOutputSpec, NativeCameraOutpu
25
25
  private var lastFaceBounds: SpoofDetectedFaceBounds?
26
26
  private var consecutiveLiveFrames = 0
27
27
  private var lastSpoofResult: AntiSpoofingResult?
28
- private var lastFaceCount = -1
29
- private var lastFacesUpdateAt = 0.0
30
- private var lastResultUpdateAt = 0.0
31
28
 
32
29
  private var antispoofLevel: Double { options.antispoofLevel ?? 0.4 }
33
30
  private var stableFrames: Int { max(1, Int(options.stableFrames ?? 3)) }
34
31
  private var requiredLiveFrames: Int { max(1, Int(options.requiredLiveFrames ?? 3)) }
35
32
  private var laplacianThreshold: Double { options.laplacianThreshold ?? 1100 }
36
33
  private var maxNeuralSpoofScore: Double { options.maxNeuralSpoofScore ?? 0.1 }
37
- private var uiUpdateInterval: Double { max(0, options.uiUpdateIntervalMs ?? 100) / 1000 }
38
34
  private var isLowMemoryDevice: Bool {
39
35
  ProcessInfo.processInfo.physicalMemory <= 4 * 1024 * 1024 * 1024
40
36
  }
@@ -226,7 +222,6 @@ final class HybridSpoofDetectorOutput: HybridCameraOutputSpec, NativeCameraOutpu
226
222
  }
227
223
 
228
224
  private func processDetectedFaces(_ faces: [SpoofDetectedFace]) {
229
- let now = ProcessInfo.processInfo.systemUptime
230
225
  if faces.count == 1 {
231
226
  let bounds = faces[0].bounds
232
227
  stableCount += 1
@@ -239,12 +234,7 @@ final class HybridSpoofDetectorOutput: HybridCameraOutputSpec, NativeCameraOutpu
239
234
  lastSpoofResult = nil
240
235
  }
241
236
 
242
- let shouldNotify = faces.count != lastFaceCount || now - lastFacesUpdateAt >= uiUpdateInterval
243
- if shouldNotify {
244
- lastFaceCount = faces.count
245
- lastFacesUpdateAt = now
246
- options.onFacesDetected?(faces)
247
- }
237
+ options.onFacesDetected?(faces)
248
238
  }
249
239
 
250
240
  private func processAntiSpoofResult(_ result: AntiSpoofingResult) {
@@ -261,11 +251,7 @@ final class HybridSpoofDetectorOutput: HybridCameraOutputSpec, NativeCameraOutpu
261
251
  }
262
252
  }
263
253
 
264
- let now = ProcessInfo.processInfo.systemUptime
265
- if now - lastResultUpdateAt >= uiUpdateInterval {
266
- lastResultUpdateAt = now
267
- options.onResult(result)
268
- }
254
+ options.onResult(result)
269
255
  notifyStableFaceIfReady()
270
256
  }
271
257
 
@@ -60,8 +60,6 @@ namespace margelo::nitro::camera::spoofdetector {
60
60
  jni::local_ref<jni::JDouble> laplacianThreshold = this->getFieldValue(fieldLaplacianThreshold);
61
61
  static const auto fieldMaxNeuralSpoofScore = clazz->getField<jni::JDouble>("maxNeuralSpoofScore");
62
62
  jni::local_ref<jni::JDouble> maxNeuralSpoofScore = this->getFieldValue(fieldMaxNeuralSpoofScore);
63
- static const auto fieldUiUpdateIntervalMs = clazz->getField<jni::JDouble>("uiUpdateIntervalMs");
64
- jni::local_ref<jni::JDouble> uiUpdateIntervalMs = this->getFieldValue(fieldUiUpdateIntervalMs);
65
63
  static const auto fieldOnResult = clazz->getField<JFunc_void_AntiSpoofingResult::javaobject>("onResult");
66
64
  jni::local_ref<JFunc_void_AntiSpoofingResult::javaobject> onResult = this->getFieldValue(fieldOnResult);
67
65
  static const auto fieldOnFacesDetected = clazz->getField<JFunc_void_std__vector_SpoofDetectedFace_::javaobject>("onFacesDetected");
@@ -77,7 +75,6 @@ namespace margelo::nitro::camera::spoofdetector {
77
75
  requiredLiveFrames != nullptr ? std::make_optional(requiredLiveFrames->value()) : std::nullopt,
78
76
  laplacianThreshold != nullptr ? std::make_optional(laplacianThreshold->value()) : std::nullopt,
79
77
  maxNeuralSpoofScore != nullptr ? std::make_optional(maxNeuralSpoofScore->value()) : std::nullopt,
80
- uiUpdateIntervalMs != nullptr ? std::make_optional(uiUpdateIntervalMs->value()) : std::nullopt,
81
78
  [&]() -> std::function<void(const AntiSpoofingResult& /* result */)> {
82
79
  if (onResult->isInstanceOf(JFunc_void_AntiSpoofingResult_cxx::javaClassStatic())) [[likely]] {
83
80
  auto downcast = jni::static_ref_cast<JFunc_void_AntiSpoofingResult_cxx::javaobject>(onResult);
@@ -123,7 +120,7 @@ namespace margelo::nitro::camera::spoofdetector {
123
120
  */
124
121
  [[maybe_unused]]
125
122
  static jni::local_ref<JSpoofDetectorOutputOptions::javaobject> fromCpp(const SpoofDetectorOutputOptions& value) {
126
- using JSignature = JSpoofDetectorOutputOptions(jni::alias_ref<JSize>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JFunc_void_AntiSpoofingResult::javaobject>, jni::alias_ref<JFunc_void_std__vector_SpoofDetectedFace_::javaobject>, jni::alias_ref<JFunc_void_SpoofDetectedFaceBounds_AntiSpoofingResult::javaobject>, jni::alias_ref<JFunc_void_std__exception_ptr::javaobject>);
123
+ using JSignature = JSpoofDetectorOutputOptions(jni::alias_ref<JSize>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JFunc_void_AntiSpoofingResult::javaobject>, jni::alias_ref<JFunc_void_std__vector_SpoofDetectedFace_::javaobject>, jni::alias_ref<JFunc_void_SpoofDetectedFaceBounds_AntiSpoofingResult::javaobject>, jni::alias_ref<JFunc_void_std__exception_ptr::javaobject>);
127
124
  static const auto clazz = javaClassStatic();
128
125
  static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
129
126
  return create(
@@ -134,7 +131,6 @@ namespace margelo::nitro::camera::spoofdetector {
134
131
  value.requiredLiveFrames.has_value() ? jni::JDouble::valueOf(value.requiredLiveFrames.value()) : nullptr,
135
132
  value.laplacianThreshold.has_value() ? jni::JDouble::valueOf(value.laplacianThreshold.value()) : nullptr,
136
133
  value.maxNeuralSpoofScore.has_value() ? jni::JDouble::valueOf(value.maxNeuralSpoofScore.value()) : nullptr,
137
- value.uiUpdateIntervalMs.has_value() ? jni::JDouble::valueOf(value.uiUpdateIntervalMs.value()) : nullptr,
138
134
  JFunc_void_AntiSpoofingResult_cxx::fromCpp(value.onResult),
139
135
  value.onFacesDetected.has_value() ? JFunc_void_std__vector_SpoofDetectedFace__cxx::fromCpp(value.onFacesDetected.value()) : nullptr,
140
136
  value.onStableFaceDetected.has_value() ? JFunc_void_SpoofDetectedFaceBounds_AntiSpoofingResult_cxx::fromCpp(value.onStableFaceDetected.value()) : nullptr,
@@ -38,9 +38,6 @@ data class SpoofDetectorOutputOptions(
38
38
  val maxNeuralSpoofScore: Double?,
39
39
  @DoNotStrip
40
40
  @Keep
41
- val uiUpdateIntervalMs: Double?,
42
- @DoNotStrip
43
- @Keep
44
41
  val onResult: Func_void_AntiSpoofingResult,
45
42
  @DoNotStrip
46
43
  @Keep
@@ -55,8 +52,8 @@ data class SpoofDetectorOutputOptions(
55
52
  /**
56
53
  * Create a new instance of SpoofDetectorOutputOptions from Kotlin
57
54
  */
58
- constructor(targetResolution: Size?, antispoofLevel: Double?, stableFrames: Double?, requiredLiveFrames: Double?, laplacianThreshold: Double?, maxNeuralSpoofScore: Double?, uiUpdateIntervalMs: Double?, onResult: (result: AntiSpoofingResult) -> Unit, onFacesDetected: ((faces: Array<SpoofDetectedFace>) -> Unit)?, onStableFaceDetected: ((face: SpoofDetectedFaceBounds, result: AntiSpoofingResult) -> Unit)?, onError: ((error: Throwable) -> Unit)?):
59
- this(targetResolution, antispoofLevel, stableFrames, requiredLiveFrames, laplacianThreshold, maxNeuralSpoofScore, uiUpdateIntervalMs, Func_void_AntiSpoofingResult_java(onResult), onFacesDetected?.let { Func_void_std__vector_SpoofDetectedFace__java(it) }, onStableFaceDetected?.let { Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult_java(it) }, onError?.let { Func_void_std__exception_ptr_java(it) })
55
+ constructor(targetResolution: Size?, antispoofLevel: Double?, stableFrames: Double?, requiredLiveFrames: Double?, laplacianThreshold: Double?, maxNeuralSpoofScore: Double?, onResult: (result: AntiSpoofingResult) -> Unit, onFacesDetected: ((faces: Array<SpoofDetectedFace>) -> Unit)?, onStableFaceDetected: ((face: SpoofDetectedFaceBounds, result: AntiSpoofingResult) -> Unit)?, onError: ((error: Throwable) -> Unit)?):
56
+ this(targetResolution, antispoofLevel, stableFrames, requiredLiveFrames, laplacianThreshold, maxNeuralSpoofScore, Func_void_AntiSpoofingResult_java(onResult), onFacesDetected?.let { Func_void_std__vector_SpoofDetectedFace__java(it) }, onStableFaceDetected?.let { Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult_java(it) }, onError?.let { Func_void_std__exception_ptr_java(it) })
60
57
 
61
58
  override fun equals(other: Any?): Boolean {
62
59
  if (this === other) return true
@@ -67,7 +64,6 @@ data class SpoofDetectorOutputOptions(
67
64
  && Objects.deepEquals(this.requiredLiveFrames, other.requiredLiveFrames)
68
65
  && Objects.deepEquals(this.laplacianThreshold, other.laplacianThreshold)
69
66
  && Objects.deepEquals(this.maxNeuralSpoofScore, other.maxNeuralSpoofScore)
70
- && Objects.deepEquals(this.uiUpdateIntervalMs, other.uiUpdateIntervalMs)
71
67
  && Objects.deepEquals(this.onResult, other.onResult)
72
68
  && Objects.deepEquals(this.onFacesDetected, other.onFacesDetected)
73
69
  && Objects.deepEquals(this.onStableFaceDetected, other.onStableFaceDetected)
@@ -82,7 +78,6 @@ data class SpoofDetectorOutputOptions(
82
78
  requiredLiveFrames,
83
79
  laplacianThreshold,
84
80
  maxNeuralSpoofScore,
85
- uiUpdateIntervalMs,
86
81
  onResult,
87
82
  onFacesDetected,
88
83
  onStableFaceDetected,
@@ -98,8 +93,8 @@ data class SpoofDetectorOutputOptions(
98
93
  @Keep
99
94
  @Suppress("unused")
100
95
  @JvmStatic
101
- private fun fromCpp(targetResolution: Size?, antispoofLevel: Double?, stableFrames: Double?, requiredLiveFrames: Double?, laplacianThreshold: Double?, maxNeuralSpoofScore: Double?, uiUpdateIntervalMs: Double?, onResult: Func_void_AntiSpoofingResult, onFacesDetected: Func_void_std__vector_SpoofDetectedFace_?, onStableFaceDetected: Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult?, onError: Func_void_std__exception_ptr?): SpoofDetectorOutputOptions {
102
- return SpoofDetectorOutputOptions(targetResolution, antispoofLevel, stableFrames, requiredLiveFrames, laplacianThreshold, maxNeuralSpoofScore, uiUpdateIntervalMs, onResult, onFacesDetected, onStableFaceDetected, onError)
96
+ private fun fromCpp(targetResolution: Size?, antispoofLevel: Double?, stableFrames: Double?, requiredLiveFrames: Double?, laplacianThreshold: Double?, maxNeuralSpoofScore: Double?, onResult: Func_void_AntiSpoofingResult, onFacesDetected: Func_void_std__vector_SpoofDetectedFace_?, onStableFaceDetected: Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult?, onError: Func_void_std__exception_ptr?): SpoofDetectorOutputOptions {
97
+ return SpoofDetectorOutputOptions(targetResolution, antispoofLevel, stableFrames, requiredLiveFrames, laplacianThreshold, maxNeuralSpoofScore, onResult, onFacesDetected, onStableFaceDetected, onError)
103
98
  }
104
99
  }
105
100
  }
@@ -18,7 +18,7 @@ public extension SpoofDetectorOutputOptions {
18
18
  /**
19
19
  * Create a new instance of `SpoofDetectorOutputOptions`.
20
20
  */
21
- init(targetResolution: Size?, antispoofLevel: Double?, stableFrames: Double?, requiredLiveFrames: Double?, laplacianThreshold: Double?, maxNeuralSpoofScore: Double?, uiUpdateIntervalMs: Double?, onResult: @escaping (_ result: AntiSpoofingResult) -> Void, onFacesDetected: ((_ faces: [SpoofDetectedFace]) -> Void)?, onStableFaceDetected: ((_ face: SpoofDetectedFaceBounds, _ result: AntiSpoofingResult) -> Void)?, onError: ((_ error: Error) -> Void)?) {
21
+ init(targetResolution: Size?, antispoofLevel: Double?, stableFrames: Double?, requiredLiveFrames: Double?, laplacianThreshold: Double?, maxNeuralSpoofScore: Double?, onResult: @escaping (_ result: AntiSpoofingResult) -> Void, onFacesDetected: ((_ faces: [SpoofDetectedFace]) -> Void)?, onStableFaceDetected: ((_ face: SpoofDetectedFaceBounds, _ result: AntiSpoofingResult) -> Void)?, onError: ((_ error: Error) -> Void)?) {
22
22
  self.init({ () -> bridge.std__optional_Size_ in
23
23
  if let __unwrappedValue = targetResolution {
24
24
  return bridge.create_std__optional_Size_(__unwrappedValue)
@@ -55,12 +55,6 @@ public extension SpoofDetectorOutputOptions {
55
55
  } else {
56
56
  return .init()
57
57
  }
58
- }(), { () -> bridge.std__optional_double_ in
59
- if let __unwrappedValue = uiUpdateIntervalMs {
60
- return bridge.create_std__optional_double_(__unwrappedValue)
61
- } else {
62
- return .init()
63
- }
64
58
  }(), { () -> bridge.Func_void_AntiSpoofingResult in
65
59
  let __closureWrapper = Func_void_AntiSpoofingResult(onResult)
66
60
  return bridge.create_Func_void_AntiSpoofingResult(__closureWrapper.toUnsafe())
@@ -159,18 +153,6 @@ public extension SpoofDetectorOutputOptions {
159
153
  }()
160
154
  }
161
155
 
162
- @inline(__always)
163
- var uiUpdateIntervalMs: Double? {
164
- return { () -> Double? in
165
- if bridge.has_value_std__optional_double_(self.__uiUpdateIntervalMs) {
166
- let __unwrapped = bridge.get_std__optional_double_(self.__uiUpdateIntervalMs)
167
- return __unwrapped
168
- } else {
169
- return nil
170
- }
171
- }()
172
- }
173
-
174
156
  @inline(__always)
175
157
  var onResult: (_ result: AntiSpoofingResult) -> Void {
176
158
  return { () -> (AntiSpoofingResult) -> Void in
@@ -59,7 +59,6 @@ namespace margelo::nitro::camera::spoofdetector {
59
59
  std::optional<double> requiredLiveFrames SWIFT_PRIVATE;
60
60
  std::optional<double> laplacianThreshold SWIFT_PRIVATE;
61
61
  std::optional<double> maxNeuralSpoofScore SWIFT_PRIVATE;
62
- std::optional<double> uiUpdateIntervalMs SWIFT_PRIVATE;
63
62
  std::function<void(const AntiSpoofingResult& /* result */)> onResult SWIFT_PRIVATE;
64
63
  std::optional<std::function<void(const std::vector<SpoofDetectedFace>& /* faces */)>> onFacesDetected SWIFT_PRIVATE;
65
64
  std::optional<std::function<void(const SpoofDetectedFaceBounds& /* face */, const AntiSpoofingResult& /* result */)>> onStableFaceDetected SWIFT_PRIVATE;
@@ -67,7 +66,7 @@ namespace margelo::nitro::camera::spoofdetector {
67
66
 
68
67
  public:
69
68
  SpoofDetectorOutputOptions() = default;
70
- explicit SpoofDetectorOutputOptions(std::optional<Size> targetResolution, std::optional<double> antispoofLevel, std::optional<double> stableFrames, std::optional<double> requiredLiveFrames, std::optional<double> laplacianThreshold, std::optional<double> maxNeuralSpoofScore, std::optional<double> uiUpdateIntervalMs, std::function<void(const AntiSpoofingResult& /* result */)> onResult, std::optional<std::function<void(const std::vector<SpoofDetectedFace>& /* faces */)>> onFacesDetected, std::optional<std::function<void(const SpoofDetectedFaceBounds& /* face */, const AntiSpoofingResult& /* result */)>> onStableFaceDetected, std::optional<std::function<void(const std::exception_ptr& /* error */)>> onError): targetResolution(targetResolution), antispoofLevel(antispoofLevel), stableFrames(stableFrames), requiredLiveFrames(requiredLiveFrames), laplacianThreshold(laplacianThreshold), maxNeuralSpoofScore(maxNeuralSpoofScore), uiUpdateIntervalMs(uiUpdateIntervalMs), onResult(onResult), onFacesDetected(onFacesDetected), onStableFaceDetected(onStableFaceDetected), onError(onError) {}
69
+ explicit SpoofDetectorOutputOptions(std::optional<Size> targetResolution, std::optional<double> antispoofLevel, std::optional<double> stableFrames, std::optional<double> requiredLiveFrames, std::optional<double> laplacianThreshold, std::optional<double> maxNeuralSpoofScore, std::function<void(const AntiSpoofingResult& /* result */)> onResult, std::optional<std::function<void(const std::vector<SpoofDetectedFace>& /* faces */)>> onFacesDetected, std::optional<std::function<void(const SpoofDetectedFaceBounds& /* face */, const AntiSpoofingResult& /* result */)>> onStableFaceDetected, std::optional<std::function<void(const std::exception_ptr& /* error */)>> onError): targetResolution(targetResolution), antispoofLevel(antispoofLevel), stableFrames(stableFrames), requiredLiveFrames(requiredLiveFrames), laplacianThreshold(laplacianThreshold), maxNeuralSpoofScore(maxNeuralSpoofScore), onResult(onResult), onFacesDetected(onFacesDetected), onStableFaceDetected(onStableFaceDetected), onError(onError) {}
71
70
 
72
71
  public:
73
72
  // SpoofDetectorOutputOptions is not equatable because these properties are not equatable: onResult, onFacesDetected, onStableFaceDetected, onError
@@ -89,7 +88,6 @@ namespace margelo::nitro {
89
88
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requiredLiveFrames"))),
90
89
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "laplacianThreshold"))),
91
90
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxNeuralSpoofScore"))),
92
- JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uiUpdateIntervalMs"))),
93
91
  JSIConverter<std::function<void(const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onResult"))),
94
92
  JSIConverter<std::optional<std::function<void(const std::vector<margelo::nitro::camera::spoofdetector::SpoofDetectedFace>&)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onFacesDetected"))),
95
93
  JSIConverter<std::optional<std::function<void(const margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds&, const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onStableFaceDetected"))),
@@ -104,7 +102,6 @@ namespace margelo::nitro {
104
102
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "requiredLiveFrames"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.requiredLiveFrames));
105
103
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "laplacianThreshold"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.laplacianThreshold));
106
104
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxNeuralSpoofScore"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxNeuralSpoofScore));
107
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "uiUpdateIntervalMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.uiUpdateIntervalMs));
108
105
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "onResult"), JSIConverter<std::function<void(const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>::toJSI(runtime, arg.onResult));
109
106
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "onFacesDetected"), JSIConverter<std::optional<std::function<void(const std::vector<margelo::nitro::camera::spoofdetector::SpoofDetectedFace>&)>>>::toJSI(runtime, arg.onFacesDetected));
110
107
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "onStableFaceDetected"), JSIConverter<std::optional<std::function<void(const margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds&, const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>>::toJSI(runtime, arg.onStableFaceDetected));
@@ -125,7 +122,6 @@ namespace margelo::nitro {
125
122
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requiredLiveFrames")))) return false;
126
123
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "laplacianThreshold")))) return false;
127
124
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxNeuralSpoofScore")))) return false;
128
- if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uiUpdateIntervalMs")))) return false;
129
125
  if (!JSIConverter<std::function<void(const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onResult")))) return false;
130
126
  if (!JSIConverter<std::optional<std::function<void(const std::vector<margelo::nitro::camera::spoofdetector::SpoofDetectedFace>&)>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onFacesDetected")))) return false;
131
127
  if (!JSIConverter<std::optional<std::function<void(const margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds&, const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onStableFaceDetected")))) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-vision-camera-spoof-detector",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "High-performance face anti-spoofing and liveness detection module for React Native Vision Camera. Uses TensorFlow Lite with GPU acceleration and optimized YUV processing.",
5
5
  "homepage": "https://github.com/dpraful/react-native-vision-camera-spoof-detector",
6
6
  "repository": {
@@ -26,7 +26,6 @@ export interface SpoofDetectorOutputOptions {
26
26
  requiredLiveFrames?: number
27
27
  laplacianThreshold?: number
28
28
  maxNeuralSpoofScore?: number
29
- uiUpdateIntervalMs?: number
30
29
  onResult: (result: AntiSpoofingResult) => void
31
30
  onFacesDetected?: (faces: SpoofDetectedFace[]) => void
32
31
  onStableFaceDetected?: (