react-native-vision-camera-spoof-detector 1.2.1 → 1.2.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 +12 -3
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofingAdvanced.kt +18 -2
- 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 +404 -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
|
@@ -32,11 +32,18 @@
|
|
|
32
32
|
namespace margelo::nitro::camera::spoofdetector { struct Size; }
|
|
33
33
|
// Forward declaration of `AntiSpoofingResult` to properly resolve imports.
|
|
34
34
|
namespace margelo::nitro::camera::spoofdetector { struct AntiSpoofingResult; }
|
|
35
|
+
// Forward declaration of `SpoofDetectedFace` to properly resolve imports.
|
|
36
|
+
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectedFace; }
|
|
37
|
+
// Forward declaration of `SpoofDetectedFaceBounds` to properly resolve imports.
|
|
38
|
+
namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectedFaceBounds; }
|
|
35
39
|
|
|
36
40
|
#include "Size.hpp"
|
|
37
41
|
#include <optional>
|
|
38
42
|
#include "AntiSpoofingResult.hpp"
|
|
39
43
|
#include <functional>
|
|
44
|
+
#include "SpoofDetectedFace.hpp"
|
|
45
|
+
#include <vector>
|
|
46
|
+
#include "SpoofDetectedFaceBounds.hpp"
|
|
40
47
|
#include <exception>
|
|
41
48
|
|
|
42
49
|
namespace margelo::nitro::camera::spoofdetector {
|
|
@@ -47,15 +54,23 @@ namespace margelo::nitro::camera::spoofdetector {
|
|
|
47
54
|
struct SpoofDetectorOutputOptions final {
|
|
48
55
|
public:
|
|
49
56
|
std::optional<Size> targetResolution SWIFT_PRIVATE;
|
|
57
|
+
std::optional<double> antispoofLevel SWIFT_PRIVATE;
|
|
58
|
+
std::optional<double> stableFrames SWIFT_PRIVATE;
|
|
59
|
+
std::optional<double> requiredLiveFrames SWIFT_PRIVATE;
|
|
60
|
+
std::optional<double> laplacianThreshold SWIFT_PRIVATE;
|
|
61
|
+
std::optional<double> maxNeuralSpoofScore SWIFT_PRIVATE;
|
|
62
|
+
std::optional<double> uiUpdateIntervalMs SWIFT_PRIVATE;
|
|
50
63
|
std::function<void(const AntiSpoofingResult& /* result */)> onResult SWIFT_PRIVATE;
|
|
64
|
+
std::optional<std::function<void(const std::vector<SpoofDetectedFace>& /* faces */)>> onFacesDetected SWIFT_PRIVATE;
|
|
65
|
+
std::optional<std::function<void(const SpoofDetectedFaceBounds& /* face */, const AntiSpoofingResult& /* result */)>> onStableFaceDetected SWIFT_PRIVATE;
|
|
51
66
|
std::optional<std::function<void(const std::exception_ptr& /* error */)>> onError SWIFT_PRIVATE;
|
|
52
67
|
|
|
53
68
|
public:
|
|
54
69
|
SpoofDetectorOutputOptions() = default;
|
|
55
|
-
explicit SpoofDetectorOutputOptions(std::optional<Size> targetResolution, std::function<void(const AntiSpoofingResult& /* result */)> onResult, std::optional<std::function<void(const std::exception_ptr& /* error */)>> onError): targetResolution(targetResolution), onResult(onResult), onError(onError) {}
|
|
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) {}
|
|
56
71
|
|
|
57
72
|
public:
|
|
58
|
-
// SpoofDetectorOutputOptions is not equatable because these properties are not equatable: onResult, onError
|
|
73
|
+
// SpoofDetectorOutputOptions is not equatable because these properties are not equatable: onResult, onFacesDetected, onStableFaceDetected, onError
|
|
59
74
|
};
|
|
60
75
|
|
|
61
76
|
} // namespace margelo::nitro::camera::spoofdetector
|
|
@@ -69,14 +84,30 @@ namespace margelo::nitro {
|
|
|
69
84
|
jsi::Object obj = arg.asObject(runtime);
|
|
70
85
|
return margelo::nitro::camera::spoofdetector::SpoofDetectorOutputOptions(
|
|
71
86
|
JSIConverter<std::optional<margelo::nitro::camera::spoofdetector::Size>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "targetResolution"))),
|
|
87
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "antispoofLevel"))),
|
|
88
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stableFrames"))),
|
|
89
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requiredLiveFrames"))),
|
|
90
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "laplacianThreshold"))),
|
|
91
|
+
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"))),
|
|
72
93
|
JSIConverter<std::function<void(const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onResult"))),
|
|
94
|
+
JSIConverter<std::optional<std::function<void(const std::vector<margelo::nitro::camera::spoofdetector::SpoofDetectedFace>&)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onFacesDetected"))),
|
|
95
|
+
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"))),
|
|
73
96
|
JSIConverter<std::optional<std::function<void(const std::exception_ptr&)>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onError")))
|
|
74
97
|
);
|
|
75
98
|
}
|
|
76
99
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::spoofdetector::SpoofDetectorOutputOptions& arg) {
|
|
77
100
|
jsi::Object obj(runtime);
|
|
78
101
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "targetResolution"), JSIConverter<std::optional<margelo::nitro::camera::spoofdetector::Size>>::toJSI(runtime, arg.targetResolution));
|
|
102
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "antispoofLevel"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.antispoofLevel));
|
|
103
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "stableFrames"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.stableFrames));
|
|
104
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "requiredLiveFrames"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.requiredLiveFrames));
|
|
105
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "laplacianThreshold"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.laplacianThreshold));
|
|
106
|
+
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));
|
|
79
108
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "onResult"), JSIConverter<std::function<void(const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>::toJSI(runtime, arg.onResult));
|
|
109
|
+
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
|
+
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));
|
|
80
111
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "onError"), JSIConverter<std::optional<std::function<void(const std::exception_ptr&)>>>::toJSI(runtime, arg.onError));
|
|
81
112
|
return obj;
|
|
82
113
|
}
|
|
@@ -89,7 +120,15 @@ namespace margelo::nitro {
|
|
|
89
120
|
return false;
|
|
90
121
|
}
|
|
91
122
|
if (!JSIConverter<std::optional<margelo::nitro::camera::spoofdetector::Size>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "targetResolution")))) return false;
|
|
123
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "antispoofLevel")))) return false;
|
|
124
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stableFrames")))) return false;
|
|
125
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requiredLiveFrames")))) return false;
|
|
126
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "laplacianThreshold")))) return false;
|
|
127
|
+
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;
|
|
92
129
|
if (!JSIConverter<std::function<void(const margelo::nitro::camera::spoofdetector::AntiSpoofingResult&)>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onResult")))) return false;
|
|
130
|
+
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
|
+
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;
|
|
93
132
|
if (!JSIConverter<std::optional<std::function<void(const std::exception_ptr&)>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onError")))) return false;
|
|
94
133
|
return true;
|
|
95
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-vision-camera-spoof-detector",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.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": {
|
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
import type { CameraOutput, Size } from 'react-native-vision-camera'
|
|
2
|
-
import type { HybridObject } from 'react-native-nitro-modules'
|
|
3
|
-
|
|
4
|
-
export interface AntiSpoofingResult {
|
|
5
|
-
isLive: boolean
|
|
6
|
-
label: string
|
|
7
|
-
neuralNetworkScore: number
|
|
8
|
-
laplacianScore: number
|
|
9
|
-
combinedScore: number
|
|
10
|
-
confidence: number
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import type { CameraOutput, Size } from 'react-native-vision-camera'
|
|
2
|
+
import type { HybridObject } from 'react-native-nitro-modules'
|
|
3
|
+
|
|
4
|
+
export interface AntiSpoofingResult {
|
|
5
|
+
isLive: boolean
|
|
6
|
+
label: string
|
|
7
|
+
neuralNetworkScore: number
|
|
8
|
+
laplacianScore: number
|
|
9
|
+
combinedScore: number
|
|
10
|
+
confidence: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SpoofDetectedFaceBounds {
|
|
14
|
+
x: number
|
|
15
|
+
y: number
|
|
16
|
+
width: number
|
|
17
|
+
height: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SpoofDetectedFace {
|
|
21
|
+
bounds: SpoofDetectedFaceBounds
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SpoofDetectorOutputOptions {
|
|
25
|
+
targetResolution?: Size
|
|
26
|
+
antispoofLevel?: number
|
|
27
|
+
stableFrames?: number
|
|
28
|
+
requiredLiveFrames?: number
|
|
29
|
+
laplacianThreshold?: number
|
|
30
|
+
maxNeuralSpoofScore?: number
|
|
31
|
+
uiUpdateIntervalMs?: number
|
|
32
|
+
onResult: (result: AntiSpoofingResult) => void
|
|
33
|
+
onFacesDetected?: (faces: SpoofDetectedFace[]) => void
|
|
34
|
+
onStableFaceDetected?: (
|
|
35
|
+
face: SpoofDetectedFaceBounds,
|
|
36
|
+
result: AntiSpoofingResult,
|
|
37
|
+
) => void
|
|
38
|
+
onError?: (error: Error) => void
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SpoofDetectorFactory extends HybridObject<{
|
|
42
|
+
ios: 'swift'
|
|
43
|
+
android: 'kotlin'
|
|
44
|
+
}> {
|
|
45
|
+
createSpoofDetectorOutput(options: SpoofDetectorOutputOptions): CameraOutput
|
|
46
|
+
resetSpoofDetectorOutput(output: CameraOutput): void
|
|
47
|
+
}
|