iVS3D v2.0.0
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
18#include "logfile.h"
19#include "stringcontainer.h"
20#include "modelinputpictures.h"
21#include "itransform.h"
22#include "progressable.h"
23#include "exportexif.h"
24#include "imageprocessor.h"
25#include "copyfilecommand.h"
26#include "cropcommand.h"
27#include "resizecommand.h"
28#include "transformcommand.h"
29#include "writetodiskcommand.h"
30#include "exiftagcommand.h"
31
32#define JPEG_COMPRESSION_PARAMS {cv::IMWRITE_JPEG_QUALITY, 100}
33
35{
36 QString name;
37 QString destination;
38 QString format;
39 std::optional<ROI> roi = std::nullopt;
40 Resolution original_resolution;
41 Resolution working_resolution;
42 Resolution export_resolution;
43 std::vector<ITransform *> transformations;
44 bool copy_images = false;
45};
46
50enum class ExportResultType
51{
52 Success, // all images were exported
53 PartialSuccess, // some images were broken and needed to be skipped
54 Aborted, // export was aborted by the user
55 Failed // export failed due to a runtime error
56};
57
62{
63 ExportResultType type;
64 int brokenImages = 0; // Only relevant for PartialSuccess
65 QString errorMessage; // Only relevant for Failed
66
67 static ExportResult success()
68 {
69 return {ExportResultType::Success, 0, ""};
70 }
71 static ExportResult partialSuccess(int broken)
72 {
73 return {ExportResultType::PartialSuccess, broken, ""};
74 }
75 static ExportResult aborted()
76 {
77 return {ExportResultType::Aborted, 0, ""};
78 }
79 static ExportResult failed(const QString &msg)
80 {
81 return {ExportResultType::Failed, 0, msg};
82 }
83};
84
85Q_DECLARE_METATYPE(ExportResult)
86
87
99class ExportThread : public QThread
100{
101 Q_OBJECT
102
103public:
116 explicit ExportThread(Progressable *receiver, ModelInputPictures *mip, const ExportConfig &config, volatile bool *stopped, LogFile *logFile);
118
123 ExportResult getResult() const;
124
125private:
126 Progressable *m_receiver;
127 Reader *m_reader;
128 std::vector<uint> m_keyframes;
129 volatile bool *m_stopped;
130 ExportConfig m_config;
131 ExportResult m_result = ExportResult::success();
132 LogFile *m_logFile;
133 int m_progress = 0;
134 ExportExif *m_exportExif;
135
136 void reportProgress();
137
138 volatile int m_exportProgress = 0;
139 QMutex m_mutex;
140 bool currentOperation(uint n);
141
142protected:
146 void run() override;
147};
148
149#endif // EXPORTTHREAD_H
Definition exportexif.h:14
The ExportThread class provides functionality to export images with given resolution and region of in...
Definition exportthread.h:100
The LogFile class logs progress as well as information about a process (e.g. Inport,...
Definition logfile.h:23
The ModelInputPictures class is responsible for saving all the Data regarding the input....
Definition modelinputpictures.h:41
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:35
ExportResult holds the result of an export operation.
Definition exportthread.h:62