anhdev99_face_camera 0.0.9

SDKflutter
Platformandroidios

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.

anhdev99_face_camera

A Flutter camera plugin that detects face in real-time.

Preview


Installation


First, add anhdev99_face_camera as a dependency in your pubspec.yaml file.

anhdev99_face_camera: ^<latest-version>

iOS


  • Minimum iOS Deployment Target: 11.0
  • Follow this link and setup ML Kit this is required for anhdev99_face_camera to function properly on iOS

Add two rows to the ios/Runner/Info.plist:

  • one with the key Privacy - Camera Usage Description and a usage description.
  • and one with the key Privacy - Microphone Usage Description and a usage description.

If editing Info.plist as text, add:

<key>NSCameraUsageDescription</key>
<string>your usage description here</string>
<key>NSMicrophoneUsageDescription</key>
<string>your usage description here</string>

Android


  • Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.
minSdkVersion 21

Usage


  • The first step is to initialize anhdev99_face_camera in main.dart
void main() async{
  WidgetsFlutterBinding.ensureInitialized(); //Add this

  await FaceCamera.initialize(); //Add this

  runApp(const MyApp());
}
  • Then render the component in your application setting the onCapture callback.
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: SmartFaceCamera(
          autoCapture: true,
          defaultCameraLens: CameraLens.front,
          message: 'Center your face in the square',
          onCapture: (File? image){
            
          },
        )
    );
  }

Customization


Here is a list of properties available to customize your widget:

NameTypeDescription
onCaptureFunction(File?)callback invoked when camera captured image
onFaceDetectedFunction(DetectedFace?)callback invoked when camera detects face
imageResolutionImageResolutionused this to set image resolution
defaultCameraLensCameraLensused this to set initial camera lens direction
defaultFlashModeCameraFlashModeused this to set initial flash mode
enableAudioboolset false to disable capture sound
autoCaptureboolset true to capture image on face detected
showControlsboolset false to hide all controls
showCaptureControlboolset false to hide capture control icon
showFlashControlboolset false to hide flash control control icon
showCameraLensControlboolset false to hide camera lens control icon
messageStringuse this pass a message above the camera
messageStyleTextStylestyle applied to the message widget
orientationCameraOrientationuse this to lock camera orientation
captureControlIconWidgetuse this to render a custom widget for capture control
lensControlIconWidgetuse this to render a custom widget for camera lens control
flashControlBuilderFlashControlBuilderuse this to build custom widgets for flash control based on camera flash mode
messageBuilderMessageBuilderuse this to build custom messages based on face position
indicatorShapeIndicatorShapeuse this to change the shape of the face indicator
indicatorAssetImageStringuse this to pass an asset image when IndicatorShape is set to image
indicatorBuilderIndicatorBuilderuse this to build custom widgets for the face indicator

Contributions


Contributions of any kind are more than welcome! Feel free to fork and improve anhdev99_face_camera in any way you want, make a pull request, or open an issue.

Support the Library


You can support the library by liking it on pub, staring in on Github and reporting any bugs you encounter.