iVS3D v2.0.9
Loading...
Searching...
No Matches
blur.h
1#ifndef BLUR_H
2#define BLUR_H
3
11#include <QComboBox>
12#include <QCoreApplication>
13#include <QDoubleSpinBox>
14#include <QLabel>
15#include <QLayout>
16#include <QMap>
17#include <QObject>
18#include <QSpinBox>
19#include <QString>
20#include <QTranslator>
21#include <QWidget>
22#include <algorithm>
23
24#include "ibase.h"
25#include "iselection.h"
26#include "ipreview.h"
27
28#include "BlurAlgorithm.h"
29#include "blurlaplacian.h"
30#include "blursobel.h"
31#include "blurtenengrad.h"
32
33#define DESCRIPTION_STYLE \
34 "color: rgb(58, 58, 58); border-left: 6px solid rgb(58, 58, 58); " \
35 "border-top-right-radius: 5px; border-bottom-right-radius: 5px; " \
36 "background-color: lightblue;"
37#define WINDOW_SIZE "Window size"
38#define LOCAL_DEVIATION "Local deviation"
39#define USED_BLUR "Blur"
40
54class Blur : public PLUG::IBase, public PLUG::ISelection, public PLUG::IPreview {
55 Q_OBJECT
56 Q_PLUGIN_METADATA(IID "iVS3D.IBase")
58
59 public:
64 Blur();
65 ~Blur() override;
66
67 // IBase interface
73 QString getName() const override;
74 QMap<QString, QVariant> getSettings() const override;
75 PLUG::ApplySettingsResult applySettings(const QMap<QString, QVariant>& settings) override;
76 void activate() override;
77 void deactivate() override;
78 void onCudaChanged(bool enabled) override;
80 void onIndexChanged(uint index) override;
81
82 // IPreview interface
83 VIS::VisualizationResult generatePreview(const PLUG::PreviewData& data) override;
84
85 // ISelection interface
86 PLUG::SelectionResult selectImages(const PLUG::SelectionData& data,
87 volatile bool& cancelFlag) override;
88
89signals:
90 void syncSettingsWidget(const QString& algorithmName,
91 int windowSize,
92 double localDeviation,
93 const QString& infoText);
94
95private slots:
96 void slot_blurAlgoChanged(const QString& name);
97 void slot_wsChanged(int ws);
98 void slot_ldChanged(double ld);
99
100private:
101 std::unique_ptr<QWidget> createSettingsWidget();
102 std::vector<uint> sampleKeyframes(Reader* reader,
103 volatile bool& cancelFlag,
104 const std::vector<uint>& indices);
105 QString progressMessage(int curr, int total) const;
106 QString currentInfoText() const;
107 void invalidateCache();
108
109 Reader* m_reader = nullptr;
110 QComboBox* m_comboBoxBlur = nullptr;
111 QSpinBox* m_spinBoxWS = nullptr;
112 QDoubleSpinBox* m_spinBoxLD = nullptr;
113 QLabel* m_infoLabel = nullptr;
114 BlurAlgorithm* m_usedBlur = nullptr;
115 int m_windowSize = 30;
116 double m_localDeviation = 95.0;
117 std::vector<BlurAlgorithm*> m_blurAlgorithms = {};
118
119 // Local cache (invalidated on algorithm/input change)
120 std::vector<double> m_cachedBlurValues = {};
121 uint m_cachedPicCount = 0;
122 QString m_cachedAlgoName;
123 uint m_currentIndex = 0;
124 bool m_useCuda = false;
125};
126
127#endif // BLUR_H
The BlurAlgorithm interface provides an interface for different algorithms calculating blur values fo...
Definition BlurAlgorithm.h:27
The Blur class selects keyframes based on blur/sharpness values computed by the selected BlurAlgorith...
Definition blur.h:54
void onIndexChanged(uint index) override
onIndexChanged is called when the currently displayed frame index changes in the viewer.
Definition blur.cpp:131
QString getName() const override
getName Returns the plugin Name
Definition blur.cpp:63
VIS::VisualizationResult generatePreview(const PLUG::PreviewData &data) override
Generates a preview visualization based on the provided data. This function is executed asynchronousl...
Definition blur.cpp:137
QMap< QString, QVariant > getSettings() const override
getSettings retrieves the current settings of the plugin as a map of key-value pairs....
Definition blur.cpp:65
PLUG::InputLoadedResult onInputLoaded(const PLUG::InputData &input) override
onInputLoaded is called when a new input video or image set is loaded.
Definition blur.cpp:118
void onCudaChanged(bool enabled) override
onCudaChanged is called when the CUDA usage setting is changed in iVS3D.
Definition blur.cpp:111
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 blur.cpp:73
Blur()
Blur Constructor which creates an instance of every BlurAlgorithm and stets standard values (WindowSi...
Definition blur.cpp:40
PLUG::SettingsWidgetResult getSettingsWidget() override
getSettingsWidget creates and returns a settings QWidget for this plugin.
Definition blur.cpp:59
PLUG::SelectionResult selectImages(const PLUG::SelectionData &data, volatile bool &cancelFlag) override
Selects images based on the provided selection data.
Definition blur.cpp:212
void activate() override
activate is called when the plugin is activated in iVS3D. Plugins can override this method to perform...
Definition blur.cpp:107
void deactivate() override
deactivate is called when the plugin is deactivated in iVS3D. Plugins can override this method to per...
Definition blur.cpp:109
The IBase interface provides a base class for all plugin interfaces in iVS3D. It inherits from QObjec...
Definition ibase.h:102
The IPreview interface defines the contract for preview plugins in iVS3D. Plugins implementing this i...
Definition ipreview.h:41
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
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
Struct containing data required to generate a preview. The image is resized to the working resolution...
Definition ipreview.h:16
Data available for image selection in ISelection plugins.
Definition iselection.h:31