iVS3D v2.0.0
Loading...
Searching...
No Matches
smoothcontroller.h
1#ifndef CONTROLLER_H
2#define CONTROLLER_H
3
11#include <QCheckBox>
12#include <QComboBox>
13#include <QCoreApplication>
14#include <QDoubleSpinBox>
15#include <QDoubleValidator>
16#include <QLabel>
17#include <QLayout>
18#include <QLineEdit>
19#include <QObject>
20#include <QPushButton>
21#include <QSpacerItem>
22#include <QThreadPool>
23#include <QTranslator>
24#include <QWidget>
25#include <QtConcurrent/QtConcurrentMap>
26#include <algorithm>
27#include <future>
28#include <iomanip>
29#include <iostream>
30#include <numeric>
31#include <opencv2/core/mat.hpp>
32#include <opencv2/video.hpp>
33#include <vector>
34
35#include "factory.h"
36#include "flowcalculator.h"
37#include "ialgorithm.h"
38#include "imagegatherer.h"
39#include "reader.h"
40
41#define PLUGIN_NAME QObject::tr("Smooth camera movement")
42// widget
43#define SELECTOR_LABEL_TEXT QObject::tr("Movement Threshold")
44#define SELECTOR_DESCRIPTION \
45 QObject::tr( \
46 "A resolution dependend threshold, that specifies when there was " \
47 "enough movement to set a new keyframe.")
48#define DESCRIPTION_STYLE \
49 "color: rgb(58, 58, 58); border-left: 6px solid rgb(58, 58, 58); " \
50 "border-top-right-radius: 5px; border-bottom-right-radius: 5px; " \
51 "background-color: lightblue;"
52#define INFO_STYLE \
53 "color: rgb(58, 58, 58); border-left: 6px solid rgb(58, 58, 58); " \
54 "border-top-right-radius: 5px; border-bottom-right-radius: 5px; " \
55 "background-color: lightGreen;"
56// buffer
57#define BUFFER_NAME "SmoothCameraMovementBuffer"
58#define DELIMITER_COORDINATE "|"
59#define DELIMITER_ENTITY ","
60// settings
61#define SETTINGS_SELECTOR_THRESHOLD "Selector threshold"
62// log file
63#define LF_OPT_FLOW_TOTAL "Flow calculation"
64#define LF_SELECT_FRAMES "Selection of keyframes"
65#define LF_CE_TYPE_ADDITIONAL_INFO "Additional Computation Information"
66#define LF_CE_VALUE_USED_BUFFERED "Used buffered values"
67#define LF_CE_TYPE_DEBUG "Debug Information"
68#define LF_CE_NAME_FLOWVALUE "Flow value"
69#define LF_TIMER_BUFFER "Update Buffer"
70#define LF_TIMER_CORE "Core Computation"
71#define LF_TIMER_SELECTION "Keyframe selection"
72
87 Q_OBJECT
88 Q_PLUGIN_METADATA(IID "iVS3D.IAlgorithm") // implement interface as plugin,
89 // use the iid as identifier
90 Q_INTERFACES(
91 IAlgorithm) // declare this as implementation of IAlgorithm interface
92
93 public:
100
108 QWidget *getSettingsWidget(QWidget *parent) override;
109
123 std::vector<uint> sampleImages(const std::vector<uint> &imageList,
124 Progressable *receiver,
125 volatile bool *stopped, bool useCuda,
126 LogFileParent *logFile) override;
127
132 QString getName() const override;
133
142 void initialize(Reader *reader, QMap<QString, QVariant> buffer,
143 signalObject *sigObj) override;
144
153 void setSettings(QMap<QString, QVariant> settings) override;
154
164 QMap<QString, QVariant> generateSettings(Progressable *receiver,
165 bool useCuda,
166 volatile bool *stopped) override;
167
172 QMap<QString, QVariant> getSettings() override;
173
174 private:
175 // member variables
176 double m_selectorThreshold = 2.0;
177 Reader *m_reader = nullptr;
178 QPoint m_inputResolution = QPoint(0, 0);
179 cv::SparseMat m_bufferMat;
180 signalObject *m_sigObj = nullptr;
181 // widget elements
182 QWidget *m_settingsWidget = nullptr;
183 QDoubleSpinBox *m_selectorThresholdSpinBox = nullptr;
184 // timing variables
185 long m_durationFarnebackMs = 0;
186 long m_durationComputationFlowMs = 0;
187
188 // functions
189 void reportProgress(QString op, int progress, Progressable *receiver);
190 void displayMessage(QString txt, Progressable *receiver);
191 void createSettingsWidget(QWidget *parent);
197 QMap<QString, QVariant> sendBuffer();
204 void recreateBufferMatrix(QMap<QString, QVariant> buffer);
211 void stringToBufferMat(QString string);
212 QVariant bufferMatToVariant(cv::SparseMat bufferMat);
213 signals:
214 void changeUIParameter(QVariant nValue, QString paramName,
215 QString selectorName);
216};
217
218#endif // CONTROLLER_H
The IAlgorithm interface is used to include plugin implementations for different sampling algorithms....
Definition ialgorithm.h:35
The LogFileParent class logs progress as well as information about a process (e.g....
Definition LogFileParent.h:30
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
Definition smoothcontroller.h:86
void stringToBufferMat(QString string)
recreateMovementFromString is used to extract the movement value from a string and write it in the bu...
Definition smoothcontroller.cpp:280
QWidget * getSettingsWidget(QWidget *parent) override
getSettingsWidget creates a Widget, which can be used to change the algorithm parameters and returns ...
Definition smoothcontroller.cpp:11
Q_INTERFACES(IAlgorithm) public ~SmoothController()
StationaryCamera Constructor sets default values for member variables.
Definition smoothcontroller.h:99
std::vector< uint > sampleImages(const std::vector< uint > &imageList, Progressable *receiver, volatile bool *stopped, bool useCuda, LogFileParent *logFile) override
sampleImages selects keyframe if the camera is currently not stationary
Definition smoothcontroller.cpp:18
void setSettings(QMap< QString, QVariant > settings) override
setter for plugin's settings settings structure: <QMap> settings (all settings) <QVariant> selector_t...
Definition smoothcontroller.cpp:195
SmoothController()
StationaryCamera Constructor sets default values for member variables.
Definition smoothcontroller.cpp:3
QMap< QString, QVariant > sendBuffer()
sendBuffer Sends all buffered values for storeing previously calculated Infos
Definition smoothcontroller.cpp:167
QString getName() const override
getName Returns a name for displaying this algorithm to the user.
Definition smoothcontroller.cpp:165
QMap< QString, QVariant > getSettings() override
getter for plugin's settings
Definition smoothcontroller.cpp:208
QMap< QString, QVariant > generateSettings(Progressable *receiver, bool useCuda, volatile bool *stopped) override
generateSettings tries to generate the best settings for the current input
Definition smoothcontroller.cpp:200
void recreateBufferMatrix(QMap< QString, QVariant > buffer)
recreateBufferMatrix initalizes the buffer matix whith the new values from nBuffer
Definition smoothcontroller.cpp:263
void initialize(Reader *reader, QMap< QString, QVariant > buffer, signalObject *sigObj) override
initialize Sets up the default value which is corresponding to video information
Definition smoothcontroller.cpp:174
Definition signalobject.h:10