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.

Files changed (67) hide show
  1. package/.npmignore +16 -99
  2. package/README.md +5 -4
  3. package/android/CMakeLists.txt +29 -0
  4. package/android/build.gradle +26 -12
  5. package/android/fix-prefab.gradle +4 -0
  6. package/android/src/main/AndroidManifest.xml +1 -1
  7. package/android/src/main/cpp/CMakeLists.txt +18 -86
  8. package/android/src/main/cpp/FaceAntiSpoofJSI.cpp +80 -6
  9. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  10. package/android/src/main/java/com/faceantispoof/FaceAntiSpoofModule.kt +108 -103
  11. package/android/src/main/java/com/faceantispoof/FaceAntiSpoofPackage.kt +12 -27
  12. package/android/src/main/java/com/faceantispoof/FaceAntiSpoofingAdvanced.kt +58 -1
  13. package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactory.kt +15 -0
  14. package/android/src/main/java/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorOutput.kt +107 -0
  15. package/index.d.ts +14 -1
  16. package/index.js +26 -57
  17. package/nitro.json +20 -0
  18. package/nitrogen/generated/.gitattributes +1 -0
  19. package/nitrogen/generated/android/VisionCameraSpoofDetector+autolinking.cmake +81 -0
  20. package/nitrogen/generated/android/VisionCameraSpoofDetector+autolinking.gradle +27 -0
  21. package/nitrogen/generated/android/VisionCameraSpoofDetectorOnLoad.cpp +58 -0
  22. package/nitrogen/generated/android/VisionCameraSpoofDetectorOnLoad.hpp +34 -0
  23. package/nitrogen/generated/android/c++/JAntiSpoofingResult.hpp +77 -0
  24. package/nitrogen/generated/android/c++/JFunc_void_AntiSpoofingResult.hpp +78 -0
  25. package/nitrogen/generated/android/c++/JFunc_void_std__exception_ptr.hpp +76 -0
  26. package/nitrogen/generated/android/c++/JHybridSpoofDetectorFactorySpec.cpp +75 -0
  27. package/nitrogen/generated/android/c++/JHybridSpoofDetectorFactorySpec.hpp +63 -0
  28. package/nitrogen/generated/android/c++/JSize.hpp +61 -0
  29. package/nitrogen/generated/android/c++/JSpoofDetectorOutputOptions.hpp +91 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/AntiSpoofingResult.kt +76 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Func_void_AntiSpoofingResult.kt +78 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Func_void_std__exception_ptr.kt +78 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactorySpec.kt +57 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/Size.kt +56 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/SpoofDetectorOutputOptions.kt +65 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/spoofdetector/VisionCameraSpoofDetectorOnLoad.kt +35 -0
  37. package/nitrogen/generated/shared/c++/AntiSpoofingResult.hpp +103 -0
  38. package/nitrogen/generated/shared/c++/HybridSpoofDetectorFactorySpec.cpp +21 -0
  39. package/nitrogen/generated/shared/c++/HybridSpoofDetectorFactorySpec.hpp +67 -0
  40. package/nitrogen/generated/shared/c++/Size.hpp +87 -0
  41. package/nitrogen/generated/shared/c++/SpoofDetectorOutputOptions.hpp +98 -0
  42. package/package.json +12 -13
  43. package/react-native-vision-camera-spoof-detector.podspec +4 -4
  44. package/src/specs/SpoofDetectorFactory.nitro.ts +23 -0
  45. package/.gitattributes +0 -2
  46. package/CONTRIBUTING.md +0 -280
  47. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  48. package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
  49. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  50. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  51. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  52. package/android/.gradle/8.9/gc.properties +0 -0
  53. package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
  54. package/android/.gradle/9.2.0/checksums/md5-checksums.bin +0 -0
  55. package/android/.gradle/9.2.0/checksums/sha1-checksums.bin +0 -0
  56. package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
  57. package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
  58. package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
  59. package/android/.gradle/9.2.0/gc.properties +0 -0
  60. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  61. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  62. package/android/.gradle/vcs-1/gc.properties +0 -0
  63. package/android/build/reports/problems/problems-report.html +0 -659
  64. package/android/src/main/assets/spoof_model_scale_2_7.tflite +0 -0
  65. package/android/src/main/assets/spoof_model_scale_4_0.tflite +0 -0
  66. package/android/src/main/java/com/faceantispoof/FaceAntiSpoofFrameProcessor.kt +0 -198
  67. /package/{android/src/main → lib}/assets/FaceAntiSpoofing.tflite +0 -0
@@ -0,0 +1,81 @@
1
+ #
2
+ # VisionCameraSpoofDetector+autolinking.cmake
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
+ # This is a CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/VisionCameraSpoofDetector+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_VISIONCAMERASPOOFDETECTOR_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ VisionCameraSpoofDetector PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/VisionCameraSpoofDetectorOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridSpoofDetectorFactorySpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridSpoofDetectorFactorySpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ VisionCameraSpoofDetector PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ VisionCameraSpoofDetector
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ VisionCameraSpoofDetector
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ VisionCameraSpoofDetector
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// VisionCameraSpoofDetector+autolinking.gradle
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
+ /// This is a Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/VisionCameraSpoofDetector+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 VisionCameraSpoofDetector is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// VisionCameraSpoofDetectorOnLoad.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
+ #ifndef BUILDING_VISIONCAMERASPOOFDETECTOR_WITH_GENERATED_CMAKE_PROJECT
9
+ #error VisionCameraSpoofDetectorOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "VisionCameraSpoofDetectorOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridSpoofDetectorFactorySpec.hpp"
19
+ #include "JFunc_void_AntiSpoofingResult.hpp"
20
+ #include "JFunc_void_std__exception_ptr.hpp"
21
+ #include <NitroModules/DefaultConstructableObject.hpp>
22
+
23
+ namespace margelo::nitro::camera::spoofdetector {
24
+
25
+ int initialize(JavaVM* vm) {
26
+ return facebook::jni::initialize(vm, []() {
27
+ ::margelo::nitro::camera::spoofdetector::registerAllNatives();
28
+ });
29
+ }
30
+
31
+ struct JHybridSpoofDetectorFactorySpecImpl: public jni::JavaClass<JHybridSpoofDetectorFactorySpecImpl, JHybridSpoofDetectorFactorySpec::JavaPart> {
32
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactory;";
33
+ static std::shared_ptr<JHybridSpoofDetectorFactorySpec> create() {
34
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridSpoofDetectorFactorySpecImpl::javaobject()>();
35
+ jni::local_ref<JHybridSpoofDetectorFactorySpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
36
+ return javaPart->getJHybridSpoofDetectorFactorySpec();
37
+ }
38
+ };
39
+
40
+ void registerAllNatives() {
41
+ using namespace margelo::nitro;
42
+ using namespace margelo::nitro::camera::spoofdetector;
43
+
44
+ // Register native JNI methods
45
+ margelo::nitro::camera::spoofdetector::JHybridSpoofDetectorFactorySpec::CxxPart::registerNatives();
46
+ margelo::nitro::camera::spoofdetector::JFunc_void_AntiSpoofingResult_cxx::registerNatives();
47
+ margelo::nitro::camera::spoofdetector::JFunc_void_std__exception_ptr_cxx::registerNatives();
48
+
49
+ // Register Nitro Hybrid Objects
50
+ HybridObjectRegistry::registerHybridObjectConstructor(
51
+ "SpoofDetectorFactory",
52
+ []() -> std::shared_ptr<HybridObject> {
53
+ return JHybridSpoofDetectorFactorySpecImpl::create();
54
+ }
55
+ );
56
+ }
57
+
58
+ } // namespace margelo::nitro::camera::spoofdetector
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// VisionCameraSpoofDetectorOnLoad.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
+ #include <jni.h>
9
+ #include <functional>
10
+ #include <NitroModules/NitroDefines.hpp>
11
+
12
+ namespace margelo::nitro::camera::spoofdetector {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of VisionCameraSpoofDetector, and autolinks all Hybrid Objects.
19
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
20
+ * inside a `facebook::jni::initialize(vm, ...)` call.
21
+ * Example:
22
+ * ```cpp (cpp-adapter.cpp)
23
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
24
+ * return facebook::jni::initialize(vm, []() {
25
+ * // register all VisionCameraSpoofDetector HybridObjects
26
+ * margelo::nitro::camera::spoofdetector::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::camera::spoofdetector
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JAntiSpoofingResult.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 "AntiSpoofingResult.hpp"
12
+
13
+ #include <string>
14
+
15
+ namespace margelo::nitro::camera::spoofdetector {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "AntiSpoofingResult" and the Kotlin data class "AntiSpoofingResult".
21
+ */
22
+ struct JAntiSpoofingResult final: public jni::JavaClass<JAntiSpoofingResult> {
23
+ public:
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/AntiSpoofingResult;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct AntiSpoofingResult by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ AntiSpoofingResult toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldIsLive = clazz->getField<jboolean>("isLive");
35
+ jboolean isLive = this->getFieldValue(fieldIsLive);
36
+ static const auto fieldLabel = clazz->getField<jni::JString>("label");
37
+ jni::local_ref<jni::JString> label = this->getFieldValue(fieldLabel);
38
+ static const auto fieldNeuralNetworkScore = clazz->getField<double>("neuralNetworkScore");
39
+ double neuralNetworkScore = this->getFieldValue(fieldNeuralNetworkScore);
40
+ static const auto fieldLaplacianScore = clazz->getField<double>("laplacianScore");
41
+ double laplacianScore = this->getFieldValue(fieldLaplacianScore);
42
+ static const auto fieldCombinedScore = clazz->getField<double>("combinedScore");
43
+ double combinedScore = this->getFieldValue(fieldCombinedScore);
44
+ static const auto fieldConfidence = clazz->getField<double>("confidence");
45
+ double confidence = this->getFieldValue(fieldConfidence);
46
+ return AntiSpoofingResult(
47
+ static_cast<bool>(isLive),
48
+ label->toStdString(),
49
+ neuralNetworkScore,
50
+ laplacianScore,
51
+ combinedScore,
52
+ confidence
53
+ );
54
+ }
55
+
56
+ public:
57
+ /**
58
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
59
+ */
60
+ [[maybe_unused]]
61
+ static jni::local_ref<JAntiSpoofingResult::javaobject> fromCpp(const AntiSpoofingResult& value) {
62
+ using JSignature = JAntiSpoofingResult(jboolean, jni::alias_ref<jni::JString>, double, double, double, double);
63
+ static const auto clazz = javaClassStatic();
64
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
65
+ return create(
66
+ clazz,
67
+ value.isLive,
68
+ jni::make_jstring(value.label),
69
+ value.neuralNetworkScore,
70
+ value.laplacianScore,
71
+ value.combinedScore,
72
+ value.confidence
73
+ );
74
+ }
75
+ };
76
+
77
+ } // namespace margelo::nitro::camera::spoofdetector
@@ -0,0 +1,78 @@
1
+ ///
2
+ /// JFunc_void_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
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "AntiSpoofingResult.hpp"
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+ #include "JAntiSpoofingResult.hpp"
17
+ #include <string>
18
+
19
+ namespace margelo::nitro::camera::spoofdetector {
20
+
21
+ using namespace facebook;
22
+
23
+ /**
24
+ * Represents the Java/Kotlin callback `(result: AntiSpoofingResult) -> Unit`.
25
+ * This can be passed around between C++ and Java/Kotlin.
26
+ */
27
+ struct JFunc_void_AntiSpoofingResult: public jni::JavaClass<JFunc_void_AntiSpoofingResult> {
28
+ public:
29
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/Func_void_AntiSpoofingResult;";
30
+
31
+ public:
32
+ /**
33
+ * Invokes the function this `JFunc_void_AntiSpoofingResult` instance holds through JNI.
34
+ */
35
+ void invoke(const AntiSpoofingResult& result) const {
36
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAntiSpoofingResult> /* result */)>("invoke");
37
+ method(self(), JAntiSpoofingResult::fromCpp(result));
38
+ }
39
+ };
40
+
41
+ /**
42
+ * An implementation of Func_void_AntiSpoofingResult that is backed by a C++ implementation (using `std::function<...>`)
43
+ */
44
+ class JFunc_void_AntiSpoofingResult_cxx final: public jni::HybridClass<JFunc_void_AntiSpoofingResult_cxx, JFunc_void_AntiSpoofingResult> {
45
+ public:
46
+ static jni::local_ref<JFunc_void_AntiSpoofingResult::javaobject> fromCpp(const std::function<void(const AntiSpoofingResult& /* result */)>& func) {
47
+ return JFunc_void_AntiSpoofingResult_cxx::newObjectCxxArgs(func);
48
+ }
49
+
50
+ public:
51
+ /**
52
+ * Invokes the C++ `std::function<...>` this `JFunc_void_AntiSpoofingResult_cxx` instance holds.
53
+ */
54
+ void invoke_cxx(jni::alias_ref<JAntiSpoofingResult> result) {
55
+ _func(result->toCpp());
56
+ }
57
+
58
+ public:
59
+ [[nodiscard]]
60
+ inline const std::function<void(const AntiSpoofingResult& /* result */)>& getFunction() const {
61
+ return _func;
62
+ }
63
+
64
+ public:
65
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/Func_void_AntiSpoofingResult_cxx;";
66
+ static void registerNatives() {
67
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_AntiSpoofingResult_cxx::invoke_cxx)});
68
+ }
69
+
70
+ private:
71
+ explicit JFunc_void_AntiSpoofingResult_cxx(const std::function<void(const AntiSpoofingResult& /* result */)>& func): _func(func) { }
72
+
73
+ private:
74
+ friend HybridBase;
75
+ std::function<void(const AntiSpoofingResult& /* result */)> _func;
76
+ };
77
+
78
+ } // namespace margelo::nitro::camera::spoofdetector
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// JFunc_void_std__exception_ptr.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 <functional>
12
+
13
+ #include <exception>
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+
17
+ namespace margelo::nitro::camera::spoofdetector {
18
+
19
+ using namespace facebook;
20
+
21
+ /**
22
+ * Represents the Java/Kotlin callback `(error: Throwable) -> Unit`.
23
+ * This can be passed around between C++ and Java/Kotlin.
24
+ */
25
+ struct JFunc_void_std__exception_ptr: public jni::JavaClass<JFunc_void_std__exception_ptr> {
26
+ public:
27
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/Func_void_std__exception_ptr;";
28
+
29
+ public:
30
+ /**
31
+ * Invokes the function this `JFunc_void_std__exception_ptr` instance holds through JNI.
32
+ */
33
+ void invoke(const std::exception_ptr& error) const {
34
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JThrowable> /* error */)>("invoke");
35
+ method(self(), jni::getJavaExceptionForCppException(error));
36
+ }
37
+ };
38
+
39
+ /**
40
+ * An implementation of Func_void_std__exception_ptr that is backed by a C++ implementation (using `std::function<...>`)
41
+ */
42
+ class JFunc_void_std__exception_ptr_cxx final: public jni::HybridClass<JFunc_void_std__exception_ptr_cxx, JFunc_void_std__exception_ptr> {
43
+ public:
44
+ static jni::local_ref<JFunc_void_std__exception_ptr::javaobject> fromCpp(const std::function<void(const std::exception_ptr& /* error */)>& func) {
45
+ return JFunc_void_std__exception_ptr_cxx::newObjectCxxArgs(func);
46
+ }
47
+
48
+ public:
49
+ /**
50
+ * Invokes the C++ `std::function<...>` this `JFunc_void_std__exception_ptr_cxx` instance holds.
51
+ */
52
+ void invoke_cxx(jni::alias_ref<jni::JThrowable> error) {
53
+ _func(std::make_exception_ptr(jni::JniException(error)));
54
+ }
55
+
56
+ public:
57
+ [[nodiscard]]
58
+ inline const std::function<void(const std::exception_ptr& /* error */)>& getFunction() const {
59
+ return _func;
60
+ }
61
+
62
+ public:
63
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/Func_void_std__exception_ptr_cxx;";
64
+ static void registerNatives() {
65
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__exception_ptr_cxx::invoke_cxx)});
66
+ }
67
+
68
+ private:
69
+ explicit JFunc_void_std__exception_ptr_cxx(const std::function<void(const std::exception_ptr& /* error */)>& func): _func(func) { }
70
+
71
+ private:
72
+ friend HybridBase;
73
+ std::function<void(const std::exception_ptr& /* error */)> _func;
74
+ };
75
+
76
+ } // namespace margelo::nitro::camera::spoofdetector
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JHybridSpoofDetectorFactorySpec.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 "JHybridSpoofDetectorFactorySpec.hpp"
9
+
10
+ // Forward declaration of `HybridCameraOutputSpec` to properly resolve imports.
11
+ namespace margelo::nitro::camera { class HybridCameraOutputSpec; }
12
+ // Forward declaration of `SpoofDetectorOutputOptions` to properly resolve imports.
13
+ namespace margelo::nitro::camera::spoofdetector { struct SpoofDetectorOutputOptions; }
14
+ // Forward declaration of `Size` to properly resolve imports.
15
+ namespace margelo::nitro::camera::spoofdetector { struct Size; }
16
+ // Forward declaration of `AntiSpoofingResult` to properly resolve imports.
17
+ namespace margelo::nitro::camera::spoofdetector { struct AntiSpoofingResult; }
18
+
19
+ #include <memory>
20
+ #include <VisionCamera/HybridCameraOutputSpec.hpp>
21
+ #include <VisionCamera/JHybridCameraOutputSpec.hpp>
22
+ #include "SpoofDetectorOutputOptions.hpp"
23
+ #include "JSpoofDetectorOutputOptions.hpp"
24
+ #include "Size.hpp"
25
+ #include <optional>
26
+ #include "JSize.hpp"
27
+ #include "AntiSpoofingResult.hpp"
28
+ #include <functional>
29
+ #include "JFunc_void_AntiSpoofingResult.hpp"
30
+ #include <NitroModules/JNICallable.hpp>
31
+ #include "JAntiSpoofingResult.hpp"
32
+ #include <string>
33
+ #include <exception>
34
+ #include "JFunc_void_std__exception_ptr.hpp"
35
+
36
+ namespace margelo::nitro::camera::spoofdetector {
37
+
38
+ std::shared_ptr<JHybridSpoofDetectorFactorySpec> JHybridSpoofDetectorFactorySpec::JavaPart::getJHybridSpoofDetectorFactorySpec() {
39
+ auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
40
+ auto castHybridObject = std::dynamic_pointer_cast<JHybridSpoofDetectorFactorySpec>(hybridObject);
41
+ if (castHybridObject == nullptr) [[unlikely]] {
42
+ throw std::runtime_error("Failed to downcast JHybridObject to JHybridSpoofDetectorFactorySpec!");
43
+ }
44
+ return castHybridObject;
45
+ }
46
+
47
+ jni::local_ref<JHybridSpoofDetectorFactorySpec::CxxPart::jhybriddata> JHybridSpoofDetectorFactorySpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
48
+ return makeCxxInstance(jThis);
49
+ }
50
+
51
+ std::shared_ptr<JHybridObject> JHybridSpoofDetectorFactorySpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
52
+ auto castJavaPart = jni::dynamic_ref_cast<JHybridSpoofDetectorFactorySpec::JavaPart>(javaPart);
53
+ if (castJavaPart == nullptr) [[unlikely]] {
54
+ throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridSpoofDetectorFactorySpec::JavaPart!");
55
+ }
56
+ return std::make_shared<JHybridSpoofDetectorFactorySpec>(castJavaPart);
57
+ }
58
+
59
+ void JHybridSpoofDetectorFactorySpec::CxxPart::registerNatives() {
60
+ registerHybrid({
61
+ makeNativeMethod("initHybrid", JHybridSpoofDetectorFactorySpec::CxxPart::initHybrid),
62
+ });
63
+ }
64
+
65
+ // Properties
66
+
67
+
68
+ // Methods
69
+ std::shared_ptr<margelo::nitro::camera::HybridCameraOutputSpec> JHybridSpoofDetectorFactorySpec::createSpoofDetectorOutput(const SpoofDetectorOutputOptions& options) {
70
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<margelo::nitro::camera::JHybridCameraOutputSpec::JavaPart>(jni::alias_ref<JSpoofDetectorOutputOptions> /* options */)>("createSpoofDetectorOutput");
71
+ auto __result = method(_javaPart, JSpoofDetectorOutputOptions::fromCpp(options));
72
+ return __result->getJHybridCameraOutputSpec();
73
+ }
74
+
75
+ } // namespace margelo::nitro::camera::spoofdetector
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridSpoofDetectorFactorySpec.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 <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridSpoofDetectorFactorySpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::camera::spoofdetector {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridSpoofDetectorFactorySpec: public virtual HybridSpoofDetectorFactorySpec, public virtual JHybridObject {
22
+ public:
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactorySpec;";
25
+ std::shared_ptr<JHybridSpoofDetectorFactorySpec> getJHybridSpoofDetectorFactorySpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/HybridSpoofDetectorFactorySpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
35
+
36
+ public:
37
+ explicit JHybridSpoofDetectorFactorySpec(const jni::local_ref<JHybridSpoofDetectorFactorySpec::JavaPart>& javaPart):
38
+ HybridObject(HybridSpoofDetectorFactorySpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
41
+ ~JHybridSpoofDetectorFactorySpec() override {
42
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
43
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
44
+ }
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridSpoofDetectorFactorySpec::JavaPart>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ std::shared_ptr<margelo::nitro::camera::HybridCameraOutputSpec> createSpoofDetectorOutput(const SpoofDetectorOutputOptions& options) override;
58
+
59
+ private:
60
+ jni::global_ref<JHybridSpoofDetectorFactorySpec::JavaPart> _javaPart;
61
+ };
62
+
63
+ } // namespace margelo::nitro::camera::spoofdetector
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JSize.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 "Size.hpp"
12
+
13
+
14
+
15
+ namespace margelo::nitro::camera::spoofdetector {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "Size" and the Kotlin data class "Size".
21
+ */
22
+ struct JSize final: public jni::JavaClass<JSize> {
23
+ public:
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/camera/spoofdetector/Size;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct Size by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ Size toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldWidth = clazz->getField<double>("width");
35
+ double width = this->getFieldValue(fieldWidth);
36
+ static const auto fieldHeight = clazz->getField<double>("height");
37
+ double height = this->getFieldValue(fieldHeight);
38
+ return Size(
39
+ width,
40
+ height
41
+ );
42
+ }
43
+
44
+ public:
45
+ /**
46
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
47
+ */
48
+ [[maybe_unused]]
49
+ static jni::local_ref<JSize::javaobject> fromCpp(const Size& value) {
50
+ using JSignature = JSize(double, double);
51
+ static const auto clazz = javaClassStatic();
52
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
53
+ return create(
54
+ clazz,
55
+ value.width,
56
+ value.height
57
+ );
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::camera::spoofdetector