digiKam
opencvdnnfacedetector.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam
4  *
5  * Date : 2019-07-22
6  * Description : Class to perform faces detection using OpenCV DNN module
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  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_FACESENGINE_OPENCV_DNN_FACE_DETECTOR_H
25 #define DIGIKAM_FACESENGINE_OPENCV_DNN_FACE_DETECTOR_H
26 
27 // Qt includes
28 
29 #include <QImage>
30 #include <QList>
31 #include <QRect>
32 
33 // Local includes
34 
35 #include "digikam_opencv.h"
36 #include "dimg.h"
37 #include "dnnfacedetectorbase.h"
38 
39 namespace Digikam
40 {
41 
43 {
45  YOLO
46 };
47 
49 {
50 
51 public:
52 
55 
56  cv::Mat prepareForDetection(const DImg& inputImage, cv::Size& paddedSize) const;
57  cv::Mat prepareForDetection(const QImage& inputImage, cv::Size& paddedSize) const;
58  cv::Mat prepareForDetection(const QString& inputImagePath, cv::Size& paddedSize) const;
59 
60  QList<QRect> detectFaces(const cv::Mat& inputImage, const cv::Size& paddedSize);
61  std::vector<cv::Rect> cvDetectFaces(const cv::Mat& inputImage, const cv::Size& paddedSize);
62 
68 
69 private:
70 
71  cv::Mat prepareForDetection(cv::Mat& cvImage, cv::Size& paddedSize) const;
72 
73 private:
74 
75  // Disable
77  OpenCVDNNFaceDetector& operator=(const OpenCVDNNFaceDetector&) = delete;
78 
79 private:
80 
81  DetectorNNModel m_modelType;
82  DNNFaceDetectorBase* m_inferenceEngine;
83 };
84 
85 } // namespace Digikam
86 
87 #endif // DIGIKAM_FACESENGINE_OPENCV_DNN_FACE_DETECTOR_H
Definition: dimg.h:62
Definition: dnnfacedetectorbase.h:44
Definition: opencvdnnfacedetector.h:49
static int recommendedImageSizeForDetection()
Definition: opencvdnnfacedetector.cpp:75
~OpenCVDNNFaceDetector()
Definition: opencvdnnfacedetector.cpp:70
QList< QRect > detectFaces(const cv::Mat &inputImage, const cv::Size &paddedSize)
Definition: opencvdnnfacedetector.cpp:243
cv::Mat prepareForDetection(const DImg &inputImage, cv::Size &paddedSize) const
Definition: opencvdnnfacedetector.cpp:81
std::vector< cv::Rect > cvDetectFaces(const cv::Mat &inputImage, const cv::Size &paddedSize)
Definition: opencvdnnfacedetector.cpp:270
OpenCVDNNFaceDetector(DetectorNNModel model=DetectorNNModel::SSDMOBILENET)
Definition: opencvdnnfacedetector.cpp:46
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43
DetectorNNModel
Definition: opencvdnnfacedetector.h:43
@ SSDMOBILENET
SSD MobileNet neural network inference.
Definition: opencvdnnfacedetector.h:44
@ YOLO
YOLO neural network inference.
Definition: opencvdnnfacedetector.h:45