This article describes the current state of the face detection algorithms of digiKam and the desired outcome of the corresponding GSoC project.
It is recommended to read Faces Management workflow improvements, as this describes the entire face management workflow. Thus it helps to understand the scope of these algorithms and where it need clarification about its structure and interfaces with other parties (code modules).
Currently, there are four different methods using the corresponding algorithm, which are more or less operational. The used algorithm can be chosen in the one Face Scan dialogue.
The goal is to be able to recognize automatically faces in images, which are not tagged, using a previous face tag registered in the face recognition database. The algorithms are complex but explained in more detail below.
currently implemented face recognition algorithms
- Deep Neural Network (DNN) DLib
This is an experimental implementation of a neural network to perform faces recognition.
This DNN is based on the DLib code, a low-level library used by OpenFace project. This code works, but it slow and complex to maintain. It is rather a proof of concept than being used for productive use.
Moreover, the documentation in the source code is non-existent. The code of Dlib is mostly the machine learning core implementation of Dlib C++ Library and referenced in projects in the Dlib users list on SourceForge.
- OpenCV - Local Binary Patterns Histograms (LBPH)
This is the most complete implementation of a face detection algorithm. Moreover, it is the oldest implementation of such an algorithm in digiKam. It's not perfect and requires at least six faces already tagged manually by the user to identify the same faces in non-tagged images.
This algorithm records a histogram of the face in the database, which is used later to perform the comparisons against new/non-tagged faces. This one use OpenCV backend based on Towards Data Science - Face Recognition: Understanding LBPH Algorithm.
- OpenCV - Eigen Faces
An alternative algorithm what uses the OpenCV backend. It was introduced to have a different source of results for face detection, enabling to proof the DNN approaches.
- OpenCV - Fisher Face
Another algorithm what uses the OpenCV backend. It was introduced for the same purposes as Eigen Faces.
According to rumours, this one is not finalized, it is said that not all methods are implemented.
There is a paper explaining the difference between Fisher and Eigen Faces, see Eigenfaces and Fisherfaces - Presenter: Harry Chao - Multimedia Analysis and Indexing –Course 2010 .pdf
why so many different approaches?
- The idea why four different algorithms were implemented is simply to be able to make a comprehnsive assessment of the currently available technologies applicable in digiKam and eventually choose the best one.
- The student who worked on the DNN project a few years ago has concluded that DNN was the best method to recognize faces with little error rate as possible. Unfortunately, the training and recognition process took too long and slowed down the application.
- Regardless that fall-back, it is agreed that DNN is the best way to go, but the current implementation based on DLib shall not be used.
- Eigen Faces
- Fisher Face
- All above-mentioned algorithms were introduced by the student Yingjie Liu during the GSoC 2017.
- More information is given in Lui's GSoC 2017 status reports and his papers:
- Face Management improvements covering Eigen Faces and Fisher Face
- Work Report
- Added the possibility to manually sort the digiKam icon view but that was done in the GSoc 2018
- LBPH tba
All the low-level steps, initiating the entire workflow, what is to detect and recognize faces by algorithm training are initiated in the class root/core/libs/facesengine/recognitiondatabase.cpp
All the middle-level codes, the subsequent actions, are multi-threaded and chained, starting by the face scan dialogue .These are listed in the directory root/core/utilities/facemanagement for better visibility. In the past, this code was mainly written by Marcel Wiesweg.
Which kind of info is stored in the database? This depends on the recognition algorithm used. Histograms, Vector, Binary data, all responsible for algorithm computation, and of course all not compatible. Typically, when you change the recognition algorithm in Face Scan dialogue, the database must be clear as well. But in fact this kind of database mechanism must be dropped, when DNN algorithm will be finalized, and only this one retained to do the job. As I said previously, 4 algorithms are implemented to choose the best one. At the end, only one must still in digiKam face engine, and all the code must be simplified.
Expected results of this GSoc 2019 project
DigiKam core already depends on OpenCV library to perform complex image processing. Moreover. the OpenCV >= 3.3 release provides a new OpenCV DNN (Deep Neural Network) module.
The goal now is to port the current digiKam core face recognition DNN extension to the new OpenCV API and write all unit tests to validate the algorithm usability, efficiency, and performance, while learning and recognizing faces automatically. The outcome shall be used instead of the other face recognition and may detection approaches, mentioned further above.
requirements on the student(s)
Typically, the student must review all Bugzilla entries will be presented in separated subsection created by the maintainers. If this page does not provide enough guidance, the student(s) must identify the top level entries to engage but with help by the listed mentors.
The student is expected to work autonomous technically-wise, so the answers to challenges will not be found necessarilly by the support of the maintainer. This does not mean that the maintainers cannot be reached by the student. Guidance will be given at any time in any case but shall that be limited to occasional situations to allow the maintainers to follow up on their work.
Regardless of the above-mentioned channel of communication, the maintainers review and validate the code in their development branch bevor merging it to the master branch.
Besides coding, it is required a technical proposal, where to list :
- the problematic,
- the code outlining, being merged into the master branch
- the tests
- the overall project plan for this summer,
- documentation to write (mostly in code), etc.