Skip to content

Flutter realtime face detection and face recognition using OpenCV and dlib

License

Notifications You must be signed in to change notification settings

alnitak/flutter_opencv_dlib

Repository files navigation

Flutter OpenCV dlib

Realtime face detection and face recognition using OpenCV and dlib

Getting Started (WIP)

flutter_opencv_dlib-linux.mp4
flutter_opencv_dlib-android.mp4

This plugin is almost tested only on Linux and Android, any help is greatly appreciated!

On Android (not tested on iOS) the camera plugin is used to grab frames and send them to this plugin.

The camera plugin seems to have a different behavior running on the emulator or on a real device: the viewfinder is rotated. For this purpose, in the example/lib/main.dart there is the [isRunninOnEmulator] const used to define the starting viewfinder rotation.

The the camera on Linux, uses frames provided by [cv::VideoCapture] OpenCV lib, it stores them into a OpenGL texture and send them back to a Texture() Flutter widget. This should work on Windows and Mac, but it's not implemented. So the camera is not yet available on these OSes (any help would be greatly appreciated), but the plugin should work for example providing photos/images to it.

The c/c++ shared source code (for all platforms) is stored into ios/Classes/cpp for further iOS release.

In the assets dir are stored some models used here. They are available here and are licensed under Creative Commons Zero v1.0 Universal

For Linux within the example dir you should run lib/main_desktop.dart: flutter run --release -t ./lib/main_desktop.dart which uses the OpenCV camera instead the camera plugin.

WARNING

Running in debug mode the performances are very poor. In profile or release mode you'll get much more FPS

Compiling libs

Linux

install OpenCV and dlib with the package manager of your linux distribution.

Android

Opencv v4.6.0 and dlib v19.24 are precompiled and stored into android/src/main. If you want to update them, you can use the below instructions:

OpenCV

dlib

  • go to BUILD_LIBS/buildDlib
  • run gitCloneDlib
  • run buildDlib-android

Windows

OpenCV

dlib

  • go to BUILD_LIBS/buildDlib
  • run gitCloneDlib.bat
  • run buildDlib-windows.bat

windows install reference: learnopencv.com

About

Flutter realtime face detection and face recognition using OpenCV and dlib

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published