62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
// YoloPanel.h — YOLO 检测 + ROI 管理
|
|
#pragma once
|
|
#include <QObject>
|
|
#include <QImage>
|
|
#include <QRect>
|
|
#include <QVector>
|
|
#include <memory>
|
|
#include "YoloDetector.h"
|
|
#include "GrooveOccupancyDetector.h"
|
|
namespace Ui { class MainWindowClass; }
|
|
class CameraManager;
|
|
|
|
class YoloPanel : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
YoloPanel(Ui::MainWindowClass& ui, YoloDetector* det,
|
|
CameraManager* cameraManager, QObject* parent);
|
|
void setCapturedFrame(const QImage& img);
|
|
QVector<YoloResult> lastResults() const { return m_results; }
|
|
QRect roiRect() const { return m_roi; }
|
|
void setROI(const QRect& r);
|
|
void clearState();
|
|
// 全流程用的批量接口
|
|
QRect runYoloAndCrop(const QImage& img, int filterClass,
|
|
const QRect& hint, const QString& tag);
|
|
signals:
|
|
void logMessage(const QString& msg);
|
|
void roiChanged(const QRect& roi);
|
|
void yoloCompleted();
|
|
|
|
private slots:
|
|
void onLoadModel(); void onRunYolo();
|
|
void onLoadGrooveModel();
|
|
void onRunGrooveOccupancy();
|
|
void onCaptureStereoDataset();
|
|
void onCaptureStereoPair();
|
|
void onAutoCropROI(); void onClearResult();
|
|
void onClearROI();
|
|
void onModelLoaded(const QString& p);
|
|
void onYoloError(const QString& msg);
|
|
|
|
private:
|
|
void updateStates();
|
|
void autoLoadGrooveModel();
|
|
bool loadGrooveModel(const QString& modelPath);
|
|
void clearGrooveResults();
|
|
Ui::MainWindowClass& ui;
|
|
YoloDetector* m_det;
|
|
std::unique_ptr<GrooveOccupancyDetector> m_grooveDet;
|
|
CameraManager* m_cameraManager = nullptr;
|
|
QImage m_frame;
|
|
QRect m_roi;
|
|
QVector<YoloResult> m_results;
|
|
QVector<GrooveDetectionResult> m_grooveResults;
|
|
bool m_grooveModelValid = false;
|
|
float m_confThresh = 0.25f;
|
|
float m_nmsThresh = 0.45f;
|
|
float m_grooveConfThresh = 0.25f;
|
|
float m_grooveNmsThresh = 0.45f;
|
|
};
|