Machine Learning Resources & OpenCV - papito/altitude GitHub Wiki
Mostly Java/Scala OpenCV resources but there are some tutorials for other languages/frameworks, if they do a good job explaining things.
Reading material
What is the best face detector model?
Description of the three available face recognizers in OpenCV. (Not SFace).
Setup
FIRST OF ALL - here is a crash course for how OpenCV, JavaCV, JavaCPP dependencies are related, and how to build it for each platform.
-
Platform-specific setup using
sbt-javacpp
presets. Also a very good example of Akka stream processing (advanced stuff here): -
Another, slightly different way to do the above:
https://github.com/pupudu/javacv-examples/blob/master/OpenCV2_Cookbook/build.sbt
-
The JavaCV SBT plugin - here specifically explains how to build for other platforms
-
JavaCV - what JavaCV SBT wraps, also has manual JAR install instructions
Face detection
DeepNet
-
OpenCV cookbook example
-
DNN detection question and tutorial (Haar has awful results):
https://stackoverflow.com/questions/63122406/face-recognition-does-not-detect-any-with-opencv https://learnopencv.com/face-detection-opencv-dlib-and-deep-learning-c-python/ https://towardsdatascience.com/face-detection-models-which-to-use-and-why-d263e82c302c
-
TUTORIAL: Face detection pipeline with Akka
https://beachape.com/blog/2016/03/14/scala-and-opencv-ep-2-akka-face-detector/
Haar Cascade (do not use, for reference only)
-
OpenCV classifier data for Haar cascade classifier:
https://github.com/opencv/opencv/tree/master/data/haarcascades
-
A very simple method to detect a face with a classifier and draw a bounding rectangle around it (2016)
-
Ancient face detection code, says "Scala" but the project is Java. (2013)
https://github.com/vspiewak/opencv-scala-sample/blob/master/src/main/java/FaceDetector.java
-
TUTORIAL: Facial Recognition Using OpenCV In Java: A Developer‘s Guide
-
ExoVisix - Advanced example with multiple classifiers and video frame grabbers:
https://github.com/anupsarkar-dev/ExoVisix/blob/master/src/application/FaceDetector.java
RetinaFace
Supposed to be THE best open-source model.
Output is here - particularly the 10x landmark matrix that we MIGHT be able to use with SFACE align and crop.
https://docs.openvino.ai/archive/2021.3/omz_models_model_retinaface_resnet50.html
Original question and code is here: https://stackoverflow.com/questions/76497427/javacv-dnn-retinaface-model-how-to-get-the-face-and-landmark-information
Caffemodel: https://github.com/cholihao/Retinaface-caffe/tree/master/caffemodel
Face recognition
-
A recognition service from an ML course - DNN and embeddings:
-
"The solution is very inefficient in its current form as the training model is built at each run, however it shows what's needed to make it work." (2019)
-
Recognizer class with the
match()
function for feature comparisons (detect similar faces)https://docs.opencv.org/4.x/javadoc/org/opencv/objdetect/FaceRecognizerSF.html
The C++ version of usage is here
❗ ❗ ❗ Example of a much better and practical YUNET/SF detection/comparison
Java version of comparing faces but using any recognizer example
-
Android example with face recognition and pretty involving face-matching:
-
ExoVisix example (see detection example above)
https://github.com/anupsarkar-dev/ExoVisix/blob/master/src/application/FaceRecognizer.java
-
An approach to unsupervised clustering of unknown faces:
https://bitsearch.blogspot.com/2013/02/unsupervised-face-clustering-with-opencv.html
All-together tutorials
-
C# - a very impressive runnable and online demo of face detection/recognition:
-
(Python) - Detect, embed, recognize with OpenCV: https://pyimagesearch.com/2018/09/24/opencv-face-recognition/
Similarity search
-
A very good StackOverflow response, describing methods, with code examples:
-
OpenCV Template search docs
-
DiskANN library https://github.com/microsoft/DiskANN
-
Nearest-neighbor vector search - Facebook FIASS
Object detection / other
-
YOLO https://opencv-tutorial.readthedocs.io/en/latest/yolo/yolo.html
-
Object detection tutorial for Java/Android https://docs.opencv.org/3.4/d0/d6c/tutorial_dnn_android.html