Realtime face detection and face recognition using OpenCV and dlib
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.
Running in debug mode the performances are very poor. In profile or release mode you'll get much more FPS
install OpenCV and dlib with the package manager of your linux distribution.
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:
- download latest opencv-[x.y.z]-android-sdk.zip from https://github.com/opencv/opencv/releases
- extract into BUILD_LIBS/buildOpenCV
- run copyLibs-android
- go to BUILD_LIBS/buildDlib
- run gitCloneDlib
- run buildDlib-android
- download latest opencv-[x.y.z]-vc14_vc15.zip from https://github.com/opencv/opencv/releases
- extract into BUILD_LIBS/buildOpenCV
- run buildOpenCV.bat
- go to BUILD_LIBS/buildDlib
- run gitCloneDlib.bat
- run buildDlib-windows.bat
windows install reference: learnopencv.com