深度相机:改变数据保存路径;
This commit is contained in:
tangchao0503
2026-05-27 22:58:41 +08:00
parent 410da482bc
commit 3568495aa9
5 changed files with 113 additions and 25 deletions

View File

@ -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);
}

View File

@ -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;
};

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<height>219</height>
<width>857</width>
<height>477</height>
</rect>
</property>
<property name="sizePolicy">
@ -83,19 +83,6 @@ QPushButton:pressed
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>135</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
@ -126,7 +113,20 @@ QPushButton:pressed
</item>
</layout>
</item>
<item row="1" column="2">
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>135</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -139,7 +139,52 @@ QPushButton:pressed
</property>
</spacer>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true">QLabel {
color: rgb(255, 255, 255);
}</string>
</property>
<property name="text">
<string>数据路径</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="dataFolderLineEdit">
<property name="styleSheet">
<string notr="true">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;
}</string>
</property>
<property name="text">
<string>./CapturedImages</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="dataFolderBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>

View File

@ -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)

View File

@ -7,6 +7,8 @@
#include <QImage>
#include <Qthread>
#include <QDir>
//#include <QLabel>
#include <QFileDialog>
#include <iostream>
#include "ui_DepthCamera.h"
@ -72,6 +74,8 @@ public Q_SLOTS:
void closeDepthCamera();
void onCamClosed();
void onSelectDataFolder();
signals:
void openDepthCameraSignal();
void PlotDepthImageSignal();