1.1.5 • Published 4 years ago

@moi-xiey/react-native-baidu-face v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

React Native 百度人像活体检测

使用前准备

安装步骤

  • yarn add react-native-baidu-face
  • react-native link react-native-baidu-face
    • 修改包名(AndroidManifest.xml 的 package 和 android/app/build.gradle > android > defaultConfig > applicationId 填入创建授权时输入的 android 包名)
    • 在 android/gradle.properties 文件中配置
      ...
      BAIDU_FACE_SDK_LICENSE_ID="*license*"
      BAIDU_FACE_SDK_LICENSE_FILE_NAME="idl-license.face-android" # 可不配, 默认为 idl-license.face-android
      ...
    • 在 MainApplication.java 中添加
      import com.baidu.idl.face.BaiduFace; /* 在顶部添加 */
      ...
      @Override
      public void onCreate() {
          super.onCreate();
          SoLoader.init(this, /* native exopackage */ false);
          BaiduFace.init(this); /* 在 onCreate 中添加 */
      }
    • 把 license 文件放入 android/app/src/main/assets 目录
    • xcode打开项目, 在 Frameworks 文件右键 Add Files to "xxx", 在弹出的框中选择 ${项目根目录}/node_modules/react-native-baidu-face/ios/IDLFaceSDK.framework 文件, 点击 add 按钮
    • 确认 General/Identity/Bundle Identifier 与创建授权时填入的要一致
    • General/Linked Frameworks and Libraries 下点击 + 号, 选择 libc++.tbd, 点击 add 按钮
    • Build Settings/Search Paths/Framework Search Paths 添加 $(SRCROOT)/../node_modules/react-native-baidu-face/ios(选择recursive)
    • Build Settings/Search Paths/Library Search Paths 添加 $(inherited) 和 $(SRCROOT)/../node_modules/react-native-baidu-face/ios(选择recursive)
    • Build Phases/Copy Bundle Resources 下点击 + 号, 在弹框中点击 Add Other... 按钮, 在弹出的框中跳转到 ${项目根目录}/node_modules/react-native-baidu-face/ios/ 目录选择添加 com.baidu.idl.face.faceSDK.bundle 和 com.baidu.idl.face.model.bundle 文件
    • 把 license 文件的名称改为 idl-license.face-ios, 然后按照上一个步骤把该文件添加到 Build Phases/Copy Bundle Resources 中
    • 在 info.plist 中添加 NSCameraUsageDescription
    • 在 info.plist 中添加 BAIDU_FACE_LICENSE_ID, 值为创建授权是填入的授权标识
    • 在 AppDelegate.m 中

      #import "BaiduFace.h" // 引入头文件
    • (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions { BaiduFace initSDK; // 初始化人像SDK }

      </details>

使用

import BaiduFace from "react-native-baidu-face";

// 人脸跟踪检测
BaiduFace.detect();

// 活体检测
BaiduFace.liveness()
1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago