1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2025-05-02
* Description : AI tools pipeline class
*
* SPDX-FileCopyrightText : 2024-2025 by Michael Miller <michael underscore miller at msn dot com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#pragma once
// Qt includes
#include <QString>
// Local includes
#include "digikam_export.h"
#include "mlpipelinefoundation.h"
#include "iteminfo.h"
#include "metaengine_rotation.h"
#include "aitoolspipelinepackage.h"
namespace Digikam
{
/**
* @class AIToolsPipeline
* @brief A class to handle AI tools processing pipeline
*/
class DIGIKAM_GUI_EXPORT AIToolsPipeline : public MLPipelineFoundation
{
Q_OBJECT
public:
/**
* @brief Destructor
*/
~AIToolsPipeline() override;
/**
* @brief Returns the global AIToolsPipeline instance
* @return Static instance of AIToolsPipeline
*/
static AIToolsPipeline* instance();
/**
* @brief Start the pipeline processing
* @return True if the pipeline was started successfully
*/
bool start();<--- Function in derived class
/**
* @brief Auto-rotate an image using AI-based rotation detection
* @param info The item information for the image to process
* @param progress Optional progress item for tracking progress
* @return True if the item was successfully submitted for processing
*/
bool autoRotate(const ItemInfo& info, ProgressItem* const progress = nullptr);
protected:
/**
* @brief Process an item with the AI tools pipeline
* @param info The item information to process
* @param tool The AI tool to use for processing
* @param progress Optional progress item for tracking progress
* @return True if the item was successfully submitted for processing
*/
bool process(const ItemInfo& info,
AIToolsPipelinePackage::AITool tool,
ProgressItem* const progress = nullptr);
/**
* @brief Process a pre-loaded image with the AI tools pipeline
* @param image The pre-loaded image to process
* @param tool The AI tool to use for processing
* @param progress Optional progress item for tracking progress
* @return True if the image was successfully submitted for processing
*/
bool process(const DImg& image,
AIToolsPipelinePackage::AITool tool,
ProgressItem* const progress = nullptr);
/**
* @brief Implementation of the finder stage
* @return True if the stage completed successfully
*/
bool finder() override { return true; }
/**
* @brief Implementation of the loader stage
* @return True if the stage completed successfully
*/
bool loader() override;
/**
* @brief Implementation of the extractor stage
* @return True if the stage completed successfully
*/
bool extractor() override { return true; }
/**
* @brief Implementation of the classifier stage
* @return True if the stage completed successfully
*/
bool classifier() override;
/**
* @brief Implementation of the trainer stage
* @return True if the stage completed successfully
*/
bool trainer() override { return true; }
/**
* @brief Implementation of the writer stage
* @return True if the stage completed successfully
*/
bool writer() override;
/**
* @brief Implementation of the addMoreWorkers method
*/
void addMoreWorkers() override;
/**
* @brief Check if there's an existing progress item for AIToolPipeline or create a new one
* @return The existing or newly created ProgressItem
*/
ProgressItem* getProgressItem();
private Q_SLOTS:
/**
* @brief Handle scheduled signal from MLPipelineFoundation
*/
void slotScheduled();
/**
* @brief Handle started signal from MLPipelineFoundation
* @param message Start message
*/
void slotStarted(const QString& message);
/**
* @brief Handle processed signal from MLPipelineFoundation
* @param package Package that was processed
*/
void slotProcessed(const MLPipelinePackageNotify::Ptr& package);
/**
* @brief Handle skipped signal from MLPipelineFoundation
* @param package Package that was skipped
*/
void slotSkipped(const MLPipelinePackageNotify::Ptr& package);
/**
* @brief Handle finished signal from MLPipelineFoundation
*/
void slotFinished();
/**
* @brief Cancels all batch processing and clears Loader and Classifier queues
*/
void slotBatchCancel();
Q_SIGNALS:
/**
* @brief Signal emitted when processing has started
* @param filePath Path of the image being processed
*/
void signalProcessingStarted(const QString& filePath);
/**
* @brief Signal emitted when processing has finished
* @param filePath Path of the image that was processed
* @param success Whether the processing was successful
*/
void signalProcessingFinished(const QString& filePath, bool success);
/**
* @brief Signal emitted to transform an image
* @param infos List of ItemInfos to transform
* @param action Transformation action to apply
*/
void signalTransform(const QList<ItemInfo>& infos, MetaEngineRotation::TransformationAction action);
private:
/**
* @brief Constructor
* @param parent Parent object
*/
explicit AIToolsPipeline(QObject* const parent = nullptr);
class Private;
Private* const d = nullptr;
friend class AIToolsPipelineCreator;
};
} // namespace Digikam
|