GrabBag/Tools/VrEyeView/Inc/VrEyeViewWidget.h

184 lines
4.1 KiB
C
Raw Normal View History

2026-02-18 15:11:41 +08:00
#ifndef VREYEVIEWWIDGET_H
#define VREYEVIEWWIDGET_H
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QCheckBox>
#include <QTimer>
#include <QImage>
#include <QLineEdit>
#include <mutex>
#include <memory>
#include "IVrEyeDevice.h"
#include "IChessboardDetector.h"
#include "VZNL_Common.h"
/**
* @brief
*/
struct ChessboardDetectionData
{
bool detected; // 是否检测到
double x, y, z; // 标定板中心位置相机坐标系单位mm
double nx, ny, nz; // 标定板法向量(单位向量)
double rx, ry, rz; // 标定板姿态(欧拉角,度)
};
/**
* @brief VrEyeView
*
*/
class VrEyeViewWidget : public QWidget
{
Q_OBJECT
public:
explicit VrEyeViewWidget(QWidget* parent = nullptr);
~VrEyeViewWidget() override;
/**
* @brief
*/
using DetectionCallback = std::function<void(const ChessboardDetectionData&)>;
void SetDetectionCallback(DetectionCallback callback);
signals:
/**
* @brief
*/
void chessboardDetected(const ChessboardDetectionData& data);
private slots:
/**
* @brief
*/
void onConnectCamera();
/**
* @brief
*/
void onDisconnectCamera();
/**
* @brief
*/
void onStartCapture();
/**
* @brief
*/
void onStopCapture();
/**
* @brief
*/
void onDetectChessboard();
/**
* @brief
*/
void onLoadImage();
/**
* @brief
*/
void onUpdateDisplay();
private:
/**
* @brief
*/
void setupUI();
/**
* @brief
*/
static void OnLaserDataCallback(EVzResultDataType eDataType,
SVzLaserLineData* pLaserData,
void* pUserData);
/**
* @brief
*/
void ProcessLaserData(EVzResultDataType eDataType, SVzLaserLineData* pLaserData);
/**
* @brief
*/
void UpdateImageDisplay();
/**
* @brief
*/
void DrawCorners(QImage& image, const std::vector<Point2D>& corners);
// 相机设备
IVrEyeDevice* m_eyeDevice;
// 标定板检测器
IChessboardDetector* m_detector;
// UI 控件 - 左右目图像
QLabel* m_leftImageLabel;
QLabel* m_rightImageLabel;
QPushButton* m_btnConnect;
QPushButton* m_btnDisconnect;
QPushButton* m_btnStartCapture;
QPushButton* m_btnStopCapture;
QPushButton* m_btnDetect;
// 相机参数控件
QLineEdit* m_editCameraIP;
QSpinBox* m_sbExposure;
QSpinBox* m_sbGain;
// 标定板参数控件
QSpinBox* m_sbPatternWidth;
QSpinBox* m_sbPatternHeight;
QDoubleSpinBox* m_sbSquareSize;
// 相机内参控件
QDoubleSpinBox* m_sbFx;
QDoubleSpinBox* m_sbFy;
QDoubleSpinBox* m_sbCx;
QDoubleSpinBox* m_sbCy;
// 检测选项
QCheckBox* m_cbAdaptiveThresh;
QCheckBox* m_cbNormalizeImage;
QCheckBox* m_cbAutoDetect;
// 状态标签
QLabel* m_lblStatus;
QLabel* m_lblDetectionResult;
// 定时器
QTimer* m_displayTimer;
// 状态
bool m_isConnected;
bool m_isCapturing;
// 左右目图像
QImage m_leftImage;
QImage m_rightImage;
std::vector<unsigned char> m_imageBuffer;
int m_imageWidth;
int m_imageHeight;
bool m_hasNewImage;
// 检测结果
ChessboardDetectionData m_lastDetection;
std::vector<Point2D> m_lastLeftCorners;
std::vector<Point2D> m_lastRightCorners;
// 回调函数
DetectionCallback m_detectionCallback;
};
#endif // VREYEVIEWWIDGET_H