File indexing completed on 2025-03-09 03:54:58
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam 0004 * 0005 * Date : 2019-08-08 0006 * Description : Derived class to perform YOLO neural network inference 0007 * for face detection. Credit: Ayoosh Kathuria (for Yolov3 blog post), 0008 * sthanhng (for example of face detection with Yolov3). 0009 * More information with Yolov3: 0010 * https://towardsdatascience.com/yolo-v3-object-detection-53fb7d3bfe6b 0011 * sthanhng github on face detection with Yolov3: 0012 * https://github.com/sthanhng/yoloface 0013 * 0014 * SPDX-FileCopyrightText: 2019 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com> 0015 * SPDX-FileCopyrightText: 2020-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0016 * 0017 * SPDX-License-Identifier: GPL-2.0-or-later 0018 * 0019 * ============================================================ */ 0020 0021 #ifndef DIGIKAM_FACESENGINE_DNN_FACE_DETECTOR_YOLO_H 0022 #define DIGIKAM_FACESENGINE_DNN_FACE_DETECTOR_YOLO_H 0023 0024 // Local includes 0025 0026 #include "dnnfacedetectorbase.h" 0027 0028 namespace Digikam 0029 { 0030 0031 class DIGIKAM_EXPORT DNNFaceDetectorYOLO: public DNNFaceDetectorBase 0032 { 0033 0034 public: 0035 0036 explicit DNNFaceDetectorYOLO(); 0037 ~DNNFaceDetectorYOLO() override; 0038 0039 bool loadModels(); 0040 0041 void detectFaces(const cv::Mat& inputImage, 0042 const cv::Size& paddedSize, 0043 std::vector<cv::Rect>& detectedBboxes) override; 0044 0045 private: 0046 0047 std::vector<cv::String> getOutputsNames() const; 0048 0049 void postprocess(const std::vector<cv::Mat>& outs, 0050 const cv::Size& paddedSize, 0051 std::vector<cv::Rect>& detectedBboxes) const; 0052 0053 private: 0054 0055 // Disable 0056 DNNFaceDetectorYOLO(const DNNFaceDetectorYOLO&) = delete; 0057 DNNFaceDetectorYOLO& operator=(const DNNFaceDetectorYOLO&) = delete; 0058 }; 0059 0060 } // namespace Digikam 0061 0062 #endif // DIGIKAM_FACESENGINE_DNN_FACE_DETECTOR_YOLO_H