File indexing completed on 2025-01-05 03:56:18
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 28/08/2021 0007 * Description : Image Quality Parser - Thread to run detectors 0008 * 0009 * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2021-2022 by Phuoc Khanh Le <phuockhanhnk94 at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_IMAGEQUALITY_THREAD_H 0017 #define DIGIKAM_IMAGEQUALITY_THREAD_H 0018 0019 // Qt includes 0020 0021 #include <QThread> 0022 0023 // Local includes 0024 0025 #include "dimg.h" 0026 #include "digikam_opencv.h" 0027 #include "abstract_detector.h" 0028 #include "imagequalitycalculator.h" 0029 0030 namespace Digikam 0031 { 0032 0033 class ImageQualityThread : public QThread 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 0039 explicit ImageQualityThread(QObject* const parent, 0040 AbstractDetector* const detector, 0041 const cv::Mat& image, 0042 ImageQualityCalculator* const calculator, 0043 float weight_quality); 0044 ~ImageQualityThread() = default; 0045 0046 public: 0047 0048 void run() override; 0049 0050 private: 0051 0052 AbstractDetector* m_detector; 0053 ImageQualityCalculator* m_calculator; 0054 cv::Mat m_image; 0055 float m_weight; 0056 }; 0057 0058 // ------------------------------------------------------------------------------------------- 0059 0060 class ImageQualityThreadPool: public QObject 0061 { 0062 Q_OBJECT 0063 0064 public: 0065 0066 explicit ImageQualityThreadPool(QObject* const parent, 0067 ImageQualityCalculator* const calculator); 0068 ~ImageQualityThreadPool(); 0069 0070 public: 0071 0072 void addDetector(const cv::Mat& image, 0073 float weight_quality, 0074 AbstractDetector* const detector); 0075 0076 void start(); 0077 void end(); 0078 0079 private: 0080 0081 ImageQualityCalculator* m_calculator; 0082 QList<ImageQualityThread*> m_threads; 0083 }; 0084 0085 } // namespace Digikam 0086 0087 #endif // DIGIKAM_IMAGEQUALITY_THREAD_H