digiKam
opencvdnnfacerecognizer.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam
4  *
5  * Date : 2020-05-22
6  * Description : Wrapper of face recognition using OpenFace
7  *
8  * Copyright (C) 2019 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
9  * Copyright (C) 2020-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2020 by Nghia Duong <minhnghiaduong997 at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef OPENCV_DNN_FACERECOGNIZER_H
26 #define OPENCV_DNN_FACERECOGNIZER_H
27 
28 // Qt includes
29 
30 #include <QImage>
31 
32 // Local includes
33 
34 #include "digikam_opencv.h"
35 #include "digikam_export.h"
36 #include "identity.h"
37 
38 namespace Digikam
39 {
40 
41 class DIGIKAM_GUI_EXPORT OpenCVDNNFaceRecognizer
42 {
43 public:
44 
46  {
47  SVM = 0,
50  DB,
51  };
52 
56  explicit OpenCVDNNFaceRecognizer(Classifier method = Tree);
58 
59 public:
60 
64  static cv::Mat prepareForRecognition(QImage& inputImage);
65 
69  static cv::Mat prepareForRecognition(const cv::Mat& cvinputImage);
70 
74  void train(const QList<QImage*>& images, const int label, const QString& context);
75 
82  int recognize(QImage* inputImage);
83 
89  QVector<int> recognize(const QList<QImage*>& inputImages);
90 
94  void clearTraining(const QList<int>& idsToClear, const QString& trainingContext);
95 
99  void setNbNeighBors(int k);
100 
104  void setThreshold(float threshold);
105 
109  bool registerTrainingData(const cv::Mat& preprocessedImage, int label);
110 
114  int verifyTestData(const cv::Mat& preprocessedImage);
115 
116 private:
117 
118  // Disable
120  OpenCVDNNFaceRecognizer& operator=(const OpenCVDNNFaceRecognizer&) = delete;
121 
122 private:
123 
124  class Private;
125  Private* d;
126 };
127 
128 } // namespace Digikam
129 
130 #endif // OPENCV_DNN_FACERECOGNIZER_H
Definition: opencvdnnfacerecognizer.h:42
Classifier
Definition: opencvdnnfacerecognizer.h:46
@ OpenCV_KNN
Definition: opencvdnnfacerecognizer.h:48
@ DB
Definition: opencvdnnfacerecognizer.h:50
@ Tree
Definition: opencvdnnfacerecognizer.h:49
Definition: datefolderview.cpp:43