iVS3D v2.0.9
Loading...
Searching...
No Matches
optflowcontroller.h
1#ifndef CONTROLLER_H
2#define CONTROLLER_H
3
11#include <QCoreApplication>
12#include <QDoubleSpinBox>
13#include <QLabel>
14#include <QLayout>
15#include <QObject>
16#include <QPoint>
17#include <QTranslator>
18#include <QVariant>
19#include <QWidget>
20#include <algorithm>
21#include <future>
22#include <memory>
23#include <opencv2/core/mat.hpp>
24#include <opencv2/video.hpp>
25#include <vector>
26
27#include "factory.h"
28#include "flowcalculator.h"
29#include "ibase.h"
30#include "imagegatherer.h"
31#include "iselection.h"
32#include "reader.h"
33
34#define PLUGIN_NAME QObject::tr("Stationary camera removal")
35// widget
36#define SELECTOR_LABEL_TEXT QObject::tr("Stationary threshold")
37#define SELECTOR_DESCRIPTION QObject::tr("Removes all frames where the camera is stationary. A frame is declared stationary if its camera movement is lower than given percentage of the median of all camera movements.")
38#define DESCRIPTION_STYLE "color: rgb(58, 58, 58); border-left: 6px solid rgb(58, 58, 58); border-top-right-radius: 5px; border-bottom-right-radius: 5px; background-color: lightblue;"
39// buffer
40#define BUFFER_NAME "StationaryCameraMovementValues"
41#define DELIMITER_COORDINATE "|"
42#define DELIMITER_ENTITY ","
43// settings
44#define SETTINGS_SELECTOR_THRESHOLD "Selector threshold"
45// log file
46#define LF_OPT_FLOW_TOTAL "Flow calculation"
47#define LF_SELECT_FRAMES "Selection of keyframes"
48#define LF_CE_TYPE_ADDITIONAL_INFO "Additional Computation Information"
49#define LF_CE_VALUE_USED_BUFFERED "Used buffered values"
50#define LF_CE_TYPE_DEBUG "Debug Information"
51#define LF_CE_NAME_FLOWVALUE "Flow value"
52#define LF_CE_NAME_SAMPLERES "Sampling Resolution"
53#define LF_TIMER_BUFFER "Update Buffer"
54#define LF_TIMER_CORE "Core Computation"
55#define LF_TIMER_SELECTION "Keyframe selection"
56
69{
70 Q_OBJECT
71 Q_PLUGIN_METADATA(IID "iVS3D.IBase")
72 Q_INTERFACES(PLUG::IBase PLUG::ISelection)
73
74public:
76 ~StationaryCamera() override = default;
77
78 // IBase
80 QString getName() const override;
81 QMap<QString, QVariant> getSettings() const override;
83 const QMap<QString, QVariant>& settings) override;
85 const PLUG::InputData& input) override;
86 void onCudaChanged(bool enabled) override;
87
88 // ISelection
89 PLUG::SelectionResult selectImages(const PLUG::SelectionData& data,
90 volatile bool& cancelFlag) override;
91
92signals:
93 void syncSettingsWidget(double selectorThresholdPercent);
94
95private slots:
96 void slot_selectorThresholdChanged(double value);
97
98private:
99 std::unique_ptr<QWidget> createSettingsWidget();
100 void reportProgress(const QString& op, int progress);
101
102private:
103 double m_selectorThreshold = 0.3;
104 bool m_useCuda = false;
105 Reader* m_reader = nullptr;
106 QPoint m_inputResolution = QPoint(0, 0);
107 cv::SparseMat m_bufferMat;
108
109 QDoubleSpinBox* m_selectorThresholdSpinBox = nullptr;
110};
111
112#endif // CONTROLLER_H
The IBase interface provides a base class for all plugin interfaces in iVS3D. It inherits from QObjec...
Definition ibase.h:102
Interface for keyframe/image-selection plugins in iVS3D.
Definition iselection.h:53
The Reader interface defines functions which are used for reading and parsing the import.
Definition reader.h:23
Implements stationary-camera frame filtering as PLUG::IBase + PLUG::ISelection.
Definition optflowcontroller.h:69
void onCudaChanged(bool enabled) override
onCudaChanged is called when the CUDA usage setting is changed in iVS3D.
Definition optflowcontroller.cpp:97
PLUG::ApplySettingsResult applySettings(const QMap< QString, QVariant > &settings) override
applySettings applies the provided settings to the plugin. This method is used to restore plugin conf...
Definition optflowcontroller.cpp:51
PLUG::InputLoadedResult onInputLoaded(const PLUG::InputData &input) override
onInputLoaded is called when a new input video or image set is loaded.
Definition optflowcontroller.cpp:70
PLUG::SelectionResult selectImages(const PLUG::SelectionData &data, volatile bool &cancelFlag) override
Selects images based on the provided selection data.
Definition optflowcontroller.cpp:102
PLUG::SettingsWidgetResult getSettingsWidget() override
getSettingsWidget creates and returns a settings QWidget for this plugin.
Definition optflowcontroller.cpp:28
QMap< QString, QVariant > getSettings() const override
getSettings retrieves the current settings of the plugin as a map of key-value pairs....
Definition optflowcontroller.cpp:44
QString getName() const override
getName returns the name of the plugin which will be displayed in the iVS3D interface.
Definition optflowcontroller.cpp:39
tl::expected< void, Error > InputLoadedResult
Type alias for the result of handling an input loaded event, which can be either a successful void re...
Definition ibase.h:58
tl::expected< void, Error > ApplySettingsResult
Type alias for the result of applying settings to a plugin, which can be either a successful void res...
Definition ibase.h:51
tl::expected< std::unique_ptr< QWidget >, Error > SettingsWidgetResult
Type alias for the result of a settings widget creation operation, which can be either a successful u...
Definition ibase.h:44
Struct to encapsulate data related to the input loaded event in iVS3D.
Definition ibase.h:71
Data available for image selection in ISelection plugins.
Definition iselection.h:31