react-native-vision-camera-spoof-detector 1.0.28 → 1.1.7
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.
Potentially problematic release.
This version of react-native-vision-camera-spoof-detector might be problematic. Click here for more details.
- package/.npmignore +16 -99
- package/README.md +5 -4
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +26 -12
- package/android/fix-prefab.gradle +4 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/cpp/CMakeLists.txt +18 -86
- package/android/src/main/cpp/FaceAntiSpoofJSI.cpp +80 -6
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofModule.kt +108 -103
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofPackage.kt +12 -27
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofingAdvanced.kt +58 -1
- package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactory.kt +15 -0
- package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorOutput.kt +107 -0
- package/index.d.ts +14 -1
- package/index.js +26 -57
- package/nitro.json +20 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/VisionCameraSpoofDetector+autolinking.cmake +81 -0
- package/nitrogen/generated/android/VisionCameraSpoofDetector+autolinking.gradle +27 -0
- package/nitrogen/generated/android/VisionCameraSpoofDetectorOnLoad.cpp +58 -0
- package/nitrogen/generated/android/VisionCameraSpoofDetectorOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JAntiSpoofingResult.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_AntiSpoofingResult.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__exception_ptr.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridSpoofDetectorFactorySpec.cpp +75 -0
- package/nitrogen/generated/android/c++/JHybridSpoofDetectorFactorySpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JSize.hpp +61 -0
- package/nitrogen/generated/android/c++/JSpoofDetectorOutputOptions.hpp +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/AntiSpoofingResult.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Func_void_AntiSpoofingResult.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Func_void_std__exception_ptr.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactorySpec.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Size.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/SpoofDetectorOutputOptions.kt +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/VisionCameraSpoofDetectorOnLoad.kt +35 -0
- package/nitrogen/generated/shared/c++/AntiSpoofingResult.hpp +103 -0
- package/nitrogen/generated/shared/c++/HybridSpoofDetectorFactorySpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridSpoofDetectorFactorySpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/Size.hpp +87 -0
- package/nitrogen/generated/shared/c++/SpoofDetectorOutputOptions.hpp +98 -0
- package/package.json +12 -13
- package/react-native-vision-camera-spoof-detector.podspec +4 -4
- package/src/specs/SpoofDetectorFactory.nitro.ts +23 -0
- package/.gitattributes +0 -2
- package/CONTRIBUTING.md +0 -280
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
- package/android/.gradle/9.2.0/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/9.2.0/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.2.0/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/reports/problems/problems-report.html +0 -659
- package/android/src/main/assets/spoof_model_scale_2_7.tflite +0 -0
- package/android/src/main/assets/spoof_model_scale_4_0.tflite +0 -0
- package/android/src/main/java/com/faceantispoof/FaceAntiSpoofFrameProcessor.kt +0 -198
- /package/{android/src/main → lib}/assets/FaceAntiSpoofing.tflite +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSpoofDetectorOutputOptions.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "SpoofDetectorOutputOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "AntiSpoofingResult.hpp"
|
|
14
|
+
#include "JAntiSpoofingResult.hpp"
|
|
15
|
+
#include "JFunc_void_AntiSpoofingResult.hpp"
|
|
16
|
+
#include "JFunc_void_std__exception_ptr.hpp"
|
|
17
|
+
#include "JSize.hpp"
|
|
18
|
+
#include "Size.hpp"
|
|
19
|
+
#include <NitroModules/JNICallable.hpp>
|
|
20
|
+
#include <exception>
|
|
21
|
+
#include <functional>
|
|
22
|
+
#include <optional>
|
|
23
|
+
#include <string>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::camera::spoofdetector {
|
|
26
|
+
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The C++ JNI bridge between the C++ struct "SpoofDetectorOutputOptions" and the Kotlin data class "SpoofDetectorOutputOptions".
|
|
31
|
+
*/
|
|
32
|
+
struct JSpoofDetectorOutputOptions final: public jni::JavaClass<JSpoofDetectorOutputOptions> {
|
|
33
|
+
public:
|
|
34
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/SpoofDetectorOutputOptions;";
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
/**
|
|
38
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SpoofDetectorOutputOptions by copying all values to C++.
|
|
39
|
+
*/
|
|
40
|
+
[[maybe_unused]]
|
|
41
|
+
[[nodiscard]]
|
|
42
|
+
SpoofDetectorOutputOptions toCpp() const {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
static const auto fieldTargetResolution = clazz->getField<JSize>("targetResolution");
|
|
45
|
+
jni::local_ref<JSize> targetResolution = this->getFieldValue(fieldTargetResolution);
|
|
46
|
+
static const auto fieldOnResult = clazz->getField<JFunc_void_AntiSpoofingResult::javaobject>("onResult");
|
|
47
|
+
jni::local_ref<JFunc_void_AntiSpoofingResult::javaobject> onResult = this->getFieldValue(fieldOnResult);
|
|
48
|
+
static const auto fieldOnError = clazz->getField<JFunc_void_std__exception_ptr::javaobject>("onError");
|
|
49
|
+
jni::local_ref<JFunc_void_std__exception_ptr::javaobject> onError = this->getFieldValue(fieldOnError);
|
|
50
|
+
return SpoofDetectorOutputOptions(
|
|
51
|
+
targetResolution != nullptr ? std::make_optional(targetResolution->toCpp()) : std::nullopt,
|
|
52
|
+
[&]() -> std::function<void(const AntiSpoofingResult& /* result */)> {
|
|
53
|
+
if (onResult->isInstanceOf(JFunc_void_AntiSpoofingResult_cxx::javaClassStatic())) [[likely]] {
|
|
54
|
+
auto downcast = jni::static_ref_cast<JFunc_void_AntiSpoofingResult_cxx::javaobject>(onResult);
|
|
55
|
+
return downcast->cthis()->getFunction();
|
|
56
|
+
} else {
|
|
57
|
+
auto onResultRef = jni::make_global(onResult);
|
|
58
|
+
return JNICallable<JFunc_void_AntiSpoofingResult, void(AntiSpoofingResult)>(std::move(onResultRef));
|
|
59
|
+
}
|
|
60
|
+
}(),
|
|
61
|
+
onError != nullptr ? std::make_optional([&]() -> std::function<void(const std::exception_ptr& /* error */)> {
|
|
62
|
+
if (onError->isInstanceOf(JFunc_void_std__exception_ptr_cxx::javaClassStatic())) [[likely]] {
|
|
63
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__exception_ptr_cxx::javaobject>(onError);
|
|
64
|
+
return downcast->cthis()->getFunction();
|
|
65
|
+
} else {
|
|
66
|
+
auto onErrorRef = jni::make_global(onError);
|
|
67
|
+
return JNICallable<JFunc_void_std__exception_ptr, void(std::exception_ptr)>(std::move(onErrorRef));
|
|
68
|
+
}
|
|
69
|
+
}()) : std::nullopt
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public:
|
|
74
|
+
/**
|
|
75
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
76
|
+
*/
|
|
77
|
+
[[maybe_unused]]
|
|
78
|
+
static jni::local_ref<JSpoofDetectorOutputOptions::javaobject> fromCpp(const SpoofDetectorOutputOptions& value) {
|
|
79
|
+
using JSignature = JSpoofDetectorOutputOptions(jni::alias_ref<JSize>, jni::alias_ref<JFunc_void_AntiSpoofingResult::javaobject>, jni::alias_ref<JFunc_void_std__exception_ptr::javaobject>);
|
|
80
|
+
static const auto clazz = javaClassStatic();
|
|
81
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
82
|
+
return create(
|
|
83
|
+
clazz,
|
|
84
|
+
value.targetResolution.has_value() ? JSize::fromCpp(value.targetResolution.value()) : nullptr,
|
|
85
|
+
JFunc_void_AntiSpoofingResult_cxx::fromCpp(value.onResult),
|
|
86
|
+
value.onError.has_value() ? JFunc_void_std__exception_ptr_cxx::fromCpp(value.onError.value()) : nullptr
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
} // namespace margelo::nitro::camera::spoofdetector
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AntiSpoofingResult.kt
|
|
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
|
+
package com.margelo.nitro.camera.spoofdetector
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "AntiSpoofingResult".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class AntiSpoofingResult(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val isLive: Boolean,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val label: String,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val neuralNetworkScore: Double,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val laplacianScore: Double,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val combinedScore: Double,
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
val confidence: Double
|
|
39
|
+
) {
|
|
40
|
+
/* primary constructor */
|
|
41
|
+
|
|
42
|
+
override fun equals(other: Any?): Boolean {
|
|
43
|
+
if (this === other) return true
|
|
44
|
+
if (other !is AntiSpoofingResult) return false
|
|
45
|
+
return Objects.deepEquals(this.isLive, other.isLive)
|
|
46
|
+
&& Objects.deepEquals(this.label, other.label)
|
|
47
|
+
&& Objects.deepEquals(this.neuralNetworkScore, other.neuralNetworkScore)
|
|
48
|
+
&& Objects.deepEquals(this.laplacianScore, other.laplacianScore)
|
|
49
|
+
&& Objects.deepEquals(this.combinedScore, other.combinedScore)
|
|
50
|
+
&& Objects.deepEquals(this.confidence, other.confidence)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override fun hashCode(): Int {
|
|
54
|
+
return arrayOf<Any?>(
|
|
55
|
+
isLive,
|
|
56
|
+
label,
|
|
57
|
+
neuralNetworkScore,
|
|
58
|
+
laplacianScore,
|
|
59
|
+
combinedScore,
|
|
60
|
+
confidence
|
|
61
|
+
).contentDeepHashCode()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
companion object {
|
|
65
|
+
/**
|
|
66
|
+
* Constructor called from C++
|
|
67
|
+
*/
|
|
68
|
+
@DoNotStrip
|
|
69
|
+
@Keep
|
|
70
|
+
@Suppress("unused")
|
|
71
|
+
@JvmStatic
|
|
72
|
+
private fun fromCpp(isLive: Boolean, label: String, neuralNetworkScore: Double, laplacianScore: Double, combinedScore: Double, confidence: Double): AntiSpoofingResult {
|
|
73
|
+
return AntiSpoofingResult(isLive, label, neuralNetworkScore, laplacianScore, combinedScore, confidence)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_AntiSpoofingResult.kt
|
|
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
|
+
package com.margelo.nitro.camera.spoofdetector
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript callback `(result: struct) => void`.
|
|
17
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
+
fun interface Func_void_AntiSpoofingResult: (AntiSpoofingResult) -> Unit {
|
|
24
|
+
/**
|
|
25
|
+
* Call the given JS callback.
|
|
26
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
+
*/
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
@Keep
|
|
30
|
+
override fun invoke(result: AntiSpoofingResult): Unit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the JavaScript callback `(result: struct) => void`.
|
|
35
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
+
* The callback might be coming from JS.
|
|
37
|
+
*/
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
@Suppress(
|
|
41
|
+
"KotlinJniMissingFunction", "unused",
|
|
42
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
+
)
|
|
45
|
+
class Func_void_AntiSpoofingResult_cxx: Func_void_AntiSpoofingResult {
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
@Keep
|
|
48
|
+
private val mHybridData: HybridData
|
|
49
|
+
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
private constructor(hybridData: HybridData) {
|
|
53
|
+
mHybridData = hybridData
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
override fun invoke(result: AntiSpoofingResult): Unit
|
|
59
|
+
= invoke_cxx(result)
|
|
60
|
+
|
|
61
|
+
private external fun invoke_cxx(result: AntiSpoofingResult): Unit
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents the JavaScript callback `(result: struct) => void`.
|
|
66
|
+
* This is implemented in Java/Kotlin, via a `(AntiSpoofingResult) -> Unit`.
|
|
67
|
+
* The callback is always coming from native.
|
|
68
|
+
*/
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
+
class Func_void_AntiSpoofingResult_java(private val function: (AntiSpoofingResult) -> Unit): Func_void_AntiSpoofingResult {
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
override fun invoke(result: AntiSpoofingResult): Unit {
|
|
76
|
+
return this.function(result)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.kt
|
|
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
|
+
package com.margelo.nitro.camera.spoofdetector
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript callback `(error: error) => void`.
|
|
17
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
+
fun interface Func_void_std__exception_ptr: (Throwable) -> Unit {
|
|
24
|
+
/**
|
|
25
|
+
* Call the given JS callback.
|
|
26
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
+
*/
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
@Keep
|
|
30
|
+
override fun invoke(error: Throwable): Unit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the JavaScript callback `(error: error) => void`.
|
|
35
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
+
* The callback might be coming from JS.
|
|
37
|
+
*/
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
@Suppress(
|
|
41
|
+
"KotlinJniMissingFunction", "unused",
|
|
42
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
+
)
|
|
45
|
+
class Func_void_std__exception_ptr_cxx: Func_void_std__exception_ptr {
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
@Keep
|
|
48
|
+
private val mHybridData: HybridData
|
|
49
|
+
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
private constructor(hybridData: HybridData) {
|
|
53
|
+
mHybridData = hybridData
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
override fun invoke(error: Throwable): Unit
|
|
59
|
+
= invoke_cxx(error)
|
|
60
|
+
|
|
61
|
+
private external fun invoke_cxx(error: Throwable): Unit
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents the JavaScript callback `(error: error) => void`.
|
|
66
|
+
* This is implemented in Java/Kotlin, via a `(Throwable) -> Unit`.
|
|
67
|
+
* The callback is always coming from native.
|
|
68
|
+
*/
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
+
class Func_void_std__exception_ptr_java(private val function: (Throwable) -> Unit): Func_void_std__exception_ptr {
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
override fun invoke(error: Throwable): Unit {
|
|
76
|
+
return this.function(error)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSpoofDetectorFactorySpec.kt
|
|
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
|
+
package com.margelo.nitro.camera.spoofdetector
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
import com.margelo.nitro.camera.HybridCameraOutputSpec
|
|
15
|
+
import com.margelo.nitro.core.HybridObject
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A Kotlin class representing the SpoofDetectorFactory HybridObject.
|
|
19
|
+
* Implement this abstract class to create Kotlin-based instances of SpoofDetectorFactory.
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress(
|
|
24
|
+
"KotlinJniMissingFunction", "unused",
|
|
25
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
26
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
27
|
+
)
|
|
28
|
+
abstract class HybridSpoofDetectorFactorySpec: HybridObject() {
|
|
29
|
+
// Properties
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// Methods
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
abstract fun createSpoofDetectorOutput(options: SpoofDetectorOutputOptions): com.margelo.nitro.camera.HybridCameraOutputSpec
|
|
36
|
+
|
|
37
|
+
// Default implementation of `HybridObject.toString()`
|
|
38
|
+
override fun toString(): String {
|
|
39
|
+
return "[HybridObject SpoofDetectorFactory]"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// C++ backing class
|
|
43
|
+
@DoNotStrip
|
|
44
|
+
@Keep
|
|
45
|
+
protected open class CxxPart(javaPart: HybridSpoofDetectorFactorySpec): HybridObject.CxxPart(javaPart) {
|
|
46
|
+
// C++ JHybridSpoofDetectorFactorySpec::CxxPart::initHybrid(...)
|
|
47
|
+
@FastNative
|
|
48
|
+
external override fun initHybrid(): HybridData
|
|
49
|
+
}
|
|
50
|
+
override fun createCxxPart(): CxxPart {
|
|
51
|
+
return CxxPart(this)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
companion object {
|
|
55
|
+
protected const val TAG = "HybridSpoofDetectorFactorySpec"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Size.kt
|
|
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
|
+
package com.margelo.nitro.camera.spoofdetector
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "Size".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class Size(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val width: Double,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val height: Double
|
|
27
|
+
) {
|
|
28
|
+
/* primary constructor */
|
|
29
|
+
|
|
30
|
+
override fun equals(other: Any?): Boolean {
|
|
31
|
+
if (this === other) return true
|
|
32
|
+
if (other !is Size) return false
|
|
33
|
+
return Objects.deepEquals(this.width, other.width)
|
|
34
|
+
&& Objects.deepEquals(this.height, other.height)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun hashCode(): Int {
|
|
38
|
+
return arrayOf<Any?>(
|
|
39
|
+
width,
|
|
40
|
+
height
|
|
41
|
+
).contentDeepHashCode()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
/**
|
|
46
|
+
* Constructor called from C++
|
|
47
|
+
*/
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
@Suppress("unused")
|
|
51
|
+
@JvmStatic
|
|
52
|
+
private fun fromCpp(width: Double, height: Double): Size {
|
|
53
|
+
return Size(width, height)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SpoofDetectorOutputOptions.kt
|
|
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
|
+
package com.margelo.nitro.camera.spoofdetector
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "SpoofDetectorOutputOptions".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class SpoofDetectorOutputOptions(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val targetResolution: Size?,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val onResult: Func_void_AntiSpoofingResult,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val onError: Func_void_std__exception_ptr?
|
|
30
|
+
) {
|
|
31
|
+
/**
|
|
32
|
+
* Create a new instance of SpoofDetectorOutputOptions from Kotlin
|
|
33
|
+
*/
|
|
34
|
+
constructor(targetResolution: Size?, onResult: (result: AntiSpoofingResult) -> Unit, onError: ((error: Throwable) -> Unit)?):
|
|
35
|
+
this(targetResolution, Func_void_AntiSpoofingResult_java(onResult), onError?.let { Func_void_std__exception_ptr_java(it) })
|
|
36
|
+
|
|
37
|
+
override fun equals(other: Any?): Boolean {
|
|
38
|
+
if (this === other) return true
|
|
39
|
+
if (other !is SpoofDetectorOutputOptions) return false
|
|
40
|
+
return Objects.deepEquals(this.targetResolution, other.targetResolution)
|
|
41
|
+
&& Objects.deepEquals(this.onResult, other.onResult)
|
|
42
|
+
&& Objects.deepEquals(this.onError, other.onError)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun hashCode(): Int {
|
|
46
|
+
return arrayOf<Any?>(
|
|
47
|
+
targetResolution,
|
|
48
|
+
onResult,
|
|
49
|
+
onError
|
|
50
|
+
).contentDeepHashCode()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
companion object {
|
|
54
|
+
/**
|
|
55
|
+
* Constructor called from C++
|
|
56
|
+
*/
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
@Suppress("unused")
|
|
60
|
+
@JvmStatic
|
|
61
|
+
private fun fromCpp(targetResolution: Size?, onResult: Func_void_AntiSpoofingResult, onError: Func_void_std__exception_ptr?): SpoofDetectorOutputOptions {
|
|
62
|
+
return SpoofDetectorOutputOptions(targetResolution, onResult, onError)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// VisionCameraSpoofDetectorOnLoad.kt
|
|
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
|
+
package com.margelo.nitro.camera.spoofdetector
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class VisionCameraSpoofDetectorOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "VisionCameraSpoofDetectorOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "VisionCameraSpoofDetector".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading VisionCameraSpoofDetector C++ library...")
|
|
25
|
+
System.loadLibrary("VisionCameraSpoofDetector")
|
|
26
|
+
Log.i(TAG, "Successfully loaded VisionCameraSpoofDetector C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load VisionCameraSpoofDetector C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AntiSpoofingResult.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
|
+
#include <string>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::camera::spoofdetector {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (AntiSpoofingResult).
|
|
39
|
+
*/
|
|
40
|
+
struct AntiSpoofingResult final {
|
|
41
|
+
public:
|
|
42
|
+
bool isLive SWIFT_PRIVATE;
|
|
43
|
+
std::string label SWIFT_PRIVATE;
|
|
44
|
+
double neuralNetworkScore SWIFT_PRIVATE;
|
|
45
|
+
double laplacianScore SWIFT_PRIVATE;
|
|
46
|
+
double combinedScore SWIFT_PRIVATE;
|
|
47
|
+
double confidence SWIFT_PRIVATE;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
AntiSpoofingResult() = default;
|
|
51
|
+
explicit AntiSpoofingResult(bool isLive, std::string label, double neuralNetworkScore, double laplacianScore, double combinedScore, double confidence): isLive(isLive), label(label), neuralNetworkScore(neuralNetworkScore), laplacianScore(laplacianScore), combinedScore(combinedScore), confidence(confidence) {}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
friend bool operator==(const AntiSpoofingResult& lhs, const AntiSpoofingResult& rhs) = default;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::camera::spoofdetector
|
|
58
|
+
|
|
59
|
+
namespace margelo::nitro {
|
|
60
|
+
|
|
61
|
+
// C++ AntiSpoofingResult <> JS AntiSpoofingResult (object)
|
|
62
|
+
template <>
|
|
63
|
+
struct JSIConverter<margelo::nitro::camera::spoofdetector::AntiSpoofingResult> final {
|
|
64
|
+
static inline margelo::nitro::camera::spoofdetector::AntiSpoofingResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
65
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
66
|
+
return margelo::nitro::camera::spoofdetector::AntiSpoofingResult(
|
|
67
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isLive"))),
|
|
68
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "label"))),
|
|
69
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "neuralNetworkScore"))),
|
|
70
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "laplacianScore"))),
|
|
71
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "combinedScore"))),
|
|
72
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confidence")))
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::spoofdetector::AntiSpoofingResult& arg) {
|
|
76
|
+
jsi::Object obj(runtime);
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "isLive"), JSIConverter<bool>::toJSI(runtime, arg.isLive));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "label"), JSIConverter<std::string>::toJSI(runtime, arg.label));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "neuralNetworkScore"), JSIConverter<double>::toJSI(runtime, arg.neuralNetworkScore));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "laplacianScore"), JSIConverter<double>::toJSI(runtime, arg.laplacianScore));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "combinedScore"), JSIConverter<double>::toJSI(runtime, arg.combinedScore));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "confidence"), JSIConverter<double>::toJSI(runtime, arg.confidence));
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
86
|
+
if (!value.isObject()) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
jsi::Object obj = value.getObject(runtime);
|
|
90
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isLive")))) return false;
|
|
94
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "label")))) return false;
|
|
95
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "neuralNetworkScore")))) return false;
|
|
96
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "laplacianScore")))) return false;
|
|
97
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "combinedScore")))) return false;
|
|
98
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confidence")))) return false;
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSpoofDetectorFactorySpec.cpp
|
|
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
|
+
#include "HybridSpoofDetectorFactorySpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::camera::spoofdetector {
|
|
11
|
+
|
|
12
|
+
void HybridSpoofDetectorFactorySpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("createSpoofDetectorOutput", &HybridSpoofDetectorFactorySpec::createSpoofDetectorOutput);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::camera::spoofdetector
|