digiKam
faceutils.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-08-08
7  * Description : FacesEngine database interface allowing easy manipulation of face tags
8  *
9  * Copyright (C) 2010-2011 by Aditya Bhatt <adityabhatt1991 at gmail dot com>
10  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11  * Copyright (C) 2012-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_FACE_UTILS_H
27 #define DIGIKAM_FACE_UTILS_H
28 
29 // Qt includes
30 
31 #include <QStringList>
32 
33 // Local includes
34 
35 #include "identity.h"
37 #include "iteminfo.h"
38 #include "facetagseditor.h"
39 #include "digikam_export.h"
40 
41 class QImage;
42 
43 namespace Digikam
44 {
45 
46 class DImg;
47 class ThumbnailLoadThread;
48 class ThumbnailImageCatcher;
49 
50 class FaceUtils : public QObject,
51  public FaceTagsEditor
52 {
53  Q_OBJECT
54 
55 public:
56 
58  {
61  };
62 
63 public:
64 
65  explicit FaceUtils(QObject* const parent = nullptr);
66  ~FaceUtils() override;
67 
68  // --- Face detection and recognition ---
69 
77  const QList<QRectF>& detectedFaces,
78  const QList<Identity>& recognitionResults,
79  const QSize& fullSize);
80 
81  // --- Status flags ---
82 
86  bool hasBeenScanned(const ItemInfo& info) const;
87  bool hasBeenScanned(qlonglong imageid) const;
88 
92  void markAsScanned(qlonglong imageid, bool hasBeenScanned = true) const;
93  void markAsScanned(const ItemInfo& info, bool hasBeenScanned = true) const;
94 
95  // --- Utilities ---
96 
101 /*
102  void fillImageInFaces(ThumbnailImageCatcher* const catcher,
103  const QString& filePath,
104  QList<Face>& faceList,
105  const QSize& scaleSize = QSize()) const;
106 */
107 
112  void storeThumbnails(ThumbnailLoadThread* const thread,
113  const QString& filePath,
115  const DImg& image);
116 
120  QList<FaceTagsIface> toFaceTagsIfaces(qlonglong imageid,
121  const QList<QRectF>& detectedFaces,
122  const QList<Identity>& recognitionResults,
123  const QSize& fullSize) const;
124 
128  QSize rotateFaces(const ItemInfo& info, int newOrientation,
129  int oldOrientation);
130 
136  static int faceRectDisplayMargin(const QRect& rect);
137 
138  // TODO: investigate this method
139  Identity identityForTag(int tagId, FacialRecognitionWrapper& recognizer) const;
140  int tagForIdentity(const Identity& identity) const;
141 
142 protected:
143 
144  // Reimplemented
145  void addNormalTag(qlonglong imageid, int tagId) override;
146  void removeNormalTag(qlonglong imageid, int tagId) override;
147  void removeNormalTags(qlonglong imageid, const QList<int>& tagId) override;
148 
149 private:
150 
151  // Disable
152  FaceUtils(const FaceUtils&) = delete;
153  FaceUtils& operator=(const FaceUtils&) = delete;
154 };
155 
156 } // Namespace Digikam
157 
158 #endif // DIGIKAM_FACE_UTILS_H
Definition: dimg.h:62
Definition: facetagseditor.h:50
QList< FaceTagsIface > databaseFaces(qlonglong imageid) const
Definition: facetagseditor.cpp:62
Definition: faceutils.h:52
Identity identityForTag(int tagId, FacialRecognitionWrapper &recognizer) const
Definition: faceutils.cpp:291
bool hasBeenScanned(const ItemInfo &info) const
Definition: faceutils.cpp:72
void removeNormalTags(qlonglong imageid, const QList< int > &tagId) override
Definition: faceutils.cpp:389
void addNormalTag(qlonglong imageid, int tagId) override
Definition: faceutils.cpp:317
void markAsScanned(qlonglong imageid, bool hasBeenScanned=true) const
Definition: faceutils.cpp:77
static int faceRectDisplayMargin(const QRect &rect)
Definition: faceutils.cpp:430
int tagForIdentity(const Identity &identity) const
Definition: faceutils.cpp:310
QList< FaceTagsIface > writeUnconfirmedResults(qlonglong imageid, const QList< QRectF > &detectedFaces, const QList< Identity > &recognitionResults, const QSize &fullSize)
Definition: faceutils.cpp:159
FaceRecognitionSteps
Definition: faceutils.h:58
@ DetectAndRecognize
Definition: faceutils.h:60
@ DetectFaceRegions
Definition: faceutils.h:59
QSize rotateFaces(const ItemInfo &info, int newOrientation, int oldOrientation)
Definition: faceutils.cpp:396
QList< FaceTagsIface > toFaceTagsIfaces(qlonglong imageid, const QList< QRectF > &detectedFaces, const QList< Identity > &recognitionResults, const QSize &fullSize) const
Definition: faceutils.cpp:96
~FaceUtils() override
Definition: faceutils.cpp:61
void removeNormalTag(qlonglong imageid, int tagId) override
Definition: faceutils.cpp:354
void storeThumbnails(ThumbnailLoadThread *const thread, const QString &filePath, const QList< FaceTagsIface > &databaseFaces, const DImg &image)
Definition: faceutils.cpp:134
FaceUtils(QObject *const parent=nullptr)
Definition: faceutils.cpp:56
Definition: facialrecognition_wrapper.h:47
Definition: identity.h:41
Definition: iteminfo.h:78
Definition: thumbnailloadthread.h:46
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43