|
|
@@ -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);
|
|
|
+ }
|
|
|
+}
|
|
|
+```
|