iVS3D v2.0.9
Loading...
Searching...
No Matches
exportthread.h
1#ifndef EXPORTTHREAD_H
2#define EXPORTTHREAD_H
3
4#include <opencv2/core.hpp>
5#include <opencv2/imgcodecs.hpp>
6#include <opencv2/imgproc.hpp>
7
8#include <QThread>
9#include <QFileDialog>
10#include <iostream>
11#include <QtConcurrent>
12#include <QMutex>
13#include <QMutexLocker>
14#include <fstream>
15#include <QFutureSynchronizer>
16#include <QFile>
17#include <QStringList>
18
19#include <memory>
20#include <atomic>
21
22#include <tl/expected.hpp>
23#include <chrono>
24#include <thread>
25
26#include "logfile.h"
27#include "stringcontainer.h"
28#include "modelinputpictures.h"
29#include "progressable.h"
30#include "exportexif.h"
31#include "imageprocessor.h"
32#include "copyfilecommand.h"
33#include "cropcommand.h"
34#include "resizecommand.h"
35#include "writetodiskcommand.h"
36#include "exiftagcommand.h"
37#include "maskmergecommand.h"
38#include "maskstack.h"
39#include "pluginthread.h"
40
41#define JPEG_COMPRESSION_PARAMS {cv::IMWRITE_JPEG_QUALITY, 100}
42
44 QString message;
45};
46
48 QStringList warnings;
49};
50
52 QString name;
53 QString destination;
54 QString format;
55 std::optional<ROI> roi;
56 Resolution original_resolution;
57 Resolution working_resolution;
58 Resolution export_resolution;
59 const MaskStack* maskStack = nullptr; // Masks to generate during export
60 bool copy_images = false;
61};
62
66enum class ExportResultType
67{
68 Success, // all images were exported
69 PartialSuccess, // some images were broken and needed to be skipped
70 Aborted, // export was aborted by the user
71 Failed // export failed due to a runtime error
72};
73
78{
79 ExportResultType type;
80 int brokenImages = 0; // Only relevant for PartialSuccess
81 QString errorMessage; // Only relevant for Failed
82
83 static ExportResult success()
84 {
85 return {ExportResultType::Success, 0, ""};
86 }
87 static ExportResult partialSuccess(int broken)
88 {
89 return {ExportResultType::PartialSuccess, broken, ""};
90 }
91 static ExportResult aborted()
92 {
93 return {ExportResultType::Aborted, 0, ""};
94 }
95 static ExportResult failed(const QString &msg)
96 {
97 return {ExportResultType::Failed, 0, msg};
98 }
99};
100
101Q_DECLARE_METATYPE(ExportResult)
102
103
117class ExportThread : public QThread {
118 Q_OBJECT
119
120public:
121 explicit ExportThread(Progressable* receiver, ModelInputPictures* mip,
122 const ExportConfig& config, volatile bool* stopped,
123 std::shared_ptr<LogFile> logFile, PluginThread* pluginThread = nullptr);
125
126 ExportResult getResult() const;
127
128 static tl::expected<ExportValidationResult, ExportError>
129 validateMaskStack(const ExportConfig& config, PluginThread* pluginThread);
130
131private:
132 Progressable* m_receiver;
133 Reader* m_reader;
134 std::vector<uint> m_keyframes;
135 volatile bool* m_stopped;
136 ExportConfig m_config;
137 ExportResult m_result = ExportResult::success();
138 std::shared_ptr<LogFile> m_logFile;
139 std::atomic<int> m_completedWorkUnits{0};
140 int m_totalWorkUnits = 0;
141 ExportExif* m_exportExif;
142 PluginThread* m_pluginThread = nullptr;
143
144 void reportProgress(const QString& operation, int stepIndex, int totalSteps);
145
146protected:
147 void run() override;
148};
149
150#endif // EXPORTTHREAD_H
Definition exportexif.h:14
The ExportThread class provides functionality to export images with given resolution,...
Definition exportthread.h:117
Manages a stack of mask generation records for later export.
Definition maskstack.h:88
The ModelInputPictures class is responsible for saving all the Data regarding the input....
Definition modelinputpictures.h:46
Definition pluginthread.h:123
The Progressable interface is used to by multithreaded actions such as sampling or exporting to repor...
Definition progressable.h:18
The Reader interface defines functions which are used for reading and parsing the import.
Definition reader.h:23
The Resolution class encapsulates an image resolution (width and height). It provides functionality f...
Definition resolution.h:17
Definition exportthread.h:51
Definition exportthread.h:43
ExportResult holds the result of an export operation.
Definition exportthread.h:78
Definition exportthread.h:47