react-native-vision-camera-spoof-detector 1.2.1 → 1.2.4
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 +12 -3
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactory.kt +4 -0
- package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorOutput.kt +403 -214
- package/index.d.ts +14 -0
- package/index.js +50 -3
- package/ios/HybridSpoofDetectorOutput.swift +186 -2
- package/nitrogen/generated/android/VisionCameraSpoofDetectorOnLoad.cpp +4 -0
- package/nitrogen/generated/android/c++/JFunc_void_SpoofDetectedFaceBounds_AntiSpoofingResult.hpp +80 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_SpoofDetectedFace_.hpp +98 -0
- package/nitrogen/generated/android/c++/JHybridSpoofDetectorFactorySpec.cpp +15 -0
- package/nitrogen/generated/android/c++/JHybridSpoofDetectorFactorySpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JSpoofDetectedFace.hpp +58 -0
- package/nitrogen/generated/android/c++/JSpoofDetectedFaceBounds.hpp +69 -0
- package/nitrogen/generated/android/c++/JSpoofDetectorOutputOptions.hpp +56 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Func_void_std__vector_SpoofDetectedFace_.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactorySpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/SpoofDetectedFace.kt +51 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/SpoofDetectedFaceBounds.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/SpoofDetectorOutputOptions.kt +44 -4
- package/nitrogen/generated/ios/VisionCameraSpoofDetector-Swift-Cxx-Bridge.cpp +16 -0
- package/nitrogen/generated/ios/VisionCameraSpoofDetector-Swift-Cxx-Bridge.hpp +116 -0
- package/nitrogen/generated/ios/VisionCameraSpoofDetector-Swift-Cxx-Umbrella.hpp +7 -0
- package/nitrogen/generated/ios/c++/HybridSpoofDetectorFactorySpecSwift.hpp +13 -0
- package/nitrogen/generated/ios/swift/Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_SpoofDetectedFace_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridSpoofDetectorFactorySpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridSpoofDetectorFactorySpec_cxx.swift +15 -0
- package/nitrogen/generated/ios/swift/SpoofDetectedFace.swift +29 -0
- package/nitrogen/generated/ios/swift/SpoofDetectedFaceBounds.swift +44 -0
- package/nitrogen/generated/ios/swift/SpoofDetectorOutputOptions.swift +167 -1
- package/nitrogen/generated/shared/c++/HybridSpoofDetectorFactorySpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridSpoofDetectorFactorySpec.hpp +1 -0
- package/nitrogen/generated/shared/c++/SpoofDetectedFace.hpp +84 -0
- package/nitrogen/generated/shared/c++/SpoofDetectedFaceBounds.hpp +95 -0
- package/nitrogen/generated/shared/c++/SpoofDetectorOutputOptions.hpp +41 -2
- package/package.json +1 -1
- package/src/specs/SpoofDetectorFactory.nitro.ts +47 -24
|
@@ -16,6 +16,10 @@ namespace margelo::nitro::camera { class HybridCameraOutputSpec; }
|
|
|
16
16
|
namespace margelo::nitro::camera::spoofdetector { class HybridSpoofDetectorFactorySpec; }
|
|
17
17
|
// Forward declaration of `Size` to properly resolve imports.
|
|
18
18
|
namespace margelo::nitro::camera::spoofdetector { struct Size; }
|
|
19
|
+
// Forward declaration of `SpoofDetectedFaceBounds` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectedFaceBounds; }
|
|
21
|
+
// Forward declaration of `SpoofDetectedFace` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectedFace; }
|
|
19
23
|
// Forward declaration of `SpoofDetectorOutputOptions` to properly resolve imports.
|
|
20
24
|
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectorOutputOptions; }
|
|
21
25
|
|
|
@@ -23,6 +27,8 @@ namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectorOutputOpti
|
|
|
23
27
|
#include "AntiSpoofingResult.hpp"
|
|
24
28
|
#include "HybridSpoofDetectorFactorySpec.hpp"
|
|
25
29
|
#include "Size.hpp"
|
|
30
|
+
#include "SpoofDetectedFace.hpp"
|
|
31
|
+
#include "SpoofDetectedFaceBounds.hpp"
|
|
26
32
|
#include "SpoofDetectorOutputOptions.hpp"
|
|
27
33
|
#include <NitroModules/Result.hpp>
|
|
28
34
|
#include <VisionCamera/HybridCameraOutputSpec.hpp>
|
|
@@ -31,6 +37,7 @@ namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectorOutputOpti
|
|
|
31
37
|
#include <memory>
|
|
32
38
|
#include <optional>
|
|
33
39
|
#include <string>
|
|
40
|
+
#include <vector>
|
|
34
41
|
|
|
35
42
|
// C++ helpers for Swift
|
|
36
43
|
#include "VisionCameraSpoofDetector-Swift-Cxx-Bridge.hpp"
|
|
@@ -20,6 +20,10 @@ namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectorOutputOpti
|
|
|
20
20
|
namespace margelo::nitro::camera::spoofdetector { struct Size; }
|
|
21
21
|
// Forward declaration of `AntiSpoofingResult` to properly resolve imports.
|
|
22
22
|
namespace margelo::nitro::camera::spoofdetector { struct AntiSpoofingResult; }
|
|
23
|
+
// Forward declaration of `SpoofDetectedFace` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectedFace; }
|
|
25
|
+
// Forward declaration of `SpoofDetectedFaceBounds` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectedFaceBounds; }
|
|
23
27
|
|
|
24
28
|
#include <memory>
|
|
25
29
|
#include <VisionCamera/HybridCameraOutputSpec.hpp>
|
|
@@ -29,6 +33,9 @@ namespace margelo::nitro::camera::spoofdetector { struct AntiSpoofingResult; }
|
|
|
29
33
|
#include "AntiSpoofingResult.hpp"
|
|
30
34
|
#include <functional>
|
|
31
35
|
#include <string>
|
|
36
|
+
#include "SpoofDetectedFace.hpp"
|
|
37
|
+
#include <vector>
|
|
38
|
+
#include "SpoofDetectedFaceBounds.hpp"
|
|
32
39
|
#include <exception>
|
|
33
40
|
|
|
34
41
|
#include "VisionCameraSpoofDetector-Swift-Cxx-Umbrella.hpp"
|
|
@@ -89,6 +96,12 @@ namespace margelo::nitro::camera::spoofdetector {
|
|
|
89
96
|
auto __value = std::move(__result.value());
|
|
90
97
|
return __value;
|
|
91
98
|
}
|
|
99
|
+
inline void resetSpoofDetectorOutput(const std::shared_ptr<margelo::nitro::camera::HybridCameraOutputSpec>& output) override {
|
|
100
|
+
auto __result = _swiftPart.resetSpoofDetectorOutput(output);
|
|
101
|
+
if (__result.hasError()) [[unlikely]] {
|
|
102
|
+
std::rethrow_exception(__result.error());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
92
105
|
|
|
93
106
|
private:
|
|
94
107
|
VisionCameraSpoofDetector::HybridSpoofDetectorFactorySpec_cxx _swiftPart;
|
package/nitrogen/generated/ios/swift/Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult.swift
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ face: SpoofDetectedFaceBounds, _ result: AntiSpoofingResult) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult {
|
|
15
|
+
public typealias bridge = margelo.nitro.camera.spoofdetector.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ face: SpoofDetectedFaceBounds, _ result: AntiSpoofingResult) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ face: SpoofDetectedFaceBounds, _ result: AntiSpoofingResult) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(face: SpoofDetectedFaceBounds, result: AntiSpoofingResult) -> Void {
|
|
25
|
+
self.closure(face, result)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult {
|
|
44
|
+
return Unmanaged<Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__vector_SpoofDetectedFace_.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ faces: [SpoofDetectedFace]) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__vector_SpoofDetectedFace_ {
|
|
15
|
+
public typealias bridge = margelo.nitro.camera.spoofdetector.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ faces: [SpoofDetectedFace]) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ faces: [SpoofDetectedFace]) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(faces: bridge.std__vector_SpoofDetectedFace_) -> Void {
|
|
25
|
+
self.closure(faces.map({ __item in __item }))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__vector_SpoofDetectedFace_`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_SpoofDetectedFace_>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_SpoofDetectedFace_ {
|
|
44
|
+
return Unmanaged<Func_void_std__vector_SpoofDetectedFace_>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -15,6 +15,7 @@ public protocol HybridSpoofDetectorFactorySpec_protocol: HybridObject {
|
|
|
15
15
|
|
|
16
16
|
// Methods
|
|
17
17
|
func createSpoofDetectorOutput(options: SpoofDetectorOutputOptions) throws -> (any HybridCameraOutputSpec)
|
|
18
|
+
func resetSpoofDetectorOutput(output: (any HybridCameraOutputSpec)) throws -> Void
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
public extension HybridSpoofDetectorFactorySpec_protocol {
|
|
@@ -139,4 +139,19 @@ open class HybridSpoofDetectorFactorySpec_cxx {
|
|
|
139
139
|
return bridge.create_Result_std__shared_ptr_margelo__nitro__camera__HybridCameraOutputSpec__(__exceptionPtr)
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
@inline(__always)
|
|
144
|
+
public final func resetSpoofDetectorOutput(output: bridge.std__shared_ptr_margelo__nitro__camera__HybridCameraOutputSpec_) -> bridge.Result_void_ {
|
|
145
|
+
do {
|
|
146
|
+
try self.__implementation.resetSpoofDetectorOutput(output: { () -> any HybridCameraOutputSpec in
|
|
147
|
+
let __unsafePointer = bridge.get_std__shared_ptr_margelo__nitro__camera__HybridCameraOutputSpec_(output)
|
|
148
|
+
let __instance = HybridCameraOutputSpec_cxx.fromUnsafe(__unsafePointer)
|
|
149
|
+
return __instance.getHybridCameraOutputSpec()
|
|
150
|
+
}())
|
|
151
|
+
return bridge.create_Result_void_()
|
|
152
|
+
} catch (let __error) {
|
|
153
|
+
let __exceptionPtr = __error.toCpp()
|
|
154
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
142
157
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SpoofDetectedFace.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `SpoofDetectedFace`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias SpoofDetectedFace = margelo.nitro.camera.spoofdetector.SpoofDetectedFace
|
|
14
|
+
|
|
15
|
+
public extension SpoofDetectedFace {
|
|
16
|
+
private typealias bridge = margelo.nitro.camera.spoofdetector.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `SpoofDetectedFace`.
|
|
20
|
+
*/
|
|
21
|
+
init(bounds: SpoofDetectedFaceBounds) {
|
|
22
|
+
self.init(bounds)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var bounds: SpoofDetectedFaceBounds {
|
|
27
|
+
return self.__bounds
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SpoofDetectedFaceBounds.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `SpoofDetectedFaceBounds`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias SpoofDetectedFaceBounds = margelo.nitro.camera.spoofdetector.SpoofDetectedFaceBounds
|
|
14
|
+
|
|
15
|
+
public extension SpoofDetectedFaceBounds {
|
|
16
|
+
private typealias bridge = margelo.nitro.camera.spoofdetector.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `SpoofDetectedFaceBounds`.
|
|
20
|
+
*/
|
|
21
|
+
init(x: Double, y: Double, width: Double, height: Double) {
|
|
22
|
+
self.init(x, y, width, height)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var x: Double {
|
|
27
|
+
return self.__x
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var y: Double {
|
|
32
|
+
return self.__y
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var width: Double {
|
|
37
|
+
return self.__width
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var height: Double {
|
|
42
|
+
return self.__height
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -18,16 +18,70 @@ public extension SpoofDetectorOutputOptions {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `SpoofDetectorOutputOptions`.
|
|
20
20
|
*/
|
|
21
|
-
init(targetResolution: Size?, onResult: @escaping (_ result: AntiSpoofingResult) -> Void, onError: ((_ error: Error) -> Void)?) {
|
|
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)?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_Size_ in
|
|
23
23
|
if let __unwrappedValue = targetResolution {
|
|
24
24
|
return bridge.create_std__optional_Size_(__unwrappedValue)
|
|
25
25
|
} else {
|
|
26
26
|
return .init()
|
|
27
27
|
}
|
|
28
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
29
|
+
if let __unwrappedValue = antispoofLevel {
|
|
30
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
35
|
+
if let __unwrappedValue = stableFrames {
|
|
36
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
41
|
+
if let __unwrappedValue = requiredLiveFrames {
|
|
42
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
43
|
+
} else {
|
|
44
|
+
return .init()
|
|
45
|
+
}
|
|
46
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
47
|
+
if let __unwrappedValue = laplacianThreshold {
|
|
48
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
49
|
+
} else {
|
|
50
|
+
return .init()
|
|
51
|
+
}
|
|
52
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
53
|
+
if let __unwrappedValue = maxNeuralSpoofScore {
|
|
54
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
55
|
+
} else {
|
|
56
|
+
return .init()
|
|
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
|
+
}
|
|
28
64
|
}(), { () -> bridge.Func_void_AntiSpoofingResult in
|
|
29
65
|
let __closureWrapper = Func_void_AntiSpoofingResult(onResult)
|
|
30
66
|
return bridge.create_Func_void_AntiSpoofingResult(__closureWrapper.toUnsafe())
|
|
67
|
+
}(), { () -> bridge.std__optional_std__function_void_const_std__vector_SpoofDetectedFace______faces______ in
|
|
68
|
+
if let __unwrappedValue = onFacesDetected {
|
|
69
|
+
return bridge.create_std__optional_std__function_void_const_std__vector_SpoofDetectedFace______faces______({ () -> bridge.Func_void_std__vector_SpoofDetectedFace_ in
|
|
70
|
+
let __closureWrapper = Func_void_std__vector_SpoofDetectedFace_(__unwrappedValue)
|
|
71
|
+
return bridge.create_Func_void_std__vector_SpoofDetectedFace_(__closureWrapper.toUnsafe())
|
|
72
|
+
}())
|
|
73
|
+
} else {
|
|
74
|
+
return .init()
|
|
75
|
+
}
|
|
76
|
+
}(), { () -> bridge.std__optional_std__function_void_const_SpoofDetectedFaceBounds_____face_____const_AntiSpoofingResult_____result______ in
|
|
77
|
+
if let __unwrappedValue = onStableFaceDetected {
|
|
78
|
+
return bridge.create_std__optional_std__function_void_const_SpoofDetectedFaceBounds_____face_____const_AntiSpoofingResult_____result______({ () -> bridge.Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult in
|
|
79
|
+
let __closureWrapper = Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult(__unwrappedValue)
|
|
80
|
+
return bridge.create_Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult(__closureWrapper.toUnsafe())
|
|
81
|
+
}())
|
|
82
|
+
} else {
|
|
83
|
+
return .init()
|
|
84
|
+
}
|
|
31
85
|
}(), { () -> bridge.std__optional_std__function_void_const_std__exception_ptr_____error______ in
|
|
32
86
|
if let __unwrappedValue = onError {
|
|
33
87
|
return bridge.create_std__optional_std__function_void_const_std__exception_ptr_____error______({ () -> bridge.Func_void_std__exception_ptr in
|
|
@@ -45,6 +99,78 @@ public extension SpoofDetectorOutputOptions {
|
|
|
45
99
|
return self.__targetResolution.value
|
|
46
100
|
}
|
|
47
101
|
|
|
102
|
+
@inline(__always)
|
|
103
|
+
var antispoofLevel: Double? {
|
|
104
|
+
return { () -> Double? in
|
|
105
|
+
if bridge.has_value_std__optional_double_(self.__antispoofLevel) {
|
|
106
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__antispoofLevel)
|
|
107
|
+
return __unwrapped
|
|
108
|
+
} else {
|
|
109
|
+
return nil
|
|
110
|
+
}
|
|
111
|
+
}()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@inline(__always)
|
|
115
|
+
var stableFrames: Double? {
|
|
116
|
+
return { () -> Double? in
|
|
117
|
+
if bridge.has_value_std__optional_double_(self.__stableFrames) {
|
|
118
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__stableFrames)
|
|
119
|
+
return __unwrapped
|
|
120
|
+
} else {
|
|
121
|
+
return nil
|
|
122
|
+
}
|
|
123
|
+
}()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@inline(__always)
|
|
127
|
+
var requiredLiveFrames: Double? {
|
|
128
|
+
return { () -> Double? in
|
|
129
|
+
if bridge.has_value_std__optional_double_(self.__requiredLiveFrames) {
|
|
130
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__requiredLiveFrames)
|
|
131
|
+
return __unwrapped
|
|
132
|
+
} else {
|
|
133
|
+
return nil
|
|
134
|
+
}
|
|
135
|
+
}()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@inline(__always)
|
|
139
|
+
var laplacianThreshold: Double? {
|
|
140
|
+
return { () -> Double? in
|
|
141
|
+
if bridge.has_value_std__optional_double_(self.__laplacianThreshold) {
|
|
142
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__laplacianThreshold)
|
|
143
|
+
return __unwrapped
|
|
144
|
+
} else {
|
|
145
|
+
return nil
|
|
146
|
+
}
|
|
147
|
+
}()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@inline(__always)
|
|
151
|
+
var maxNeuralSpoofScore: Double? {
|
|
152
|
+
return { () -> Double? in
|
|
153
|
+
if bridge.has_value_std__optional_double_(self.__maxNeuralSpoofScore) {
|
|
154
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__maxNeuralSpoofScore)
|
|
155
|
+
return __unwrapped
|
|
156
|
+
} else {
|
|
157
|
+
return nil
|
|
158
|
+
}
|
|
159
|
+
}()
|
|
160
|
+
}
|
|
161
|
+
|
|
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
|
+
|
|
48
174
|
@inline(__always)
|
|
49
175
|
var onResult: (_ result: AntiSpoofingResult) -> Void {
|
|
50
176
|
return { () -> (AntiSpoofingResult) -> Void in
|
|
@@ -55,6 +181,46 @@ public extension SpoofDetectorOutputOptions {
|
|
|
55
181
|
}()
|
|
56
182
|
}
|
|
57
183
|
|
|
184
|
+
@inline(__always)
|
|
185
|
+
var onFacesDetected: ((_ faces: [SpoofDetectedFace]) -> Void)? {
|
|
186
|
+
return { () -> ((_ faces: [SpoofDetectedFace]) -> Void)? in
|
|
187
|
+
if bridge.has_value_std__optional_std__function_void_const_std__vector_SpoofDetectedFace______faces______(self.__onFacesDetected) {
|
|
188
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_std__vector_SpoofDetectedFace______faces______(self.__onFacesDetected)
|
|
189
|
+
return { () -> ([SpoofDetectedFace]) -> Void in
|
|
190
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__vector_SpoofDetectedFace_(__unwrapped)
|
|
191
|
+
return { (__faces: [SpoofDetectedFace]) -> Void in
|
|
192
|
+
__wrappedFunction.call({ () -> bridge.std__vector_SpoofDetectedFace_ in
|
|
193
|
+
var __vector = bridge.create_std__vector_SpoofDetectedFace_(__faces.count)
|
|
194
|
+
for __item in __faces {
|
|
195
|
+
__vector.push_back(__item)
|
|
196
|
+
}
|
|
197
|
+
return __vector
|
|
198
|
+
}())
|
|
199
|
+
}
|
|
200
|
+
}()
|
|
201
|
+
} else {
|
|
202
|
+
return nil
|
|
203
|
+
}
|
|
204
|
+
}()
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@inline(__always)
|
|
208
|
+
var onStableFaceDetected: ((_ face: SpoofDetectedFaceBounds, _ result: AntiSpoofingResult) -> Void)? {
|
|
209
|
+
return { () -> ((_ face: SpoofDetectedFaceBounds, _ result: AntiSpoofingResult) -> Void)? in
|
|
210
|
+
if bridge.has_value_std__optional_std__function_void_const_SpoofDetectedFaceBounds_____face_____const_AntiSpoofingResult_____result______(self.__onStableFaceDetected) {
|
|
211
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_SpoofDetectedFaceBounds_____face_____const_AntiSpoofingResult_____result______(self.__onStableFaceDetected)
|
|
212
|
+
return { () -> (SpoofDetectedFaceBounds, AntiSpoofingResult) -> Void in
|
|
213
|
+
let __wrappedFunction = bridge.wrap_Func_void_SpoofDetectedFaceBounds_AntiSpoofingResult(__unwrapped)
|
|
214
|
+
return { (__face: SpoofDetectedFaceBounds, __result: AntiSpoofingResult) -> Void in
|
|
215
|
+
__wrappedFunction.call(__face, __result)
|
|
216
|
+
}
|
|
217
|
+
}()
|
|
218
|
+
} else {
|
|
219
|
+
return nil
|
|
220
|
+
}
|
|
221
|
+
}()
|
|
222
|
+
}
|
|
223
|
+
|
|
58
224
|
@inline(__always)
|
|
59
225
|
var onError: ((_ error: Error) -> Void)? {
|
|
60
226
|
return { () -> ((_ error: Error) -> Void)? in
|
|
@@ -15,6 +15,7 @@ namespace margelo::nitro::camera::spoofdetector {
|
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
17
|
prototype.registerHybridMethod("createSpoofDetectorOutput", &HybridSpoofDetectorFactorySpec::createSpoofDetectorOutput);
|
|
18
|
+
prototype.registerHybridMethod("resetSpoofDetectorOutput", &HybridSpoofDetectorFactorySpec::resetSpoofDetectorOutput);
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -54,6 +54,7 @@ namespace margelo::nitro::camera::spoofdetector {
|
|
|
54
54
|
public:
|
|
55
55
|
// Methods
|
|
56
56
|
virtual std::shared_ptr<margelo::nitro::camera::HybridCameraOutputSpec> createSpoofDetectorOutput(const SpoofDetectorOutputOptions& options) = 0;
|
|
57
|
+
virtual void resetSpoofDetectorOutput(const std::shared_ptr<margelo::nitro::camera::HybridCameraOutputSpec>& output) = 0;
|
|
57
58
|
|
|
58
59
|
protected:
|
|
59
60
|
// Hybrid Setup
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SpoofDetectedFace.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `SpoofDetectedFaceBounds` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectedFaceBounds; }
|
|
33
|
+
|
|
34
|
+
#include "SpoofDetectedFaceBounds.hpp"
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::camera::spoofdetector {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (SpoofDetectedFace).
|
|
40
|
+
*/
|
|
41
|
+
struct SpoofDetectedFace final {
|
|
42
|
+
public:
|
|
43
|
+
SpoofDetectedFaceBounds bounds SWIFT_PRIVATE;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
SpoofDetectedFace() = default;
|
|
47
|
+
explicit SpoofDetectedFace(SpoofDetectedFaceBounds bounds): bounds(bounds) {}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
friend bool operator==(const SpoofDetectedFace& lhs, const SpoofDetectedFace& rhs) = default;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace margelo::nitro::camera::spoofdetector
|
|
54
|
+
|
|
55
|
+
namespace margelo::nitro {
|
|
56
|
+
|
|
57
|
+
// C++ SpoofDetectedFace <> JS SpoofDetectedFace (object)
|
|
58
|
+
template <>
|
|
59
|
+
struct JSIConverter<margelo::nitro::camera::spoofdetector::SpoofDetectedFace> final {
|
|
60
|
+
static inline margelo::nitro::camera::spoofdetector::SpoofDetectedFace fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
61
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
62
|
+
return margelo::nitro::camera::spoofdetector::SpoofDetectedFace(
|
|
63
|
+
JSIConverter<margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bounds")))
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::spoofdetector::SpoofDetectedFace& arg) {
|
|
67
|
+
jsi::Object obj(runtime);
|
|
68
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bounds"), JSIConverter<margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds>::toJSI(runtime, arg.bounds));
|
|
69
|
+
return obj;
|
|
70
|
+
}
|
|
71
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
72
|
+
if (!value.isObject()) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
jsi::Object obj = value.getObject(runtime);
|
|
76
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (!JSIConverter<margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bounds")))) return false;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SpoofDetectedFaceBounds.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::camera::spoofdetector {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (SpoofDetectedFaceBounds).
|
|
39
|
+
*/
|
|
40
|
+
struct SpoofDetectedFaceBounds final {
|
|
41
|
+
public:
|
|
42
|
+
double x SWIFT_PRIVATE;
|
|
43
|
+
double y SWIFT_PRIVATE;
|
|
44
|
+
double width SWIFT_PRIVATE;
|
|
45
|
+
double height SWIFT_PRIVATE;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
SpoofDetectedFaceBounds() = default;
|
|
49
|
+
explicit SpoofDetectedFaceBounds(double x, double y, double width, double height): x(x), y(y), width(width), height(height) {}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
friend bool operator==(const SpoofDetectedFaceBounds& lhs, const SpoofDetectedFaceBounds& rhs) = default;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace margelo::nitro::camera::spoofdetector
|
|
56
|
+
|
|
57
|
+
namespace margelo::nitro {
|
|
58
|
+
|
|
59
|
+
// C++ SpoofDetectedFaceBounds <> JS SpoofDetectedFaceBounds (object)
|
|
60
|
+
template <>
|
|
61
|
+
struct JSIConverter<margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds> final {
|
|
62
|
+
static inline margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
+
return margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds(
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "x"))),
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "y"))),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::spoofdetector::SpoofDetectedFaceBounds& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "x"), JSIConverter<double>::toJSI(runtime, arg.x));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "y"), JSIConverter<double>::toJSI(runtime, arg.y));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
80
|
+
if (!value.isObject()) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
jsi::Object obj = value.getObject(runtime);
|
|
84
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "x")))) return false;
|
|
88
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "y")))) return false;
|
|
89
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
|
|
90
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace margelo::nitro
|