1#ifndef VISUALSIMILARITY_H
2#define VISUALSIMILARITY_H
25#include <QCoreApplication>
27#include <QElapsedTimer>
30#include <QtConcurrent>
32#include <opencv2/core.hpp>
33#include <opencv2/opencv.hpp>
34#include <opencv2/dnn.hpp>
35#include <opencv2/imgcodecs.hpp>
36#include <opencv2/imgproc.hpp>
37#include <opencv2/tracking/tracking_by_matching.hpp>
41#include "ialgorithm.h"
43#include "progressable.h"
44#include "signalobject.h"
46#define RESSOURCE_PATH "/plugins/resources/neural_network_models/"
47#define MEM_THRESEHOLD 0.8f
49#define NN_STD {0.229, 0.224, 0.225}
50#define NN_MEAN {0.485, 0.456, 0.406}
53#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;"
54#define UI_FRAMEREDUCTION_NAME QObject::tr("Select one frame every K framese")
55#define UI_FRAMEREDUCTION_DESC QObject::tr("Reduces the amount of selected frames by the factor K.")
56#define UI_NNNAME_NAME QObject::tr("Selected Neural Network")
57#define UI_NNNAME_DESC QObject::tr("The drop-down shows all files in the folder plugins/ressources/neural_network_models/ that follow the format ImageEmbedding_NAME_DIMENSION_WIDHTxHEIGHT.onnx")
58#define UI_NNNAME_BT_DESC QObject::tr("Resets the drop-Down and reloads available neural networks.")
61#define FRAMEREDUCTION_JSON_NAME "K"
62#define NNNAME_JSON_NAME "NN-Name"
65#define LF_TIMER_KEYFRAMES "keyframeSelection"
66#define LF_TTHRESHOLD "tDistThreshold"
67#define LF_RESULT_INFO_TAG "result_info"
68#define LF_COMPUTE_INFO_TAG "compute_info"
69#define LF_SELECTION_INFO_TAG "selection_info"
70#define LF_TIMER_NN "NN feeding timer"
71#define LF_TIMER_KMEANS "kMeans timer"
72#define LF_TIMER_BUFFER "safe buffer timer"
75#define BUFFER_NAME_FEATURES "DeepVisSimilarityFeatureVector"
76#define BUFFER_FEATURE_DELIMITER_X ","
77#define BUFFER_FEATURE_DELIMITER_Y ";"
78#define BUFFER_NAME_IDX "DeepVisSimilarityIdx"
94 Q_PLUGIN_METADATA(IID
"iVS3D.IAlgorithm")
124 QString
getName()
const override;
136 void setSettings(QMap<QString, QVariant> settings)
override;
155 void slot_selectedNNChanged(QString nnName);
156 void slot_reloadNN(
int index);
160 static void displayProgress(
Progressable *p,
int progress, QString msg);
161 static void displayMessage(
Progressable *p, QString msg);
162 bool bufferLookup(uint idx, cv::Mat *out);
163 cv::Mat getFeatureVector(cv::Mat totalVector,
int position);
164 void sendBuffer(cv::Mat bufferMat, std::vector<uint> calculatedIdx);
165 void readBuffer(QMap<QString,QVariant> buffer);
166 cv::Mat stringToBufferMat(QString
string);
167 QStringList collect_nns(QString path);
168 void displayErrorMessage(QString message);
171 cv::Mat m_bufferMat = cv::Mat();
172 std::vector<uint> m_bufferUsedIdx;
173 Reader *m_reader =
nullptr;
176 int m_frameReduction = -1;
177 const QRegularExpression m_nnNameFormat = QRegularExpression(
"^(ImageEmbedding)\\w+.onnx$");
178 QString m_nnFileName =
"ImageEmbedding_NAME_DIMENSION_WIDTHxHEIGHT.onnx";
180 QWidget *m_settingsWidget =
nullptr;
181 QSpinBox *m_frameReductionInput =
nullptr;
182 QComboBox *m_nnNameInput =
nullptr;
186 void createSettingsWidget(QWidget *parent);
Factory class for creating NeuralNet instances.
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 visualSimilarity.h:92
QMap< QString, QVariant > generateSettings(Progressable *receiver, bool useCuda, volatile bool *stopped) override
generateSettings tries to generate the best settings for the current input
Definition visualSimilarity.cpp:390
QWidget * getSettingsWidget(QWidget *parent) override
returns a widget to change parameters of this plugin.
Definition visualSimilarity.cpp:18
QMap< QString, QVariant > getSettings() override
getter for plugin's settings
Definition visualSimilarity.cpp:401
std::vector< uint > sampleImages(const std::vector< unsigned int > &imageList, Progressable *receiver, volatile bool *stopped, bool useCuda, LogFileParent *logFile) override
sampleImages Create an keyframe list with indices of the keyframes. The algorithm reports progress to...
Definition visualSimilarity.cpp:28
void initialize(Reader *reader, QMap< QString, QVariant > buffer, signalObject *sigObj) override
initialize is called after new images have been loaded. the plugin parameters can be selected based o...
Definition visualSimilarity.cpp:354
QString getName() const override
getName Returns the plugin name
Definition visualSimilarity.cpp:349
void setSettings(QMap< QString, QVariant > settings) override
setter for plugin's settings
Definition visualSimilarity.cpp:369
Definition signalobject.h:10
std::shared_ptr< NeuralNet > NeuralNetPtr
Smart pointer type for managing NeuralNet instances.
Definition NeuralNet.h:95