react-native-vision-camera-spoof-detector 1.0.22 → 1.0.24
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 +442 -442
- package/android/.gradle/9.2.0/checksums/checksums.lock +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/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/android/build/reports/problems/problems-report.html +659 -0
- package/android/build.gradle +12 -4
- package/android/src/main/cpp/CMakeLists.txt +101 -94
- package/android/src/main/cpp/libyuv/.clang-format +6 -6
- package/android/src/main/cpp/libyuv/.gn +40 -40
- package/android/src/main/cpp/libyuv/.vpython3 +410 -410
- package/android/src/main/cpp/libyuv/AUTHORS +7 -7
- package/android/src/main/cpp/libyuv/Android.bp +202 -202
- package/android/src/main/cpp/libyuv/Android.mk +106 -106
- package/android/src/main/cpp/libyuv/BUILD.gn +490 -490
- package/android/src/main/cpp/libyuv/CM_linux_packages.cmake +70 -70
- package/android/src/main/cpp/libyuv/CMakeLists.txt +259 -252
- package/android/src/main/cpp/libyuv/DEPS +935 -935
- package/android/src/main/cpp/libyuv/DIR_METADATA +3 -3
- package/android/src/main/cpp/libyuv/LICENSE +29 -29
- package/android/src/main/cpp/libyuv/OWNERS +11 -11
- package/android/src/main/cpp/libyuv/PATENTS +23 -23
- package/android/src/main/cpp/libyuv/PRESUBMIT.py +65 -65
- package/android/src/main/cpp/libyuv/README.chromium +11 -11
- package/android/src/main/cpp/libyuv/README.md +19 -19
- package/android/src/main/cpp/libyuv/build_overrides/build.gni +60 -60
- package/android/src/main/cpp/libyuv/build_overrides/gtest.gni +19 -19
- package/android/src/main/cpp/libyuv/build_overrides/partition_alloc.gni +17 -17
- package/android/src/main/cpp/libyuv/codereview.settings +5 -5
- package/android/src/main/cpp/libyuv/docs/deprecated_builds.md +409 -409
- package/android/src/main/cpp/libyuv/docs/environment_variables.md +64 -64
- package/android/src/main/cpp/libyuv/docs/feature_detection.md +108 -108
- package/android/src/main/cpp/libyuv/docs/filtering.md +196 -196
- package/android/src/main/cpp/libyuv/docs/formats.md +208 -208
- package/android/src/main/cpp/libyuv/docs/getting_started.md +296 -296
- package/android/src/main/cpp/libyuv/docs/rotation.md +107 -107
- package/android/src/main/cpp/libyuv/download_vs_toolchain.py +29 -29
- package/android/src/main/cpp/libyuv/include/libyuv/basic_types.h +68 -68
- package/android/src/main/cpp/libyuv/include/libyuv/compare.h +111 -111
- package/android/src/main/cpp/libyuv/include/libyuv/compare_row.h +112 -112
- package/android/src/main/cpp/libyuv/include/libyuv/convert.h +1117 -1117
- package/android/src/main/cpp/libyuv/include/libyuv/convert_argb.h +2335 -2335
- package/android/src/main/cpp/libyuv/include/libyuv/convert_from.h +203 -203
- package/android/src/main/cpp/libyuv/include/libyuv/convert_from_argb.h +394 -394
- package/android/src/main/cpp/libyuv/include/libyuv/cpu_id.h +147 -147
- package/android/src/main/cpp/libyuv/include/libyuv/cpu_support.h +99 -99
- package/android/src/main/cpp/libyuv/include/libyuv/loongson_intrinsics.h +1949 -1949
- package/android/src/main/cpp/libyuv/include/libyuv/mjpeg_decoder.h +195 -195
- package/android/src/main/cpp/libyuv/include/libyuv/planar_functions.h +1131 -1131
- package/android/src/main/cpp/libyuv/include/libyuv/rotate.h +296 -296
- package/android/src/main/cpp/libyuv/include/libyuv/rotate_argb.h +37 -37
- package/android/src/main/cpp/libyuv/include/libyuv/rotate_row.h +265 -265
- package/android/src/main/cpp/libyuv/include/libyuv/row.h +6738 -6738
- package/android/src/main/cpp/libyuv/include/libyuv/row_sve.h +2154 -2154
- package/android/src/main/cpp/libyuv/include/libyuv/scale.h +336 -336
- package/android/src/main/cpp/libyuv/include/libyuv/scale_argb.h +76 -76
- package/android/src/main/cpp/libyuv/include/libyuv/scale_rgb.h +42 -42
- package/android/src/main/cpp/libyuv/include/libyuv/scale_row.h +1726 -1726
- package/android/src/main/cpp/libyuv/include/libyuv/scale_uv.h +51 -51
- package/android/src/main/cpp/libyuv/include/libyuv/version.h +16 -16
- package/android/src/main/cpp/libyuv/include/libyuv/video_common.h +222 -222
- package/android/src/main/cpp/libyuv/include/libyuv.h +33 -33
- package/android/src/main/cpp/libyuv/infra/config/OWNERS +3 -3
- package/android/src/main/cpp/libyuv/infra/config/PRESUBMIT.py +17 -17
- package/android/src/main/cpp/libyuv/infra/config/README.md +2 -2
- package/android/src/main/cpp/libyuv/infra/config/codereview.settings +6 -6
- package/android/src/main/cpp/libyuv/infra/config/commit-queue.cfg +144 -144
- package/android/src/main/cpp/libyuv/infra/config/cr-buildbucket.cfg +1185 -1185
- package/android/src/main/cpp/libyuv/infra/config/luci-logdog.cfg +9 -9
- package/android/src/main/cpp/libyuv/infra/config/luci-milo.cfg +246 -246
- package/android/src/main/cpp/libyuv/infra/config/luci-scheduler.cfg +385 -385
- package/android/src/main/cpp/libyuv/infra/config/main.star +402 -402
- package/android/src/main/cpp/libyuv/infra/config/project.cfg +16 -16
- package/android/src/main/cpp/libyuv/infra/config/realms.cfg +111 -111
- package/android/src/main/cpp/libyuv/libyuv.gni +34 -34
- package/android/src/main/cpp/libyuv/libyuv.gyp +149 -149
- package/android/src/main/cpp/libyuv/libyuv.gypi +87 -87
- package/android/src/main/cpp/libyuv/linux.mk +96 -96
- package/android/src/main/cpp/libyuv/public.mk +13 -13
- package/android/src/main/cpp/libyuv/pylintrc +49 -49
- package/android/src/main/cpp/libyuv/riscv_script/prepare_toolchain_qemu.sh +74 -74
- package/android/src/main/cpp/libyuv/riscv_script/riscv-clang.cmake +56 -56
- package/android/src/main/cpp/libyuv/riscv_script/run_qemu.sh +15 -15
- package/android/src/main/cpp/libyuv/source/compare.cc +435 -435
- package/android/src/main/cpp/libyuv/source/compare_common.cc +74 -74
- package/android/src/main/cpp/libyuv/source/compare_gcc.cc +362 -362
- package/android/src/main/cpp/libyuv/source/compare_neon.cc +96 -96
- package/android/src/main/cpp/libyuv/source/compare_neon64.cc +223 -223
- package/android/src/main/cpp/libyuv/source/compare_win.cc +241 -241
- package/android/src/main/cpp/libyuv/source/convert.cc +4746 -4746
- package/android/src/main/cpp/libyuv/source/convert_argb.cc +9179 -9179
- package/android/src/main/cpp/libyuv/source/convert_from.cc +866 -866
- package/android/src/main/cpp/libyuv/source/convert_from_argb.cc +3671 -3671
- package/android/src/main/cpp/libyuv/source/convert_jpeg.cc +602 -602
- package/android/src/main/cpp/libyuv/source/convert_to_argb.cc +391 -391
- package/android/src/main/cpp/libyuv/source/convert_to_i420.cc +288 -288
- package/android/src/main/cpp/libyuv/source/cpu_id.cc +496 -496
- package/android/src/main/cpp/libyuv/source/mjpeg_decoder.cc +580 -580
- package/android/src/main/cpp/libyuv/source/mjpeg_validate.cc +71 -71
- package/android/src/main/cpp/libyuv/source/planar_functions.cc +5663 -5663
- package/android/src/main/cpp/libyuv/source/rotate.cc +1241 -1241
- package/android/src/main/cpp/libyuv/source/rotate_any.cc +76 -76
- package/android/src/main/cpp/libyuv/source/rotate_argb.cc +259 -259
- package/android/src/main/cpp/libyuv/source/rotate_common.cc +208 -208
- package/android/src/main/cpp/libyuv/source/rotate_gcc.cc +505 -505
- package/android/src/main/cpp/libyuv/source/rotate_lsx.cc +233 -233
- package/android/src/main/cpp/libyuv/source/rotate_neon.cc +219 -219
- package/android/src/main/cpp/libyuv/source/rotate_neon64.cc +273 -273
- package/android/src/main/cpp/libyuv/source/rotate_sme.cc +174 -174
- package/android/src/main/cpp/libyuv/source/rotate_win.cc +253 -253
- package/android/src/main/cpp/libyuv/source/row_any.cc +2519 -2519
- package/android/src/main/cpp/libyuv/source/row_common.cc +4461 -4461
- package/android/src/main/cpp/libyuv/source/row_gcc.cc +9570 -9570
- package/android/src/main/cpp/libyuv/source/row_lasx.cc +2343 -2343
- package/android/src/main/cpp/libyuv/source/row_lsx.cc +3030 -3030
- package/android/src/main/cpp/libyuv/source/row_neon.cc +4026 -4026
- package/android/src/main/cpp/libyuv/source/row_neon64.cc +5617 -5617
- package/android/src/main/cpp/libyuv/source/row_rvv.cc +2599 -2599
- package/android/src/main/cpp/libyuv/source/row_sme.cc +1183 -1183
- package/android/src/main/cpp/libyuv/source/row_sve.cc +1088 -1088
- package/android/src/main/cpp/libyuv/source/row_win.cc +6453 -6453
- package/android/src/main/cpp/libyuv/source/scale.cc +2710 -2710
- package/android/src/main/cpp/libyuv/source/scale_any.cc +991 -991
- package/android/src/main/cpp/libyuv/source/scale_argb.cc +1158 -1158
- package/android/src/main/cpp/libyuv/source/scale_common.cc +1977 -1977
- package/android/src/main/cpp/libyuv/source/scale_gcc.cc +2947 -2947
- package/android/src/main/cpp/libyuv/source/scale_lsx.cc +739 -739
- package/android/src/main/cpp/libyuv/source/scale_neon.cc +1449 -1449
- package/android/src/main/cpp/libyuv/source/scale_neon64.cc +1552 -1552
- package/android/src/main/cpp/libyuv/source/scale_rgb.cc +82 -82
- package/android/src/main/cpp/libyuv/source/scale_rvv.cc +1971 -1971
- package/android/src/main/cpp/libyuv/source/scale_sme.cc +555 -555
- package/android/src/main/cpp/libyuv/source/scale_uv.cc +1159 -1159
- package/android/src/main/cpp/libyuv/source/scale_win.cc +1392 -1392
- package/android/src/main/cpp/libyuv/source/test.sh +35 -35
- package/android/src/main/cpp/libyuv/source/video_common.cc +62 -62
- package/android/src/main/cpp/libyuv/tools_libyuv/OWNERS +4 -4
- package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/roll_deps.py +931 -931
- package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py +164 -164
- package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS +21 -21
- package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new +13 -13
- package/android/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old +13 -13
- package/android/src/main/cpp/libyuv/tools_libyuv/get_landmines.py +38 -38
- package/android/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS +3 -3
- package/android/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt +9 -9
- package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS +3 -3
- package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt +15 -15
- package/android/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt +25 -25
- package/android/src/main/cpp/libyuv/unit_test/basictypes_test.cc +43 -43
- package/android/src/main/cpp/libyuv/unit_test/color_test.cc +848 -848
- package/android/src/main/cpp/libyuv/unit_test/compare_test.cc +739 -739
- package/android/src/main/cpp/libyuv/unit_test/convert_argb_test.cc +2867 -2867
- package/android/src/main/cpp/libyuv/unit_test/convert_test.cc +2133 -2133
- package/android/src/main/cpp/libyuv/unit_test/cpu_test.cc +427 -427
- package/android/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc +63 -63
- package/android/src/main/cpp/libyuv/unit_test/math_test.cc +160 -160
- package/android/src/main/cpp/libyuv/unit_test/planar_test.cc +4731 -4731
- package/android/src/main/cpp/libyuv/unit_test/rotate_argb_test.cc +334 -334
- package/android/src/main/cpp/libyuv/unit_test/rotate_test.cc +962 -962
- package/android/src/main/cpp/libyuv/unit_test/scale_argb_test.cc +590 -590
- package/android/src/main/cpp/libyuv/unit_test/scale_plane_test.cc +465 -465
- package/android/src/main/cpp/libyuv/unit_test/scale_rgb_test.cc +280 -280
- package/android/src/main/cpp/libyuv/unit_test/scale_test.cc +1135 -1135
- package/android/src/main/cpp/libyuv/unit_test/scale_uv_test.cc +249 -249
- package/android/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt +12 -12
- package/android/src/main/cpp/libyuv/unit_test/testdata/mips.txt +7 -7
- package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson2k.txt +5 -5
- package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson3.txt +10 -10
- package/android/src/main/cpp/libyuv/unit_test/testdata/mips_loongson_mmi.txt +7 -7
- package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64.txt +3 -3
- package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv.txt +3 -3
- package/android/src/main/cpp/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt +3 -3
- package/android/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt +23 -23
- package/android/src/main/cpp/libyuv/unit_test/unit_test.cc +581 -581
- package/android/src/main/cpp/libyuv/unit_test/unit_test.h +232 -232
- package/android/src/main/cpp/libyuv/unit_test/video_common_test.cc +112 -112
- package/android/src/main/cpp/libyuv/util/Makefile +9 -9
- package/android/src/main/cpp/libyuv/util/color.cc +120 -120
- package/android/src/main/cpp/libyuv/util/compare.cc +67 -67
- package/android/src/main/cpp/libyuv/util/cpuid.c +211 -211
- package/android/src/main/cpp/libyuv/util/i444tonv12_eg.cc +27 -27
- package/android/src/main/cpp/libyuv/util/psnr.cc +291 -291
- package/android/src/main/cpp/libyuv/util/psnr.h +47 -47
- package/android/src/main/cpp/libyuv/util/psnr_main.cc +620 -620
- package/android/src/main/cpp/libyuv/util/ssim.cc +364 -364
- package/android/src/main/cpp/libyuv/util/ssim.h +38 -38
- package/android/src/main/cpp/libyuv/util/yuvconstants.c +114 -114
- package/android/src/main/cpp/libyuv/util/yuvconvert.cc +367 -367
- package/android/src/main/cpp/libyuv/winarm.mk +47 -47
- package/index.js +17 -1
- package/ios/FaceAntiSpoofFrameProcessor.swift +283 -0
- package/ios/FaceAntiSpoofJSI.h +12 -0
- package/ios/FaceAntiSpoofJSI.mm +92 -0
- package/ios/FaceAntiSpoofManager.swift +63 -0
- package/ios/FaceAntiSpoofModule.m +191 -0
- package/ios/FaceAntiSpoofPluginRegister.m +42 -0
- package/ios/models/FaceAntiSpoofing.tflite +0 -0
- package/ios/models/model_spec.json +16 -0
- package/package.json +87 -86
- package/.gitignore +0 -27
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- /package/android/.gradle/{8.9 → 9.2.0}/fileChanges/last-build.bin +0 -0
- /package/android/.gradle/{8.9/dependencies-accessors → 9.2.0}/gc.properties +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#if __has_include(<React/RCTBridgeModule.h>)
|
|
2
|
+
#import <React/RCTBridgeModule.h>
|
|
3
|
+
#elif __has_include("RCTBridgeModule.h")
|
|
4
|
+
#import "RCTBridgeModule.h"
|
|
5
|
+
#else
|
|
6
|
+
#warning "React headers not found - FaceAntiSpoofModule will expose stub implementation"
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#import <objc/message.h>
|
|
10
|
+
#if __has_include(<React/RCTBridge.h>)
|
|
11
|
+
#import <React/RCTBridge.h>
|
|
12
|
+
#elif __has_include("RCTBridge.h")
|
|
13
|
+
#import "RCTBridge.h"
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
@interface FaceAntiSpoofModule : NSObject <RCTBridgeModule>
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
@implementation FaceAntiSpoofModule
|
|
20
|
+
|
|
21
|
+
RCT_EXPORT_MODULE(FaceAntiSpoof);
|
|
22
|
+
|
|
23
|
+
// Indicate whether this module requires main thread initialization
|
|
24
|
+
+(BOOL)requiresMainQueueSetup
|
|
25
|
+
{
|
|
26
|
+
return NO;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Keep a reference to the bridge for lifecycle hooks
|
|
30
|
+
static RCTBridge *_faceAntiSpoofBridge = nil;
|
|
31
|
+
|
|
32
|
+
RCT_REMAP_METHOD(initialize,
|
|
33
|
+
initializeWithResolver:(RCTPromiseResolveBlock)resolve
|
|
34
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
35
|
+
{
|
|
36
|
+
|
|
37
|
+
BOOL pluginAvailable = (NSClassFromString(@"FaceAntiSpoofFrameProcessor") != Nil);
|
|
38
|
+
|
|
39
|
+
// Prefer the FaceAntiSpoofManager to initialize the model and create the interpreter
|
|
40
|
+
BOOL managerInitialized = NO;
|
|
41
|
+
Class managerClass = NSClassFromString(@"FaceAntiSpoofManager");
|
|
42
|
+
if (managerClass != Nil) {
|
|
43
|
+
SEL sel = NSSelectorFromString(@"initializeModel");
|
|
44
|
+
if ([managerClass respondsToSelector:sel]) {
|
|
45
|
+
// Call +initializeModel and capture BOOL result
|
|
46
|
+
BOOL (*msgSendBool)(id, SEL) = (BOOL (*)(id, SEL))objc_msgSend;
|
|
47
|
+
managerInitialized = msgSendBool((id)managerClass, sel);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// As a fallback, check bundle resources
|
|
52
|
+
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"FaceAntiSpoofing" ofType:@"tflite"];
|
|
53
|
+
if (!modelPath) {
|
|
54
|
+
Class fpsClass = NSClassFromString(@"FaceAntiSpoofFrameProcessor");
|
|
55
|
+
if (fpsClass != Nil) {
|
|
56
|
+
NSBundle *podBundle = [NSBundle bundleForClass:fpsClass];
|
|
57
|
+
modelPath = [podBundle pathForResource:@"FaceAntiSpoofing" ofType:@"tflite"];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
BOOL modelLoaded = (modelPath != nil) || managerInitialized;
|
|
61
|
+
BOOL success = pluginAvailable && modelLoaded;
|
|
62
|
+
resolve(@(success));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
RCT_REMAP_METHOD(checkModelStatus,
|
|
66
|
+
checkModelStatusWithResolver:(RCTPromiseResolveBlock)resolve
|
|
67
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
68
|
+
{
|
|
69
|
+
BOOL pluginAvailable = (NSClassFromString(@"FaceAntiSpoofFrameProcessor") != Nil);
|
|
70
|
+
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"FaceAntiSpoofing" ofType:@"tflite"];
|
|
71
|
+
if (!modelPath) {
|
|
72
|
+
Class fpsClass = NSClassFromString(@"FaceAntiSpoofFrameProcessor");
|
|
73
|
+
if (fpsClass != Nil) {
|
|
74
|
+
NSBundle *podBundle = [NSBundle bundleForClass:fpsClass];
|
|
75
|
+
modelPath = [podBundle pathForResource:@"FaceAntiSpoofing" ofType:@"tflite"];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
BOOL modelLoaded = (modelPath != nil);
|
|
79
|
+
NSDictionary *result = @{@"pluginAvailable": @(pluginAvailable), @"modelLoaded": @(modelLoaded), @"moduleInitialized": @(YES)};
|
|
80
|
+
resolve(result);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
RCT_REMAP_METHOD(isAvailable,
|
|
84
|
+
isAvailableWithResolver:(RCTPromiseResolveBlock)resolve
|
|
85
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
86
|
+
{
|
|
87
|
+
BOOL pluginAvailable = (NSClassFromString(@"FaceAntiSpoofFrameProcessor") != Nil);
|
|
88
|
+
resolve(@(pluginAvailable));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
RCT_REMAP_METHOD(testMethod,
|
|
92
|
+
testMethodWithResolver:(RCTPromiseResolveBlock)resolve
|
|
93
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
94
|
+
{
|
|
95
|
+
resolve(@"iOS native module stub");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
RCT_REMAP_METHOD(getModuleInfo,
|
|
99
|
+
getModuleInfoWithResolver:(RCTPromiseResolveBlock)resolve
|
|
100
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
101
|
+
{
|
|
102
|
+
NSDictionary *info = @{@"name": @"FaceAntiSpoof", @"methods": @[@"initialize", @"checkModelStatus", @"isAvailable", @"testMethod", @"getModuleInfo", @"install", @"cleanup"]};
|
|
103
|
+
resolve(info);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
RCT_REMAP_METHOD(install,
|
|
107
|
+
installWithResolver:(RCTPromiseResolveBlock)resolve
|
|
108
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
109
|
+
{
|
|
110
|
+
// Attempt to initialize shared model resources via FaceAntiSpoofManager
|
|
111
|
+
BOOL managerInitialized = NO;
|
|
112
|
+
Class managerClass = NSClassFromString(@"FaceAntiSpoofManager");
|
|
113
|
+
if (managerClass != Nil) {
|
|
114
|
+
SEL sel = NSSelectorFromString(@"initializeModel");
|
|
115
|
+
if ([managerClass respondsToSelector:sel]) {
|
|
116
|
+
BOOL (*msgSendBool)(id, SEL) = (BOOL (*)(id, SEL))objc_msgSend;
|
|
117
|
+
managerInitialized = msgSendBool((id)managerClass, sel);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
BOOL pluginAvailable = (NSClassFromString(@"FaceAntiSpoofFrameProcessor") != Nil);
|
|
122
|
+
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"FaceAntiSpoofing" ofType:@"tflite"];
|
|
123
|
+
if (!modelPath) {
|
|
124
|
+
Class fpsClass = NSClassFromString(@"FaceAntiSpoofFrameProcessor");
|
|
125
|
+
if (fpsClass != Nil) {
|
|
126
|
+
NSBundle *podBundle = [NSBundle bundleForClass:fpsClass];
|
|
127
|
+
modelPath = [podBundle pathForResource:@"FaceAntiSpoofing" ofType:@"tflite"];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
BOOL modelLoaded = (modelPath != nil) || managerInitialized;
|
|
131
|
+
// Attempt to register JSI: try common bridge keys to obtain a runtime pointer
|
|
132
|
+
if (_faceAntiSpoofBridge != nil) {
|
|
133
|
+
id runtimePtr = nil;
|
|
134
|
+
@try {
|
|
135
|
+
runtimePtr = [_faceAntiSpoofBridge valueForKeyPath:@"jsContext"];
|
|
136
|
+
} @catch (NSException *_) {}
|
|
137
|
+
if (!runtimePtr) {
|
|
138
|
+
@try {
|
|
139
|
+
runtimePtr = [_faceAntiSpoofBridge valueForKeyPath:@"jsContextRef"];
|
|
140
|
+
} @catch (NSException *_) {}
|
|
141
|
+
}
|
|
142
|
+
if (!runtimePtr) {
|
|
143
|
+
@try {
|
|
144
|
+
runtimePtr = [_faceAntiSpoofBridge valueForKeyPath:@"javaScriptContextRef"];
|
|
145
|
+
} @catch (NSException *_) {}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (runtimePtr) {
|
|
149
|
+
// Pass the pointer to the JSI install stub
|
|
150
|
+
void *ptr = (__bridge void *)(runtimePtr);
|
|
151
|
+
extern void FaceAntiSpoofJSI_install(void *runtimePtr);
|
|
152
|
+
FaceAntiSpoofJSI_install(ptr);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
resolve(@(pluginAvailable && modelLoaded));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
RCT_REMAP_METHOD(cleanup,
|
|
160
|
+
cleanupWithResolver:(RCTPromiseResolveBlock)resolve
|
|
161
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
162
|
+
{
|
|
163
|
+
// Ask manager to cleanup interpreter
|
|
164
|
+
Class managerClass = NSClassFromString(@"FaceAntiSpoofManager");
|
|
165
|
+
if (managerClass != Nil) {
|
|
166
|
+
SEL sel = NSSelectorFromString(@"cleanupModel");
|
|
167
|
+
if ([managerClass respondsToSelector:sel]) {
|
|
168
|
+
void (*msgSendVoid)(id, SEL) = (void (*)(id, SEL))objc_msgSend;
|
|
169
|
+
msgSendVoid((id)managerClass, sel);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
resolve(@(YES));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
- (void)setBridge:(RCTBridge *)bridge {
|
|
176
|
+
_faceAntiSpoofBridge = bridge;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
- (void)invalidate {
|
|
180
|
+
Class managerClass = NSClassFromString(@"FaceAntiSpoofManager");
|
|
181
|
+
if (managerClass != Nil) {
|
|
182
|
+
SEL sel = NSSelectorFromString(@"cleanupModel");
|
|
183
|
+
if ([managerClass respondsToSelector:sel]) {
|
|
184
|
+
void (*msgSendVoid)(id, SEL) = (void (*)(id, SEL))objc_msgSend;
|
|
185
|
+
msgSendVoid((id)managerClass, sel);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
_faceAntiSpoofBridge = nil;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <objc/runtime.h>
|
|
3
|
+
#import <objc/message.h>
|
|
4
|
+
|
|
5
|
+
// At load time, attempt to register the Swift FrameProcessor plugin with VisionCamera
|
|
6
|
+
__attribute__((constructor)) static void register_face_anti_spoof_plugin(void) {
|
|
7
|
+
@autoreleasepool {
|
|
8
|
+
Class registry = NSClassFromString(@"FrameProcessorPluginRegistry");
|
|
9
|
+
|
|
10
|
+
if (registry == Nil) {
|
|
11
|
+
return; // VisionCamera not available yet
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
SEL selector = NSSelectorFromString(@"addFrameProcessorPlugin:withInitializer:");
|
|
15
|
+
if (![registry respondsToSelector:selector]) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Create initializer block using objc_msgSend to avoid compile-time selector checks
|
|
20
|
+
id initializer = ^id(id proxy, id options) {
|
|
21
|
+
Class dynClass = NSClassFromString(@"FaceAntiSpoofFrameProcessor");
|
|
22
|
+
if (dynClass == Nil) {
|
|
23
|
+
return nil;
|
|
24
|
+
}
|
|
25
|
+
SEL allocSel = sel_registerName("alloc");
|
|
26
|
+
id alloced = ((id (*)(id, SEL))objc_msgSend)((id)dynClass, allocSel);
|
|
27
|
+
|
|
28
|
+
// Swift's exported Objective-C initializer name is `initWithProxy:options:`
|
|
29
|
+
SEL initSel = sel_registerName("initWithProxy:options:");
|
|
30
|
+
if (![alloced respondsToSelector:initSel]) {
|
|
31
|
+
return nil;
|
|
32
|
+
}
|
|
33
|
+
id instance = ((id (*)(id, SEL, id, id))objc_msgSend)(alloced, initSel, proxy, options);
|
|
34
|
+
return instance;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Call +addFrameProcessorPlugin:name with the block
|
|
38
|
+
// We use objc_msgSend to avoid compile-time dependency on the header signature
|
|
39
|
+
void (*msgSend)(id, SEL, id, id) = (void (*)(id, SEL, id, id))objc_msgSend;
|
|
40
|
+
msgSend((id)registry, selector, @"faceAntiSpoof", initializer);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_file": "FaceAntiSpoofing.tflite",
|
|
3
|
+
"input": {
|
|
4
|
+
"shape": [1, 256, 256, 3],
|
|
5
|
+
"dtype": "float32",
|
|
6
|
+
"normalization": {"scale": 255.0}
|
|
7
|
+
},
|
|
8
|
+
"outputs": {
|
|
9
|
+
"Identity": {"shape": [1,8], "dtype": "float32", "description": "class predictions (clss_pred)"},
|
|
10
|
+
"Identity_1": {"shape": [1,8], "dtype": "float32", "description": "leaf node mask (leaf_node_mask)"}
|
|
11
|
+
},
|
|
12
|
+
"post_processing": {
|
|
13
|
+
"leafScore": "sum(abs(clss_pred[i]) * leaf_node_mask[i]) for i in 0..7",
|
|
14
|
+
"combinedScore": "calculated from neural and laplacian scores as in Android implementation"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,87 +1,88 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-native-vision-camera-spoof-detector",
|
|
3
|
-
"version": "1.0.
|
|
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
|
-
"homepage": "https://github.com/dpraful/react-native-vision-camera-spoof-detector",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/dpraful/react-native-vision-camera-spoof-detector.git"
|
|
9
|
-
},
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/dpraful/react-native-vision-camera-spoof-detector/issues"
|
|
12
|
-
},
|
|
13
|
-
"license": "JSCON TECHNOLOGIES PVT LTD",
|
|
14
|
-
"author": {
|
|
15
|
-
"name": "PRAFULDAS M M",
|
|
16
|
-
"company": "JESCON TECHNOLOGIES PVT LTD",
|
|
17
|
-
"email": "jescontechnologies@gmail.com"
|
|
18
|
-
},
|
|
19
|
-
"contributors": [
|
|
20
|
-
{
|
|
21
|
-
"name": "JESCON TECHNOLOGIES PVT LTD",
|
|
22
|
-
"email": "jescontechnologies@gmail.com"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"main": "index.js",
|
|
26
|
-
"browser": "index.js",
|
|
27
|
-
"react-native": "index.js",
|
|
28
|
-
"types": "index.d.ts",
|
|
29
|
-
"files": [
|
|
30
|
-
"android/",
|
|
31
|
-
"
|
|
32
|
-
".
|
|
33
|
-
".
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"index.
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"react
|
|
61
|
-
"react-native
|
|
62
|
-
"react-native-
|
|
63
|
-
"react-native-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"react
|
|
73
|
-
"
|
|
74
|
-
"@babel/plugin-proposal-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-vision-camera-spoof-detector",
|
|
3
|
+
"version": "1.0.24",
|
|
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
|
+
"homepage": "https://github.com/dpraful/react-native-vision-camera-spoof-detector",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/dpraful/react-native-vision-camera-spoof-detector.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/dpraful/react-native-vision-camera-spoof-detector/issues"
|
|
12
|
+
},
|
|
13
|
+
"license": "JSCON TECHNOLOGIES PVT LTD",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "PRAFULDAS M M",
|
|
16
|
+
"company": "JESCON TECHNOLOGIES PVT LTD",
|
|
17
|
+
"email": "jescontechnologies@gmail.com"
|
|
18
|
+
},
|
|
19
|
+
"contributors": [
|
|
20
|
+
{
|
|
21
|
+
"name": "JESCON TECHNOLOGIES PVT LTD",
|
|
22
|
+
"email": "jescontechnologies@gmail.com"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"main": "index.js",
|
|
26
|
+
"browser": "index.js",
|
|
27
|
+
"react-native": "index.js",
|
|
28
|
+
"types": "index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"android/",
|
|
31
|
+
"ios/",
|
|
32
|
+
".gitattributes",
|
|
33
|
+
".gitignore",
|
|
34
|
+
".npmignore",
|
|
35
|
+
"CHANGELOG.md",
|
|
36
|
+
"CONTRIBUTING.md",
|
|
37
|
+
"index.js",
|
|
38
|
+
"index.d.ts",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"keywords": [
|
|
43
|
+
"react-native",
|
|
44
|
+
"vision-camera",
|
|
45
|
+
"face-detection",
|
|
46
|
+
"anti-spoofing",
|
|
47
|
+
"liveness-detection",
|
|
48
|
+
"face-liveness",
|
|
49
|
+
"spoofing-detection",
|
|
50
|
+
"tensorflow-lite",
|
|
51
|
+
"gpu-acceleration",
|
|
52
|
+
"yuv-processing",
|
|
53
|
+
"face-recognition",
|
|
54
|
+
"biometric",
|
|
55
|
+
"security",
|
|
56
|
+
"ai",
|
|
57
|
+
"ml"
|
|
58
|
+
],
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": ">=16.8.0",
|
|
61
|
+
"react-native": ">=0.60.0",
|
|
62
|
+
"react-native-vision-camera": "^4.6.4 || ^5.0.0",
|
|
63
|
+
"react-native-reanimated": "^3.0.0",
|
|
64
|
+
"react-native-worklets-core": "^1.0.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"react-native-vision-camera-face-detector": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"react": "^18.2.0",
|
|
73
|
+
"react-native": "^0.72.0",
|
|
74
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
75
|
+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
76
|
+
"typescript": "^5.0.0"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=16.0.0",
|
|
80
|
+
"npm": ">=8.0.0"
|
|
81
|
+
},
|
|
82
|
+
"packageManager": "npm@8.0.0",
|
|
83
|
+
"documentation": "https://github.com/dpraful/react-native-vision-camera-spoof-detector/wiki",
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public",
|
|
86
|
+
"registry": "https://registry.npmjs.org/"
|
|
87
|
+
}
|
|
87
88
|
}
|
package/.gitignore
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Compiled class file
|
|
2
|
-
*.class
|
|
3
|
-
|
|
4
|
-
# Log file
|
|
5
|
-
*.log
|
|
6
|
-
|
|
7
|
-
# BlueJ files
|
|
8
|
-
*.ctxt
|
|
9
|
-
|
|
10
|
-
# Mobile Tools for Java (J2ME)
|
|
11
|
-
.mtj.tmp/
|
|
12
|
-
|
|
13
|
-
# Package Files #
|
|
14
|
-
*.jar
|
|
15
|
-
*.war
|
|
16
|
-
*.nar
|
|
17
|
-
*.ear
|
|
18
|
-
*.zip
|
|
19
|
-
*.tar.gz
|
|
20
|
-
*.rar
|
|
21
|
-
|
|
22
|
-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
|
23
|
-
hs_err_pid*
|
|
24
|
-
replay_pid*
|
|
25
|
-
|
|
26
|
-
# Kotlin Gradle plugin data, see https://kotlinlang.org/docs/whatsnew20.html#new-directory-for-kotlin-data-in-gradle-projects
|
|
27
|
-
.kotlin/
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|