瀏覽代碼

配置demo使用文档

RandyWei 5 年之前
父節點
當前提交
956d563f81
共有 4 個文件被更改,包括 60 次插入23 次删除
  1. 13 4
      README.md
  2. 35 8
      example/README.md
  3. 12 10
      example/lib/face_service.dart
  4. 0 1
      example/lib/main.dart

+ 13 - 4
README.md

@@ -2,12 +2,21 @@
 
 Baidu's face recognition SDK encapsulates the flutter version, calls native SDK and interface operations, and returns data to flutter
 
+## 声明
+
+插件是基于百度云人脸离线采集有活体动作版SDK(https://ai.baidu.com/ai-doc/FACE/Mk37c1pue#%E7%9B%AE%E5%BD%95)进行封装的
+
+在使用插件之前要自行在百度云注册账号,并完成一系列配置之后,阅读https://ai.baidu.com/ai-doc/FACE/Mk37c1pue#22-%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C 文档申请license
+
+## 配置
+
+在百度云后台将 安卓-License文件下载后放置于android/app/src/main/assets下,如果没有该目录创建即可
+
 ## 安装
 
 ```
 //pub方式
-dependencies:
-  flt_bd_face: ^0.0.4
+暂无
 
 //导入方式
 dependencies:
@@ -17,7 +26,7 @@ dependencies:
 ```
 
 ### Android
-android/app/build.gradle配置如下
+android/app/build.gradle配置如下(以下只保留了本插件需要的配置,忽略了其他)
 ```
 android {
 
@@ -55,4 +64,4 @@ android {
 -keep class com.baidu.** {*;}
 -keep class vi.com.** {*;}
 -dontwarn com.baidu.**
-```
+```

+ 35 - 8
example/README.md

@@ -2,15 +2,42 @@
 
 Demonstrates how to use the fltbdface plugin.
 
-## Getting Started
+## Demo
 
-This project is a starting point for a Flutter application.
+```
+class FaceService {
+  FacePlugin _facePlugin = FacePlugin();
 
-A few resources to get you started if this is your first Flutter project:
+  String _licenseId;
+  String _licenseFileName;
 
-- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
-- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
+  FaceService() {
+    if (Platform.isIOS) {
+      _licenseId = 'pharmacist-license-face-ios'; //百度云后台licenseID
+      _licenseFileName = 'idl-license.face-ios';
+    } else {
+      _licenseId = 'pharmacist-license-face-android';
+      _licenseFileName =
+          'idl-license.face-android'; // 位于android/app/src/main/assets下的license文件名称
+    }
+  }
 
-For help getting started with Flutter, view our
-[online documentation](https://flutter.dev/docs), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.
+  startFaceLiveness({Function data, Function onFailed}) {
+    //初始化插件
+    _facePlugin.initialize(
+        licenseId: _licenseId, licenseFileName: _licenseFileName);
+
+    //创建插件配置
+    FaceConfig _faceConfig = FaceConfig();
+
+    //验证活动动作列表
+    List<LivenessType> livenessTypeList = [LivenessType.Eye];
+    livenessTypeList.add(LivenessType.Mouth);
+    _faceConfig.livenessTypeList = livenessTypeList;
+    //设置配置
+    _facePlugin.setFaceConfig(_faceConfig);
+    //启动人脸采集界面
+    _facePlugin.startFaceLiveness(data: data, onFailed: onFailed);
+  }
+}
+```

+ 12 - 10
example/lib/face_service.dart

@@ -10,28 +10,30 @@ class FaceService {
 
   FaceService() {
     if (Platform.isIOS) {
-      _licenseId = 'food-license-face-ios';
+      _licenseId = 'pharmacist-license-face-ios'; //百度云后台licenseID
       _licenseFileName = 'idl-license.face-ios';
     } else {
-      _licenseId = 'food-license-face-android';
-      _licenseFileName = 'idl-license.face-android';
+      _licenseId = 'pharmacist-license-face-android'; //百度云后台licenseID
+      _licenseFileName =
+          'idl-license.face-android'; // 位于android/app/src/main/assets下的license文件名称
     }
   }
 
-  startFaceLiveness({bool withMouth, Function data, Function onFailed}) {
+  startFaceLiveness({Function data, Function onFailed}) {
+    //初始化插件
     _facePlugin.initialize(
         licenseId: _licenseId, licenseFileName: _licenseFileName);
+
+    //创建插件配置
     FaceConfig _faceConfig = FaceConfig();
 
+    //验证活动动作列表
     List<LivenessType> livenessTypeList = [LivenessType.Eye];
-
-    if (withMouth) {
-      livenessTypeList.add(LivenessType.Mouth);
-    }
-
+    livenessTypeList.add(LivenessType.Mouth);
     _faceConfig.livenessTypeList = livenessTypeList;
+    //设置配置
     _facePlugin.setFaceConfig(_faceConfig);
+    //启动人脸采集界面
     _facePlugin.startFaceLiveness(data: data, onFailed: onFailed);
   }
-
 }

+ 0 - 1
example/lib/main.dart

@@ -31,7 +31,6 @@ class _MyAppState extends State<MyApp> {
           child: RaisedButton(
             onPressed: () {
               faceService.startFaceLiveness(
-                  withMouth: true,
                   data: (data) {
                     print(data);
                   },