first Commit

This commit is contained in:
lidg
2026-10-26 10:56:56 +08:00
commit c8cd533d9b
81 changed files with 128540 additions and 0 deletions
+151
View File
@@ -0,0 +1,151 @@
#pragma once
// ════════════════════════════════════════════════════════════════════════════
// StereoCalibDialog.h ─ 在线双目标定对话框 (v3)
//
// [v3 改动]
// 1. 集成 AppSettings 记忆 caltab 和保存目录
// 2. 新增"预标定内参(可选)"区:可加载左/右 .cal
// 3. 新增"[EXT] 仅优化外参(固定内参)"按钮 —— 用已加载的单目内参
// 作为固定量,只优化相对位姿和各视图外参
// 4. onValidateAll 跳过已验证过的图像对
// ════════════════════════════════════════════════════════════════════════════
#include <QDialog>
#include <QList>
#include <QImage>
#include <QString>
#include <memory>
class CameraManager;
class QLabel;
class QTreeWidget;
class QTreeWidgetItem;
class QLineEdit;
class QPushButton;
class QProgressBar;
class QTextEdit;
class QComboBox;
class QDoubleSpinBox;
class QCheckBox;
struct CalibImagePair {
int index = 0;
QString leftPath;
QString rightPath;
bool validated = false;
bool validLeft = false;
bool validRight = false;
double reproj = -1.0;
bool excluded = false;
QString displayName() const {
return QString("left/right_%1").arg(index, 3, 10, QChar('0'));
}
QString validStr() const {
if (excluded) return QString::fromUtf8("已排除");
if (!validated) return QString::fromUtf8("未验证");
if (!validLeft && !validRight) return QString::fromUtf8("无效(L/R)");
if (!validLeft) return QString::fromUtf8("无效(L)");
if (!validRight) return QString::fromUtf8("无效(R)");
return QString::fromUtf8("有效");
}
QString reprojStr() const {
if (reproj < -1.5) return QString::fromUtf8("—");
if (reproj < 0) return QString::fromUtf8("N/A");
return QString("%1 px").arg(reproj, 0, 'f', 4);
}
};
class StereoCalibDialog : public QDialog
{
Q_OBJECT
public:
explicit StereoCalibDialog(CameraManager* camMgr, QWidget* parent = nullptr);
~StereoCalibDialog();
QString leftCalFile() const { return m_leftCalFile; }
QString rightCalFile() const { return m_rightCalFile; }
QString relPoseFile() const { return m_relPoseFile; }
bool hasResult() const { return m_hasResult; }
static QString defaultSaveDir();
private slots:
void onBrowseCaltab();
void onBrowseSaveDir();
void onLoadLeftIntrinsic();
void onLoadRightIntrinsic();
void onCapturePair();
void onValidateAll();
void onPairClicked(QTreeWidgetItem* item, int col);
void onExcludeSelected();
void onIncludeSelected();
void onCalibrate(); // 完整标定(优化内外参)
void onRefineExtrinsics(); // 仅优化外参(固定内参)
void onComputeErrors();
void onSave();
private:
void buildUi();
void setupConnections();
void refreshList();
void displayPair(int idx);
void displayImageOnLabel(QLabel* lbl, const QImage& img);
void log(const QString& msg);
void setProgress(int pct, const QString& msg = {});
void updateBoardParameterUi();
void invalidateDetectionResults(const QString& reason);
bool validateSinglePair(int idx);
// refineExtrinsicsOnly = true 时固定内参
bool runCalibration(const QList<int>& usedIndices, bool refineExtrinsicsOnly);
void computePerImageErrors(const QList<int>& usedIndices);
CameraManager* m_camMgr;
QString m_saveDir;
QString m_sessionImageDir;
QList<CalibImagePair> m_pairs;
QString m_leftCalFile;
QString m_rightCalFile;
QString m_relPoseFile;
bool m_hasResult = false;
double m_overallRMSE = -1.0;
struct Impl;
std::unique_ptr<Impl> m_d;
// Top
QLineEdit* m_editCaltab = nullptr;
QLineEdit* m_editSaveDir = nullptr;
QLineEdit* m_editLeftIntrinsic = nullptr;
QLineEdit* m_editRightIntrinsic = nullptr;
QComboBox* m_comboBoardType = nullptr;
QDoubleSpinBox* m_spinFindSigma = nullptr;
QDoubleSpinBox* m_spinFindAlpha = nullptr;
QDoubleSpinBox* m_spinGapTolerance = nullptr;
QDoubleSpinBox* m_spinMaxDiamMarks = nullptr;
QCheckBox* m_checkSkipFindCaltab = nullptr;
QLabel* m_labelPairCount = nullptr;
// Middle
QPushButton* m_btnCapture = nullptr;
QPushButton* m_btnValidateAll = nullptr;
QPushButton* m_btnCalibrate = nullptr;
QPushButton* m_btnRefineExt = nullptr;
QPushButton* m_btnComputeErrors = nullptr;
QPushButton* m_btnExclude = nullptr;
QPushButton* m_btnInclude = nullptr;
QPushButton* m_btnSave = nullptr;
QTreeWidget* m_treePairs = nullptr;
QLabel* m_labelRMSE = nullptr;
QProgressBar* m_progress = nullptr;
QTextEdit* m_textLog = nullptr;
// Bottom
QLabel* m_labelLeft = nullptr;
QLabel* m_labelRight = nullptr;
};