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

outdated

A Flutter camera plugin that detects faces in real-time. In addition it can capture automatically once a face is detected, This can be handy while taking a selfie during kyc verification.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';

import 'package:face_camera/face_camera.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();

  await FaceCamera.intialize();

  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {

  File? _capturedImage;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('FaceCapture example app'),
        ),
        body: Builder(
          builder: (context) {
            if(_capturedImage!=null){
              return Center(
                child: Stack(
                  alignment: Alignment.bottomCenter,
                  children: [
                    Image.file(
                      _capturedImage!,
                      width: double.maxFinite,
                      fit: BoxFit.fitWidth,
                    ),
                    ElevatedButton(
                      onPressed: ()=>setState(()=>_capturedImage=null),
                      child: const Text('Capture Again',
                        textAlign: TextAlign.center,
                        style: TextStyle(fontSize: 14,
                            fontWeight: FontWeight.w700),
                      )
                    )
                  ],
                ),
              );
            }
            return SmartFaceCamera(
              defaultCameraLens: CameraLens.front,
              message: 'Center your face in the sqaure',
              autoCapture: true,
              onCapture: (File? image){
                setState(()=> _capturedImage=image);
              },
            );
          }
        )
      ),
    );
  }
}
154
likes
0
pub points
94%
popularity

Publisher

unverified uploader

A Flutter camera plugin that detects faces in real-time. In addition it can capture automatically once a face is detected, This can be handy while taking a selfie during kyc verification.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

camera, flutter, google_mlkit_face_detection

More

Packages that depend on face_camera