| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2024-11-10 |
| 7 |
* Description : Performs face detection and recognition |
| 8 |
* |
| 9 |
* SPDX-FileCopyrightText: 2024-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 10 |
* SPDX-FileCopyrightText: 2024-2025 by Michael Miller <michael underscore miller at msn dot com> |
| 11 |
* |
| 12 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 13 |
* |
| 14 |
* ============================================================ */ |
| 15 |
|
| 16 |
#pragma once |
| 17 |
|
| 18 |
// Qt includes |
| 19 |
|
| 20 |
#include <QElapsedTimer> |
| 21 |
|
| 22 |
// Local includes |
| 23 |
|
| 24 |
#include "facepipelinebase.h" |
| 25 |
#include "facetagsiface.h" |
| 26 |
#include "faceutils.h" |
| 27 |
|
| 28 |
namespace Digikam |
| 29 |
{ |
| 30 |
|
| 31 |
class FacePipelineEdit : public FacePipelineBase |
| 32 |
{ |
| 33 |
Q_OBJECT |
| 34 |
|
| 35 |
public: |
| 36 |
|
| 37 |
explicit FacePipelineEdit(); |
| 38 |
~FacePipelineEdit() override = default; |
| 39 |
|
| 40 |
static FacePipelineEdit* instance(); |
| 41 |
|
| 42 |
public: |
| 43 |
|
| 44 |
bool start() override; |
| 45 |
|
| 46 |
FaceTagsIface confirmFace(const ItemInfo& info, |
| 47 |
const FaceTagsIface& face, |
| 48 |
const TagRegion& region, |
| 49 |
int tagId, |
| 50 |
bool retrain = true); |
| 51 |
|
| 52 |
void removeFace(const ItemInfo& info, |
| 53 |
const FaceTagsIface& face); |
| 54 |
|
| 55 |
void removeAllFaces(const ItemInfo& info); |
| 56 |
|
| 57 |
FaceTagsIface editTag(const ItemInfo& info, |
| 58 |
const FaceTagsIface& face, |
| 59 |
int newTagId); |
| 60 |
|
| 61 |
FaceTagsIface editRegion(const ItemInfo& info, |
| 62 |
const FaceTagsIface& face, |
| 63 |
const TagRegion& region, |
| 64 |
int tagId = -1, |
| 65 |
bool retrain = true); |
| 66 |
|
| 67 |
FaceTagsIface addManually(const ItemInfo& info, |
| 68 |
const DImg& image, |
| 69 |
const TagRegion& region, |
| 70 |
bool retrain = true); |
| 71 |
|
| 72 |
/** |
| 73 |
* Delete all saved rejected face tag lists for faces in the given image. |
| 74 |
*/ |
| 75 |
QList<FaceTagsIface> deleteRejectedFaceTagLists(const ItemInfo& info); |
| 76 |
|
| 77 |
/** |
| 78 |
* Delete all saved rejected face tags for the given face. |
| 79 |
*/ |
| 80 |
FaceTagsIface deleteRejectedFaceTagList(const FaceTagsIface& face); |
| 81 |
|
| 82 |
protected: |
| 83 |
|
| 84 |
bool finder() override |
| 85 |
{ |
| 86 |
return false; |
| 87 |
} |
| 88 |
|
| 89 |
bool loader() override; |
| 90 |
bool extractor() override; |
| 91 |
|
| 92 |
bool classifier() override |
| 93 |
{ |
| 94 |
return false; |
| 95 |
} |
| 96 |
|
| 97 |
bool trainer() override |
| 98 |
{ |
| 99 |
return false; |
| 100 |
} |
| 101 |
|
| 102 |
bool writer() override; |
| 103 |
|
| 104 |
void addMoreWorkers() override; |
| 105 |
|
| 106 |
/** |
| 107 |
* returns a copy of FaceTagsIface object with the face tags that were rejected |
| 108 |
*/ |
| 109 |
FaceTagsIface getRejectedFaceTagList(const FaceTagsIface& face) const; |
| 110 |
|
| 111 |
private: |
| 112 |
|
| 113 |
bool isStarted = false; |
| 114 |
|
| 115 |
// TODO: Remove DEBUG timer |
| 116 |
QElapsedTimer debugConfirmTimer; |
| 117 |
|
| 118 |
private: |
| 119 |
|
| 120 |
/// @note disabled |
| 121 |
FacePipelineEdit(QObject* const) = delete; |
| 122 |
FacePipelineEdit(const FacePipelineEdit&) = delete; |
| 123 |
FacePipelineEdit& operator=(const FacePipelineEdit&) = delete; |
| 124 |
}; |
| 125 |
|
| 126 |
} // namespace Digikam |