Initial Linux Qt OpenCV project

This commit is contained in:
luochen570
2026-05-29 22:29:30 +08:00
commit 81d586c032
22 changed files with 1748 additions and 0 deletions

72
app/include/MainWindow.h Normal file
View File

@@ -0,0 +1,72 @@
#pragma once
#include "ImageWorker.h"
#include <QMainWindow>
#include <QThread>
#include <opencv2/core.hpp>
class QAction;
class QLabel;
class QSpinBox;
class QDoubleSpinBox;
class QPushButton;
class ImageView;
class MainWindow final : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
Q_SIGNALS:
void processRequested(cv::Mat image, ImageWorker::Operation operation, double value, int dx, int dy);
private Q_SLOTS:
void openImage();
void saveImage();
void saveImageAs();
void resetToOriginal();
void onProcessFinished(ProcessResult result);
void onProcessFailed(const QString &message);
void rotateLeft();
void rotateRight();
void scaleUp();
void scaleDown();
void translateUp();
void translateDown();
void translateLeft();
void translateRight();
void extractTargets();
void classifyImage();
private:
void buildUi();
void setupWorkerThread();
void updateViews();
void setBusy(bool busy);
bool ensureHasImage() const;
void requestProcess(ImageWorker::Operation operation, double value = 0.0, int dx = 0, int dy = 0);
bool writeCurrentImageTo(const QString &path);
ImageView *originalView_ = nullptr;
ImageView *processedView_ = nullptr;
QLabel *infoLabel_ = nullptr;
QLabel *statusLabel_ = nullptr;
QDoubleSpinBox *scaleSpin_ = nullptr;
QDoubleSpinBox *angleSpin_ = nullptr;
QSpinBox *translateSpin_ = nullptr;
QAction *saveAction_ = nullptr;
QAction *saveAsAction_ = nullptr;
QThread workerThread_;
ImageWorker *worker_ = nullptr;
cv::Mat originalImage_;
cv::Mat processedImage_;
QString currentPath_;
bool busy_ = false;
};