feat: 重新规划ui布局;增加左右红外以及rgb相机可视化

This commit is contained in:
2026-01-21 15:36:47 +08:00
parent 8b07397b5b
commit 93c7c1a86b
10 changed files with 1287 additions and 352 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -35,7 +35,6 @@ private slots:
// 相机控制槽函数
void onStartClicked();
void onStopClicked();
void onOnceClicked();
void onExposureChanged(int value);
void onCaptureClicked();
void onBrowseSavePathClicked();
@@ -51,6 +50,9 @@ private slots:
// GVSP数据处理槽函数
void onImageReceived(const QImage &image, uint32_t blockId);
void onLeftImageReceived(const QByteArray &jpegData, uint32_t blockId);
void onRightImageReceived(const QByteArray &jpegData, uint32_t blockId);
void onRgbImageReceived(const QByteArray &jpegData, uint32_t blockId);
void onDepthDataReceived(const QByteArray &depthData, uint32_t blockId);
void onPointCloudDataReceived(const QByteArray &cloudData, uint32_t blockId);
void onPointCloudReady(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, uint32_t blockId);
@@ -84,7 +86,9 @@ private:
bool savePointCloud(const QString &dir, const QString &baseName, const QString &format);
void performBackgroundSave(const QString &saveDir, const QString &baseName,
const QString &depthFormat, const QString &pointCloudFormat,
const QImage &image, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
const QImage &image, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,
const QByteArray &leftIRData, const QByteArray &rightIRData,
const QByteArray &rgbData);
// 日志辅助函数
void addLog(const QString &message, const QString &level = "INFO");
@@ -102,28 +106,45 @@ private:
// 状态变量
bool m_isConnected;
bool m_autoSaveOnNextFrame;
// 当前帧数据(用于拍照)
QImage m_currentImage;
pcl::PointCloud<pcl::PointXYZ>::Ptr m_currentPointCloud;
uint32_t m_currentFrameId;
// 三个相机的原始JPEG数据用于保存完整分辨率图像
QByteArray m_currentLeftIRData;
QByteArray m_currentRightIRData;
QByteArray m_currentRgbData;
// UI控件指针
class QWidget *m_centralWidget;
class QSplitter *m_mainSplitter;
class QWidget *m_controlPanel;
class QLabel *m_imageDisplay;
class QLabel *m_imageDisplay; // 兼容旧代码
PointCloudWidget *m_pointCloudWidget;
// 三个图像显示控件
QLabel *m_leftImageDisplay;
QLabel *m_rightImageDisplay;
QLabel *m_rgbImageDisplay;
// 按钮控件
QPushButton *m_refreshBtn;
QPushButton *m_connectBtn;
QPushButton *m_startBtn;
QPushButton *m_stopBtn;
QPushButton *m_onceBtn;
QPushButton *m_captureBtn;
// 数据传输开关按钮
QPushButton *m_leftIRToggle;
QPushButton *m_rightIRToggle;
QPushButton *m_rgbToggle;
// 单目/双目模式切换按钮
QPushButton *m_monocularBtn;
QPushButton *m_binocularBtn;
// 输入控件
QSlider *m_exposureSlider;
QSpinBox *m_exposureSpinBox;
@@ -146,6 +167,11 @@ private:
QLabel *m_resolutionLabel;
QLabel *m_queueLabel;
// 三个相机的FPS标签
QLabel *m_leftFpsLabel;
QLabel *m_rightFpsLabel;
QLabel *m_rgbFpsLabel;
// 日志显示控件
class QTextEdit *m_logDisplay;
QPushButton *m_clearLogBtn;
@@ -162,6 +188,33 @@ private:
int m_pointCloudFrameCount;
int m_totalPointCloudFrameCount;
double m_currentPointCloudFps;
// 统计数据 - 左红外
QDateTime m_lastLeftFrameTime;
int m_leftFrameCount;
int m_totalLeftFrameCount;
double m_currentLeftFps;
// 统计数据 - 右红外
QDateTime m_lastRightFrameTime;
int m_rightFrameCount;
int m_totalRightFrameCount;
double m_currentRightFps;
// 统计数据 - RGB
QDateTime m_lastRgbFrameTime;
int m_rgbFrameCount;
int m_totalRgbFrameCount;
double m_currentRgbFps;
// RGB解码处理标志防止线程积压
QAtomicInt m_rgbProcessing;
int m_rgbSkipCounter; // RGB帧跳过计数器
// 相机启用状态标志(防止关闭后闪烁)
QAtomicInt m_leftIREnabled;
QAtomicInt m_rightIREnabled;
QAtomicInt m_rgbEnabled;
};
#endif // MAINWINDOW_H

View File

@@ -9,9 +9,11 @@ PointCloudGLWidget::PointCloudGLWidget(QWidget *parent)
, m_vertexBuffer(nullptr)
, m_vao(nullptr)
, m_pointCount(0)
, m_fixedCenter(0.0f, 0.0f, 0.0f)
, m_centerInitialized(false)
, m_orthoSize(2000.0f) // 正交投影视野大小
, m_rotationX(0.0f) // 从正面看0度
, m_rotationY(0.0f) // 从正面看0度
, m_rotationY(0.0f) // 不旋转Y轴
, m_translation(0.0f, 0.0f, 0.0f)
, m_leftButtonPressed(false)
, m_rightButtonPressed(false)
@@ -67,7 +69,7 @@ void PointCloudGLWidget::setupShaders()
uniform mat4 mvp;
void main() {
gl_Position = mvp * vec4(position, 1.0);
gl_PointSize = 2.0;
gl_PointSize = 1.0; // 减小点的大小
}
)";
@@ -221,6 +223,27 @@ void PointCloudGLWidget::updatePointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr cl
m_pointCount = m_vertices.size() / 3;
// 计算点云中心并进行中心化处理
if (m_pointCount > 0) {
float centerX = (minX + maxX) / 2.0f;
float centerY = (minY + maxY) / 2.0f;
float centerZ = (minZ + maxZ) / 2.0f;
// 第一帧:初始化固定中心点
if (!m_centerInitialized) {
m_fixedCenter = QVector3D(centerX, centerY, centerZ);
m_centerInitialized = true;
qDebug() << "[PointCloudGLWidget] Fixed center initialized:" << m_fixedCenter;
}
// 使用固定的中心点进行中心化(避免抖动)
for (size_t i = 0; i < m_vertices.size(); i += 3) {
m_vertices[i] -= m_fixedCenter.x(); // X坐标
m_vertices[i + 1] -= m_fixedCenter.y(); // Y坐标
m_vertices[i + 2] -= m_fixedCenter.z(); // Z坐标
}
}
// 添加调试日志
static int updateCount = 0;
if (updateCount < 3 || updateCount % 100 == 0) {