digiKam
facepipeline.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2010-09-03
7  * Description : Integrated, multithread face detection / recognition
8  *
9  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2012-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_FACE_PIPELINE_H
26 #define DIGIKAM_FACE_PIPELINE_H
27 
28 // Local includes
29 
30 #include "facepipelinepackage.h"
31 
32 namespace Digikam
33 {
34 
35 class FacePipeline : public QObject
36 {
37  Q_OBJECT
38 
39 public:
40 
42  {
45 
48 
51 
54 
57  };
58 
59  enum WriteMode
60  {
63 
66  };
67 
68 public:
69 
70  explicit FacePipeline();
71  ~FacePipeline() override;
72 
104  void plugDatabaseFilter(FilterMode mode);
107  void plugFacePreviewLoader();
108  void plugFaceDetector();
110  void plugFaceRecognizer();
111  void plugDatabaseWriter(WriteMode mode);
112  void plugDatabaseEditor();
113  void plugTrainer();
116  void construct();
117 
121  void cancel();
122 
126  void shutDown();
127 
128  bool hasFinished() const;
129  QString benchmarkResult() const;
130 
135  void setPriority(QThread::Priority priority);
136  QThread::Priority priority() const;
137 
138 public Q_SLOTS:
139 
146  bool process(const ItemInfo& info);
147  bool process(const ItemInfo& info, const DImg& image);
148 
155  FaceTagsIface confirm(const ItemInfo& info,
156  const FaceTagsIface& face,
157  int assignedTagId = 0,
158  const TagRegion& assignedRegion = TagRegion());
159  FaceTagsIface confirm(const ItemInfo& info,
160  const FaceTagsIface& face,
161  const DImg& image,
162  int assignedTagId = 0,
163  const TagRegion& assignedRegion = TagRegion());
167  void train(const ItemInfo& info,
168  const QList<FaceTagsIface>& faces);
169  void train(const ItemInfo& info,
170  const QList<FaceTagsIface>& faces,
171  const DImg& image);
172 
176  void remove(const ItemInfo& info,
177  const FaceTagsIface& face);
178 
182  FaceTagsIface addManually(const ItemInfo& info,
183  const DImg& image,
184  const TagRegion& assignedRegion);
185 
190  FaceTagsIface editRegion(const ItemInfo& info,
191  const DImg& image,
192  const FaceTagsIface& databaseFace,
193  const TagRegion& newRegion);
194 
200  FaceTagsIface editTag(const ItemInfo& info,
201  const FaceTagsIface& databaseFace,
202  int newTagId);
203 
209  void process(const QList<ItemInfo>& infos);
210 
211  void setAccuracyAndModel(double accuracy, bool yolo);
212 
213 Q_SIGNALS:
214 
216  void scheduled();
217 
219  void started(const QString& message);
220 
222  void processing(const FacePipelinePackage& package);
223 
225  void processed(const FacePipelinePackage& package);
226  void progressValueChanged(float progress);
227 
229  void finished();
230 
232  void skipped(const QList<ItemInfo>& skippedInfos);
233 
234 public:
235 
236  class Private;
237 
238 private:
239 
240  // Disable
241  explicit FacePipeline(QObject*) = delete;
242  FacePipeline(const FacePipeline&) = delete;
243  FacePipeline& operator=(const FacePipeline&) = delete;
244 
245 private:
246 
247  Private* const d;
248  friend class Private;
249 };
250 
251 } // namespace Digikam
252 
253 #endif // DIGIKAM_FACE_PIPELINE_H
Definition: dimg.h:62
Definition: facepipelinepackage.h:123
Definition: facepipeline_p.h:50
Definition: facepipeline.h:36
void plugFaceDetector()
Definition: facepipeline.cpp:115
void progressValueChanged(float progress)
void setPriority(QThread::Priority priority)
Definition: facepipeline.cpp:253
void plugFacePreviewLoader()
Definition: facepipeline.cpp:110
void plugRerecognizingDatabaseFilter()
Definition: facepipeline.cpp:98
void plugRecognitionBenchmarker()
Definition: facepipeline.cpp:170
void cancel()
Definition: facepipeline.cpp:269
void shutDown()
Definition: facepipeline.cpp:67
WriteMode
Definition: facepipeline.h:60
@ NormalWrite
Write results. Merge with existing entries.
Definition: facepipeline.h:62
@ OverwriteUnconfirmed
Add new results. Previous unconfirmed results will be cleared.
Definition: facepipeline.h:65
void setAccuracyAndModel(double accuracy, bool yolo)
Definition: facepipeline.cpp:434
FacePipeline()
Definition: facepipeline.cpp:44
void plugDetectionBenchmarker()
Definition: facepipeline.cpp:165
bool hasFinished() const
Definition: facepipeline.cpp:73
void plugTrainer()
Definition: facepipeline.cpp:160
void scheduled()
Emitted when processing is scheduled.
FilterMode
Definition: facepipeline.h:42
@ ReadUnconfirmedFaces
Will read unconfirmed faces for recognition.
Definition: facepipeline.h:50
@ ScanAll
Will read any given image.
Definition: facepipeline.h:44
@ ReadConfirmedFaces
Will read faces which are confirmed.
Definition: facepipeline.h:56
@ ReadFacesForTraining
Will read faces marked for training.
Definition: facepipeline.h:53
@ SkipAlreadyScanned
Will skip any image that is already marked as scanned.
Definition: facepipeline.h:47
void construct()
Definition: facepipeline.cpp:180
void remove(const ItemInfo &info, const FaceTagsIface &face)
Definition: facepipeline.cpp:419
void plugParallelFaceDetectors()
Definition: facepipeline.cpp:123
void plugFaceRecognizer()
Definition: facepipeline.cpp:147
FaceTagsIface editRegion(const ItemInfo &info, const DImg &image, const FaceTagsIface &databaseFace, const TagRegion &newRegion)
Definition: facepipeline.cpp:383
void train(const ItemInfo &info, const QList< FaceTagsIface > &faces)
Definition: facepipeline.cpp:325
QThread::Priority priority() const
Definition: facepipeline.cpp:264
FaceTagsIface editTag(const ItemInfo &info, const FaceTagsIface &databaseFace, int newTagId)
Definition: facepipeline.cpp:402
QString benchmarkResult() const
Definition: facepipeline.cpp:78
bool process(const ItemInfo &info)
Definition: facepipeline.cpp:274
void processed(const FacePipelinePackage &package)
Emitted when one package has finished processing.
void plugRetrainingDatabaseFilter()
Definition: facepipeline.cpp:104
void started(const QString &message)
Emitted when processing has started.
void skipped(const QList< ItemInfo > &skippedInfos)
Emitted when one or several packages were skipped, usually because they have already been scanned.
void plugDatabaseWriter(WriteMode mode)
Definition: facepipeline.cpp:155
~FacePipeline() override
Definition: facepipeline.cpp:50
void processing(const FacePipelinePackage &package)
Emitted when one package begins processing.
void plugDatabaseFilter(FilterMode mode)
Definition: facepipeline.cpp:93
FaceTagsIface addManually(const ItemInfo &info, const DImg &image, const TagRegion &assignedRegion)
Definition: facepipeline.cpp:367
void finished()
Emitted when the last package has finished processing.
void plugDatabaseEditor()
Definition: facepipeline.cpp:175
FaceTagsIface confirm(const ItemInfo &info, const FaceTagsIface &face, int assignedTagId=0, const TagRegion &assignedRegion=TagRegion())
Definition: facepipeline.cpp:342
Definition: facetagsiface.h:44
Definition: iteminfo.h:78
Definition: tagregion.h:47
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43