File indexing completed on 2025-03-09 03:54:59
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2019-07-09 0007 * Description : Preprocessor for openface nn model 0008 * 0009 * SPDX-FileCopyrightText: 2019 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com> 0010 * SPDX-FileCopyrightText: 2019-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_OPENFACE_PREPROCESSOR_H 0017 #define DIGIKAM_OPENFACE_PREPROCESSOR_H 0018 0019 // C++ includes 0020 0021 #include <array> 0022 0023 // Qt includes 0024 0025 #include <QMutex> 0026 0027 // Local includes 0028 0029 #include "digikam_opencv.h" 0030 #include "shapepredictor.h" 0031 0032 namespace Digikam 0033 { 0034 0035 class OpenfacePreprocessor 0036 { 0037 0038 public: 0039 0040 explicit OpenfacePreprocessor(); 0041 ~OpenfacePreprocessor(); 0042 0043 /** 0044 * Load shapepredictor model for face alignment with 68 points of face landmark extraction. 0045 */ 0046 bool loadModels(); 0047 0048 cv::Mat process(const cv::Mat& image); 0049 0050 private: 0051 0052 cv::Size outImageSize; 0053 0054 cv::Mat faceTemplate; 0055 std::array<int, 3> outerEyesNosePositions; 0056 0057 RedEye::ShapePredictor sp; 0058 0059 QMutex mutex; 0060 0061 private: 0062 0063 // Disable 0064 OpenfacePreprocessor(const OpenfacePreprocessor&) = delete; 0065 OpenfacePreprocessor& operator=(const OpenfacePreprocessor&) = delete; 0066 }; 0067 0068 } // namespace Digikam 0069 0070 #endif // DIGIKAM_OPENFACE_PREPROCESSOR_H