seetaface6 0.0.2 copy "seetaface6: ^0.0.2" to clipboard
seetaface6: ^0.0.2 copied to clipboard

A new Flutter project for seetaface6.

example/lib/main.dart

import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:seetaface6/seetaface6.dart';

import 'package:flutter/services.dart' show PlatformException, rootBundle;
import 'package:path_provider/path_provider.dart';
import 'package:image_picker/image_picker.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Seetaface6.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              Text('Running on: $_platformVersion\n'),
              FlatButton(
                onPressed: () async {
                  await Seetaface6.launch;
                },
                child: Text('launch'),
              ),
              FlatButton(
                onPressed: () async {
                  var faceCount = await Seetaface6.faceCount;
                  print(faceCount);
                },
                child: Text('faceCount'),
              ),
              FlatButton(
                onPressed: () async {
                  await Seetaface6.init;
                },
                child: Text('人脸检测初始化'),
              ),
              FlatButton(
                onPressed: () async {
                  final picker = ImagePicker();
                  final pickedFile = await picker.getImage(source: ImageSource.gallery);
                  String facesStr = await Seetaface6.facesFromImage(pickedFile.path, minFaceSize: 20.0);
                  print(facesStr);
                  var faces = jsonDecode(facesStr);
                  print((faces as List).length);
                },
                child: Text('从相册中选择'),
              ),
              FlatButton(
                onPressed: () async {
                  final imageByteData = await rootBundle.load('images/1.jpg');
                  Directory dir = await getExternalStorageDirectory();
                  String path = dir.path;
                  File imageFile = File('$path/1.jpg');
                  imageFile.writeAsBytesSync(imageByteData.buffer.asInt8List(0));
                  String facesStr = await Seetaface6.facesFromImage(imageFile.path, minFaceSize: 20.0);
                  print(facesStr);
                  var faces = jsonDecode(facesStr);
                  print((faces as List).length);
                },
                child: Text('人脸检测'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
120
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter project for seetaface6.

Homepage

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on seetaface6