File indexing completed on 2025-01-19 03:57:56
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-09-03 0007 * Description : Integrated, multithread face detection / recognition 0008 * 0009 * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2012-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_FACE_PIPELINE_PRIVATE_H 0017 #define DIGIKAM_FACE_PIPELINE_PRIVATE_H 0018 0019 #include "facepipeline.h" 0020 0021 // Qt includes 0022 0023 #include <QExplicitlySharedDataPointer> 0024 #include <QMetaMethod> 0025 #include <QMutex> 0026 #include <QSharedData> 0027 #include <QWaitCondition> 0028 0029 // Local includes 0030 0031 #include "facedetector.h" 0032 #include "faceutils.h" 0033 #include "previewloadthread.h" 0034 #include "thumbnailloadthread.h" 0035 #include "workerobject.h" 0036 0037 namespace Digikam 0038 { 0039 0040 class Q_DECL_HIDDEN FacePipeline::Private : public QObject 0041 { 0042 Q_OBJECT 0043 0044 public: 0045 0046 explicit Private(FacePipeline* const q); 0047 0048 void processBatch(const QList<ItemInfo>& infos); 0049 void sendFromFilter(const QList<FacePipelineExtendedPackage::Ptr>& packages); 0050 void skipFromFilter(const QList<ItemInfo>& infosForSkipping); 0051 void send(const FacePipelineExtendedPackage::Ptr& package); 0052 bool senderFlowControl(const FacePipelineExtendedPackage::Ptr& package); 0053 void receiverFlowControl(); 0054 FacePipelineExtendedPackage::Ptr buildPackage(const ItemInfo& info); 0055 FacePipelineExtendedPackage::Ptr buildPackage(const ItemInfo& info, 0056 const FacePipelineFaceTagsIface&, 0057 const DImg& image); 0058 FacePipelineExtendedPackage::Ptr buildPackage(const ItemInfo& info, 0059 const FacePipelineFaceTagsIfaceList& faces, 0060 const DImg& image); 0061 FacePipelineExtendedPackage::Ptr filterOrBuildPackage(const ItemInfo& info); 0062 0063 bool hasFinished() const; 0064 void checkFinished(); 0065 void start(); 0066 void stop(); 0067 void wait(); 0068 void applyPriority(); 0069 0070 ThumbnailLoadThread* createThumbnailLoadThread(); 0071 0072 public: 0073 0074 ScanStateFilter* databaseFilter; 0075 FacePreviewLoader* previewThread; 0076 DetectionWorker* detectionWorker; 0077 ParallelPipes* parallelDetectors; 0078 RecognitionWorker* recognitionWorker; 0079 DatabaseWriter* databaseWriter; 0080 TrainerWorker* trainerWorker; 0081 DetectionBenchmarker* detectionBenchmarker; 0082 RecognitionBenchmarker* recognitionBenchmarker; 0083 0084 QList<QObject*> pipeline; 0085 QThread::Priority priority; 0086 0087 QList<ThumbnailLoadThread*> thumbnailLoadThreads; 0088 bool started; 0089 bool waiting; 0090 int infosForFiltering; 0091 int packagesOnTheRoad; 0092 int maxPackagesOnTheRoad; 0093 int totalPackagesAdded; 0094 0095 QList<FacePipelineExtendedPackage::Ptr> delayedPackages; 0096 0097 public Q_SLOTS: 0098 0099 void finishProcess(FacePipelineExtendedPackage::Ptr package); 0100 0101 Q_SIGNALS: 0102 0103 friend class FacePipeline; 0104 void startProcess(const FacePipelineExtendedPackage::Ptr& package); 0105 0106 void accuracyAndModel(double accuracy, bool yolo); 0107 void thresholdChanged(double threshold); 0108 0109 private: 0110 0111 FacePipeline* const q; 0112 }; 0113 0114 } // namespace Digikam 0115 0116 #endif // DIGIKAM_FACE_PIPELINE_PRIVATE_H