Initial Qt OpenCV image tool
This commit is contained in:
76
MainWindow.h
Normal file
76
MainWindow.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMetaType>
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QSlider;
|
||||
class QCheckBox;
|
||||
class QThread;
|
||||
|
||||
struct ProcessParams
|
||||
{
|
||||
double scale = 1.0;
|
||||
int translateX = 0;
|
||||
int translateY = 0;
|
||||
double angle = 0.0;
|
||||
bool extractTarget = false;
|
||||
bool classifyImage = false;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cv::Mat)
|
||||
Q_DECLARE_METATYPE(ProcessParams)
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow() override;
|
||||
|
||||
signals:
|
||||
void processRequested(const cv::Mat &image, const ProcessParams ¶ms);
|
||||
|
||||
private slots:
|
||||
void openImage();
|
||||
void saveImage();
|
||||
void saveImageAs();
|
||||
void resetParams();
|
||||
void scheduleProcessing();
|
||||
void onProcessed(const cv::Mat &image, const QString &classText);
|
||||
|
||||
private:
|
||||
void buildUi();
|
||||
void updateOriginalView();
|
||||
void updateResultView();
|
||||
void setImageOnLabel(QLabel *label, const cv::Mat &mat);
|
||||
ProcessParams currentParams() const;
|
||||
bool writeResultToFile(const QString &fileName);
|
||||
|
||||
QLabel *originalLabel = nullptr;
|
||||
QLabel *resultLabel = nullptr;
|
||||
QLabel *statusLabel = nullptr;
|
||||
QPushButton *openButton = nullptr;
|
||||
QPushButton *saveButton = nullptr;
|
||||
QPushButton *saveAsButton = nullptr;
|
||||
QPushButton *resetButton = nullptr;
|
||||
QSlider *scaleSlider = nullptr;
|
||||
QSlider *rotateSlider = nullptr;
|
||||
QSlider *translateXSlider = nullptr;
|
||||
QSlider *translateYSlider = nullptr;
|
||||
QCheckBox *extractCheckBox = nullptr;
|
||||
QCheckBox *classifyCheckBox = nullptr;
|
||||
|
||||
cv::Mat originalImage;
|
||||
cv::Mat resultImage;
|
||||
QString savePath;
|
||||
|
||||
QThread *workerThread = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user