File indexing completed on 2025-03-09 03:55:01
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam 0004 * 0005 * Date : 2013-05-18 0006 * Description : Wrapper class for face recognition 0007 * 0008 * SPDX-FileCopyrightText: 2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0009 * SPDX-FileCopyrightText: 2014-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_FACESENGINE_DATAPROVIDERS_H 0016 #define DIGIKAM_FACESENGINE_DATAPROVIDERS_H 0017 0018 // Qt includes 0019 0020 #include <QImage> 0021 #include <QList> 0022 0023 // Local includes 0024 0025 #include "digikam_export.h" 0026 #include "identity.h" 0027 0028 namespace Digikam 0029 { 0030 0031 /** 0032 * This class provides access to a list of unspecified entities, 0033 * where for each entry a QImage can be provided. 0034 * Only forward iteration is required. 0035 */ 0036 class DIGIKAM_GUI_EXPORT ImageListProvider 0037 { 0038 public: 0039 0040 ImageListProvider() = default; 0041 virtual ~ImageListProvider() = default; 0042 0043 virtual int size() const = 0; 0044 virtual bool atEnd() const = 0; 0045 virtual void proceed(int steps = 1) = 0; 0046 virtual QImage* image() = 0; 0047 virtual QList<QImage*> images() = 0; 0048 virtual void setImages(const QList<QImage*>&) = 0; 0049 0050 private: 0051 0052 Q_DISABLE_COPY(ImageListProvider) 0053 }; 0054 0055 // ---------------------------------------------------------------------------------------- 0056 0057 /** 0058 * A wrapper implementation for ImageListProvider if you have a QList of QImages 0059 */ 0060 class DIGIKAM_GUI_EXPORT QListImageListProvider : public ImageListProvider 0061 { 0062 public: 0063 0064 QListImageListProvider(); 0065 ~QListImageListProvider() override; 0066 0067 void reset(); 0068 0069 public: 0070 0071 int size() const override; 0072 bool atEnd() const override; 0073 void proceed(int steps = 1) override; 0074 QImage* image() override; 0075 QList<QImage*> images() override; 0076 void setImages(const QList<QImage*>&) override; 0077 0078 public: 0079 0080 QList<QImage*> list; 0081 QList<QImage*>::const_iterator it; 0082 0083 private: 0084 0085 Q_DISABLE_COPY(QListImageListProvider) 0086 }; 0087 0088 // ---------------------------------------------------------------------------------------- 0089 0090 class DIGIKAM_GUI_EXPORT EmptyImageListProvider : public ImageListProvider 0091 { 0092 public: 0093 0094 EmptyImageListProvider() = default; 0095 ~EmptyImageListProvider() = default; 0096 0097 int size() const override; 0098 bool atEnd() const override; 0099 void proceed(int steps = 1) override; 0100 QImage* image() override; 0101 QList<QImage*> images() override; 0102 void setImages(const QList<QImage*>&) override; 0103 0104 private: 0105 0106 Q_DISABLE_COPY(EmptyImageListProvider) 0107 }; 0108 0109 // ---------------------------------------------------------------------------------------- 0110 0111 /** 0112 * A TrainingDataProvider provides a call-back interface 0113 * for the training process to retrieve the necessary information. 0114 * It is not specified, but depends on the backend which of the methods 0115 * in which order and for which identities will be called. 0116 */ 0117 class DIGIKAM_GUI_EXPORT TrainingDataProvider 0118 { 0119 public: 0120 0121 TrainingDataProvider() = default; 0122 virtual ~TrainingDataProvider() = default; 0123 0124 /** 0125 * Provides those images for the given identity that have not yet been 0126 * supplied for training. 0127 * Ownership of the returned object stays with the TrainingDataProvider. 0128 */ 0129 virtual ImageListProvider* newImages(const Identity& identity) = 0; 0130 0131 /** 0132 * Provides all images known for the given identity. 0133 * Ownership of the returned object stays with the TrainingDataProvider. 0134 */ 0135 virtual ImageListProvider* images(const Identity& identity) = 0; 0136 0137 private: 0138 0139 Q_DISABLE_COPY(TrainingDataProvider) 0140 }; 0141 0142 } // namespace Digikam 0143 0144 #endif // DIGIKAM_FACESENGINE_DATAPROVIDERS_H