- 程序启动后自动连接左右相机、应用参数并完成一次白平衡 - 测量请求到达时若相机未初始化成功,再初始化一次 - 重试成功继续同一测量请求,失败返回 INITIALIZATION 和 robot_valid=false - 初始化期间允许一个待处理测量请求,并支持取消 - IPC 状态增加 initialization_in_progress - 手动白平衡先失效初始化缓存并同步更新就绪状态 - 将带宽设置收口到 CameraManager,更新接入文档 验证:MSVC x64编译通过;启动重试8、IPC9、白平衡6、抓取7项测试通过
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
// CameraPanel.h — 相机连接/预览/冻结/参数 (QObject 控制器)
|
|
#pragma once
|
|
#include <QObject>
|
|
#include <QImage>
|
|
#include <QJsonObject>
|
|
namespace Ui { class MainWindowClass; }
|
|
class CameraManager;
|
|
class QComboBox;
|
|
|
|
class CameraPanel : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CameraPanel(Ui::MainWindowClass& ui, CameraManager* mgr, QObject* parent);
|
|
QImage lastLeftFrame() const { return m_lastLeft; }
|
|
QImage lastRightFrame() const { return m_lastRight; }
|
|
QImage captureLeft();
|
|
QImage captureRight();
|
|
bool leftConnected() const;
|
|
bool rightConnected() const;
|
|
bool leftPreviewing() const { return m_lPrev; }
|
|
bool rightPreviewing() const { return m_rPrev; }
|
|
QJsonObject initializeRemote();
|
|
bool remoteInitialized() const;
|
|
|
|
signals:
|
|
void logMessage(const QString& msg);
|
|
void remoteInitializationChanged(int cameraIndex);
|
|
|
|
private slots:
|
|
void onLeftConnect(); void onLeftDisconnect();
|
|
void onLeftPreviewToggle(); void onLeftFreeze();
|
|
void onRightConnect(); void onRightDisconnect();
|
|
void onRightPreviewToggle(); void onRightFreeze();
|
|
void onLeftFrameReady(const QImage& img);
|
|
void onRightFrameReady(const QImage& img);
|
|
void onCameraError(int idx, const QString& msg);
|
|
void onApplyParams();
|
|
void onApplyWhiteBalance();
|
|
void onCamTargetChanged(int);
|
|
void refreshComPorts();
|
|
|
|
private:
|
|
friend class CameraInitializationTest;
|
|
void updateStates();
|
|
bool applyParameters(int cameraIndex);
|
|
Ui::MainWindowClass& ui;
|
|
CameraManager* m_mgr;
|
|
QComboBox* m_comboCamTarget = nullptr;
|
|
bool m_lPrev = false, m_rPrev = false;
|
|
bool m_lFrozen = false, m_rFrozen = false;
|
|
QImage m_lastLeft, m_lastRight;
|
|
bool m_remoteInitialized[2] = {false,false};
|
|
};
|