From 3568495aa956673bfd8fa5adc222e4101af397df Mon Sep 17 00:00:00 2001
From: tangchao0503 <735056338@qq.com>
Date: Wed, 27 May 2026 22:58:41 +0800
Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=20=E6=B7=B1=E5=BA=A6=E7=9B=B8?=
=?UTF-8?q?=E6=9C=BA=EF=BC=9A=E6=94=B9=E5=8F=98=E6=95=B0=E6=8D=AE=E4=BF=9D?=
=?UTF-8?q?=E5=AD=98=E8=B7=AF=E5=BE=84=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
HPPA/AppSettings.cpp | 16 ++++++++
HPPA/AppSettings.h | 5 +++
HPPA/DepthCamera.ui | 79 ++++++++++++++++++++++++++++++--------
HPPA/DepthCameraWindow.cpp | 34 ++++++++++++----
HPPA/DepthCameraWindow.h | 4 ++
5 files changed, 113 insertions(+), 25 deletions(-)
diff --git a/HPPA/AppSettings.cpp b/HPPA/AppSettings.cpp
index b972dff..c735ab9 100644
--- a/HPPA/AppSettings.cpp
+++ b/HPPA/AppSettings.cpp
@@ -7,6 +7,7 @@ const int AppSettings::kDefaultFrameRate = 20;
const int AppSettings::kDefaultIntegrationTime = 1;
const int AppSettings::kDefaultGain = 0;
const QString AppSettings::kDefaultSLRDataFolder = QString();
+const QString AppSettings::kDefaultDepthCameraDataFolder = QString();
AppSettings::AppSettings()
: m_settings(QSettings::IniFormat, QSettings::UserScope,
@@ -84,3 +85,18 @@ void AppSettings::setSlrDataFolder(const QString& path)
{
m_settings.setValue("General/SLRDataFolder", path);
}
+
+QString AppSettings::depthCameraDataFolder() const
+{
+ QString path = m_settings.value("General/DepthCameraDataFolder").toString();
+ if (path.isEmpty())
+ {
+ return QCoreApplication::applicationDirPath() + "/CapturedDepthImages/";
+ }
+ return path;
+}
+
+void AppSettings::setDepthCameraDataFolder(const QString& path)
+{
+ m_settings.setValue("General/DepthCameraDataFolder", path);
+}
diff --git a/HPPA/AppSettings.h b/HPPA/AppSettings.h
index 0bbad84..0bdfe32 100644
--- a/HPPA/AppSettings.h
+++ b/HPPA/AppSettings.h
@@ -30,6 +30,10 @@ public:
// 单反相机数据保存路径
QString slrDataFolder() const;
void setSlrDataFolder(const QString& path);
+
+ // 深度相机数据保存路径
+ QString depthCameraDataFolder() const;
+ void setDepthCameraDataFolder(const QString& path);
// 在此处添加更多参数的 getter/setter ...
private:
@@ -46,4 +50,5 @@ private:
static const int kDefaultIntegrationTime;
static const int kDefaultGain;
static const QString kDefaultSLRDataFolder;
+ static const QString kDefaultDepthCameraDataFolder;
};
diff --git a/HPPA/DepthCamera.ui b/HPPA/DepthCamera.ui
index 6a1f544..51bedeb 100644
--- a/HPPA/DepthCamera.ui
+++ b/HPPA/DepthCamera.ui
@@ -6,8 +6,8 @@
0
0
- 416
- 219
+ 857
+ 477
@@ -83,19 +83,6 @@ QPushButton:pressed
- -
-
-
- Qt::Horizontal
-
-
-
- 135
- 20
-
-
-
-
-
-
@@ -126,7 +113,20 @@ QPushButton:pressed
- -
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 135
+ 20
+
+
+
+
+ -
Qt::Horizontal
@@ -139,7 +139,52 @@ QPushButton:pressed
- -
+
-
+
+
-
+
+
+ QLabel {
+ color: rgb(255, 255, 255);
+}
+
+
+ 数据路径
+
+
+
+ -
+
+
+ QLineEdit {
+ background-color: #142D7F;
+ color: #e6eeff;
+ border: 1px solid #2f6bff;
+ border-radius: 6px;
+ padding: 4px 8px;
+ min-width: 70px;
+ min-height: 20px;
+ font-size: 13px;
+}
+
+
+ ./CapturedImages
+
+
+ true
+
+
+
+ -
+
+
+ ...
+
+
+
+
+
+ -
Qt::Vertical
diff --git a/HPPA/DepthCameraWindow.cpp b/HPPA/DepthCameraWindow.cpp
index 0e80437..4e7a4f4 100644
--- a/HPPA/DepthCameraWindow.cpp
+++ b/HPPA/DepthCameraWindow.cpp
@@ -10,16 +10,21 @@ DepthCameraWindow::DepthCameraWindow(QWidget* parent)
m_DepthCameraOperation->moveToThread(m_DepthCameraThread);
m_DepthCameraThread->start();
- connect(ui.openDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::openDepthCamera);
- connect(ui.closeDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::closeDepthCamera);
+ connect(ui.openDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::openDepthCamera);
+ connect(ui.closeDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::closeDepthCamera);
- connect(this, &DepthCameraWindow::openDepthCameraSignal, m_DepthCameraOperation, &DepthCameraOperation::OpenDepthCamera);
+ connect(this, &DepthCameraWindow::openDepthCameraSignal, m_DepthCameraOperation, &DepthCameraOperation::OpenDepthCamera);
- connect(m_DepthCameraOperation, &DepthCameraOperation::CamOpenedSignal, this, &DepthCameraWindow::onCamOpened);
- connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::onCamClosed);
+ connect(m_DepthCameraOperation, &DepthCameraOperation::CamOpenedSignal, this, &DepthCameraWindow::onCamOpened);
+ connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::onCamClosed);
- connect(m_DepthCameraOperation, &DepthCameraOperation::PlotSignal, this, &DepthCameraWindow::PlotDepthImageSignal);
- connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::DepthCamClosedSignal);
+ connect(m_DepthCameraOperation, &DepthCameraOperation::PlotSignal, this, &DepthCameraWindow::PlotDepthImageSignal);
+ connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::DepthCamClosedSignal);
+
+ connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
+
+ // 初始化数据保存路径显示(从 AppSettings 恢复或使用默认)
+ ui.dataFolderLineEdit->setText(AppSettings::instance().depthCameraDataFolder());
}
DepthCameraWindow::~DepthCameraWindow()
@@ -30,6 +35,19 @@ DepthCameraWindow::~DepthCameraWindow()
m_DepthCameraOperation = nullptr;
}
+void DepthCameraWindow::onSelectDataFolder()
+{
+ QString dir = QFileDialog::getExistingDirectory(this,
+ QString::fromLocal8Bit("选择数据保存路径"),
+ ui.dataFolderLineEdit->text());
+
+ if (!dir.isEmpty())
+ {
+ ui.dataFolderLineEdit->setText(dir);
+ AppSettings::instance().setDepthCameraDataFolder(dir);
+ }
+}
+
void DepthCameraWindow::openDepthCamera()
{
if (!m_DepthCameraOperation->getRecordStatus())
@@ -131,7 +149,7 @@ void DepthCameraOperation::OpenDepthCamera()
int frameIndex = 0;
record = true;
- QString fileNamePrefix = AppSettings::instance().dataFolder() + QDir::separator() + AppSettings::instance().fileName();
+ QString fileNamePrefix = AppSettings::instance().depthCameraDataFolder() + QDir::separator() + AppSettings::instance().fileName();
QString imuFilePath = fileNamePrefix + "_IMU.txt";
std::ofstream imuFile(imuFilePath.toStdString(), std::ios::out | std::ios::trunc);
while (record)
diff --git a/HPPA/DepthCameraWindow.h b/HPPA/DepthCameraWindow.h
index 02f2901..f1506c7 100644
--- a/HPPA/DepthCameraWindow.h
+++ b/HPPA/DepthCameraWindow.h
@@ -7,6 +7,8 @@
#include
#include
#include
+//#include
+#include
#include
#include "ui_DepthCamera.h"
@@ -72,6 +74,8 @@ public Q_SLOTS:
void closeDepthCamera();
void onCamClosed();
+ void onSelectDataFolder();
+
signals:
void openDepthCameraSignal();
void PlotDepthImageSignal();