xbr_baidu_face 1.0.2 copy "xbr_baidu_face: ^1.0.2" to clipboard
xbr_baidu_face: ^1.0.2 copied to clipboard

PlatformAndroidiOS
outdated

XBR_baidu_face,This FLUTTER package uses Baidu Cloud's official offline collection SDK for packaging. Before use, it needs to obtain Baidu Cloud authorization certification. Baidu Cloud address:https: [...]

example/lib/main.dart

import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:xbr_baidu_face/xbr_baidu_face.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    initBdFace();
  }

  ///初始化百度FACE
  void initBdFace() {
    Config config = Config(livenessTypeList: [LivenessTypes.random()]);
    if (Platform.isAndroid) {
      BaiduFace.instance.init('driver-face-face-android', config: config);
    } else if (Platform.isIOS) {
      BaiduFace.instance.init('XiaobiaorenApp-face-ios', config: config);
    }
  }

  ///開始采集
  Future<void> liveDetect() async {
    final base64Image = await BaiduFace.instance.liveDetect();
    if (kDebugMode) {
      print('采集结果:$base64Image');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('百度人脸采集'),
        ),
        body: Container(
          padding: const EdgeInsets.all(30),
          alignment: Alignment.center,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const Text('1:创建JKS秘钥文件,完成APP签名,自行百度查看方法,前往百度智能云官网申请license文件',style:style),
              const SizedBox(height: 20),
              const Text('2-1:在android-main下面新建assets文件夹,放入 idl-license.face-android 文件 ',style:style),
              const SizedBox(height: 20),
              const Text('2-2:在ios-Runner下面放入 idl-license.face-ios 文件 ',style:style),
              const SizedBox(height: 20),
              const Text('3:初始化百度FACE,点击第4步即可开始采集',style:style),
              const SizedBox(height: 20),
              OutlinedButton(
                onPressed: () {
                  liveDetect();
                },
                child: const Text("4:点击开始采集",style:style),
              ),
              const Text("如果日志中出现异常:java.io.FileNotFoundException: idl-license.face-android,说明没有license文件,或license文件放错位置")
            ],
          ),
        ),
      ),
    );
  }
}

const TextStyle style = TextStyle(fontWeight: FontWeight.bold,fontSize: 18);
4
likes
140
points
11
downloads

Publisher

unverified uploader

Weekly Downloads

XBR_baidu_face,This FLUTTER package uses Baidu Cloud's official offline collection SDK for packaging. Before use, it needs to obtain Baidu Cloud authorization certification. Baidu Cloud address:https://cloud.baidu.com/campaign/2022/index.html.

Homepage

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on xbr_baidu_face

Packages that implement xbr_baidu_face