Compare commits
8 Commits
304a1aa28b
...
6456232114
| Author | SHA1 | Date | |
|---|---|---|---|
| 6456232114 | |||
| 525b39851a | |||
| 5f965f0d8e | |||
| 3568495aa9 | |||
| 410da482bc | |||
| 43acd5ba01 | |||
| 5dc589aee0 | |||
| e8ae6aa3b9 |
@ -1,10 +1,13 @@
|
||||
#include "AppSettings.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
const QString AppSettings::kDefaultDataFolder = QStringLiteral("C:\\HPPA_image");
|
||||
const QString AppSettings::kDefaultFileName = QStringLiteral("test_image");
|
||||
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,
|
||||
@ -32,6 +35,7 @@ QString AppSettings::fileName() const
|
||||
{
|
||||
return m_settings.value("General/FileName", kDefaultFileName).toString();
|
||||
}
|
||||
|
||||
void AppSettings::setFileName(const QString& path)
|
||||
{
|
||||
m_settings.setValue("General/FileName", path);
|
||||
@ -41,6 +45,7 @@ int AppSettings::frameRate() const
|
||||
{
|
||||
return m_settings.value("CameraParams/FrameRate", kDefaultFrameRate).toInt();
|
||||
}
|
||||
|
||||
void AppSettings::setFrameRate(int value)
|
||||
{
|
||||
m_settings.setValue("CameraParams/FrameRate", value);
|
||||
@ -50,6 +55,7 @@ int AppSettings::integrationTime() const
|
||||
{
|
||||
return m_settings.value("CameraParams/IntegrationTime", kDefaultIntegrationTime).toInt();
|
||||
}
|
||||
|
||||
void AppSettings::setIntegrationTime(int value)
|
||||
{
|
||||
m_settings.setValue("CameraParams/IntegrationTime", value);
|
||||
@ -59,7 +65,38 @@ int AppSettings::gain() const
|
||||
{
|
||||
return m_settings.value("CameraParams/Gain", kDefaultGain).toInt();
|
||||
}
|
||||
|
||||
void AppSettings::setGain(int value)
|
||||
{
|
||||
m_settings.setValue("CameraParams/Gain", value);
|
||||
}
|
||||
|
||||
QString AppSettings::slrDataFolder() const
|
||||
{
|
||||
QString path = m_settings.value("General/SLRDataFolder").toString();
|
||||
if (path.isEmpty())
|
||||
{
|
||||
return QCoreApplication::applicationDirPath() + "/CapturedImages/";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -26,6 +26,14 @@ public:
|
||||
// 增益
|
||||
int gain() const;
|
||||
void setGain(int value);
|
||||
|
||||
// 单反相机数据保存路径
|
||||
QString slrDataFolder() const;
|
||||
void setSlrDataFolder(const QString& path);
|
||||
|
||||
// 深度相机数据保存路径
|
||||
QString depthCameraDataFolder() const;
|
||||
void setDepthCameraDataFolder(const QString& path);
|
||||
// 在此处添加更多参数的 getter/setter ...
|
||||
|
||||
private:
|
||||
@ -41,4 +49,6 @@ private:
|
||||
static const int kDefaultFrameRate;
|
||||
static const int kDefaultIntegrationTime;
|
||||
static const int kDefaultGain;
|
||||
static const QString kDefaultSLRDataFolder;
|
||||
static const QString kDefaultDepthCameraDataFolder;
|
||||
};
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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();
|
||||
|
||||
102
HPPA/HPPA.cpp
102
HPPA/HPPA.cpp
@ -385,6 +385,7 @@ HPPA::HPPA(QWidget* parent)
|
||||
m_carousel = new MyCarousel();
|
||||
m_carousel->setObjectName(QString::fromUtf8("carousel"));
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
QScrollArea* sa = new QScrollArea();
|
||||
sa->setObjectName("sa");
|
||||
sa->setStyleSheet(R"(
|
||||
@ -430,6 +431,29 @@ HPPA::HPPA(QWidget* parent)
|
||||
m_carousel->addWidget(sa_depthCamera);
|
||||
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
QScrollArea* sa_SingleLensReflexCamera = new QScrollArea();
|
||||
sa_SingleLensReflexCamera->setObjectName("sa_SingleLensReflexCamera");
|
||||
sa_SingleLensReflexCamera->setStyleSheet(R"(
|
||||
border: none;
|
||||
background-color: #0D1233;
|
||||
)");
|
||||
QGridLayout* gridLayout_sa_SingleLensReflexCamera = new QGridLayout(sa_SingleLensReflexCamera);
|
||||
gridLayout_sa_SingleLensReflexCamera->setSpacing(6);
|
||||
gridLayout_sa_SingleLensReflexCamera->setObjectName(QString::fromUtf8("gridLayout_sa_SingleLensReflexCamera"));
|
||||
gridLayout_sa_SingleLensReflexCamera->setVerticalSpacing(0);
|
||||
gridLayout_sa_SingleLensReflexCamera->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_SingleLensReflexCamera_label = new QLabel();
|
||||
m_SingleLensReflexCamera_label->setAlignment(Qt::AlignHCenter);
|
||||
m_SingleLensReflexCamera_label->setStyleSheet(R"(
|
||||
background-color: #0D1233;
|
||||
)");
|
||||
gridLayout_sa_SingleLensReflexCamera->addWidget(m_SingleLensReflexCamera_label);
|
||||
|
||||
m_carousel->addWidget(sa_SingleLensReflexCamera);
|
||||
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_carousel->play();
|
||||
|
||||
gridLayout_carouselContainer->addWidget(m_carousel);
|
||||
@ -784,6 +808,9 @@ void HPPA::initControlTabwidget()
|
||||
|
||||
//单反相机
|
||||
m_singleLensReflexCameraWindow = new SingleLensReflexCameraWindow();
|
||||
connect(m_singleLensReflexCameraWindow, &SingleLensReflexCameraWindow::LiveViewImageReady, this, &HPPA::onLiveViewImageReady);
|
||||
connect(m_singleLensReflexCameraWindow, &SingleLensReflexCameraWindow::LiveViewStopped, this, &HPPA::onLiveViewStopped);
|
||||
|
||||
ui.controlTabWidget->addTab(m_singleLensReflexCameraWindow, QString::fromLocal8Bit("单反相机"));
|
||||
|
||||
//rgb相机
|
||||
@ -1037,16 +1064,20 @@ void HPPA::removeLayerByNode(LayerTreeNode* node)
|
||||
const int tabIndex = m_imageViewerTabWidget->indexOf(widget);
|
||||
if (tabIndex >= 0)
|
||||
{
|
||||
if (m_recordFrameCounter)
|
||||
{
|
||||
m_recordFrameCounter->removeCounter(widget);
|
||||
}
|
||||
m_imageViewerTabWidget->removeTab(tabIndex);
|
||||
}
|
||||
widget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mapLayer || mapLayer->layerType() == MapLayer::LayerType::Raster)
|
||||
{
|
||||
if (m_recordFrameCounter)
|
||||
{
|
||||
m_recordFrameCounter->removeCounter(static_cast<RasterLayer*>(mapLayer));
|
||||
}
|
||||
}
|
||||
|
||||
// 删除 MapLayerStore 中的 mapLayer
|
||||
m_MapLayerStore->removeLayer(mapLayer);
|
||||
|
||||
@ -1104,10 +1135,6 @@ void HPPA::removeImageByTreeIndex()
|
||||
const int tabIndex = m_imageViewerTabWidget->indexOf(layerWidget);
|
||||
if (tabIndex >= 0)
|
||||
{
|
||||
if (m_recordFrameCounter)
|
||||
{
|
||||
m_recordFrameCounter->removeCounter(layerWidget);
|
||||
}
|
||||
m_imageViewerTabWidget->removeTab(tabIndex);
|
||||
}
|
||||
layerWidget->deleteLater();
|
||||
@ -1674,11 +1701,6 @@ QWidget* HPPA::onCreateTab(QString tabName)
|
||||
|
||||
m_imageViewerTabWidget->setCurrentIndex(m_imageViewerTabWidget->count() - 1);
|
||||
|
||||
if (m_recordFrameCounter)
|
||||
{
|
||||
m_recordFrameCounter->addCounter(tabTmp);
|
||||
}
|
||||
|
||||
return tabTmp;
|
||||
}
|
||||
|
||||
@ -1695,7 +1717,11 @@ void HPPA::onTabWidgetCurrentChanged(int index)//代码新建一个tab,会调
|
||||
if (m_recordFrameCounter)
|
||||
{
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->widget(index);
|
||||
m_recordFrameCounter->switchTo(currentWidget);
|
||||
MapLayer* currentMapLayer = m_MapLayerStore->mapLayerForWidget(currentWidget);
|
||||
if (currentMapLayer)
|
||||
{
|
||||
m_recordFrameCounter->switchTo(static_cast<RasterLayer*>(currentMapLayer));
|
||||
}
|
||||
}
|
||||
|
||||
//获取绘图控件
|
||||
@ -1892,6 +1918,22 @@ void HPPA::onClearLabel()
|
||||
m_cam_label->setText("closed");
|
||||
}
|
||||
|
||||
void HPPA::onLiveViewImageReady(const QImage& image)
|
||||
{
|
||||
if (m_SingleLensReflexCamera_label && !image.isNull())
|
||||
{
|
||||
// 缩放图像以适应标签大小
|
||||
QPixmap pixmap = QPixmap::fromImage(image);
|
||||
pixmap = pixmap.scaled(m_SingleLensReflexCamera_label->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
m_SingleLensReflexCamera_label->setPixmap(pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::onLiveViewStopped()
|
||||
{
|
||||
m_SingleLensReflexCamera_label->clear();
|
||||
}
|
||||
|
||||
void HPPA::onPlotDepthImage()
|
||||
{
|
||||
QPixmap pixmap = QPixmap::fromImage(m_depthCameraWindow->m_DepthCameraOperation->m_depthImage);
|
||||
@ -1985,6 +2027,14 @@ void HPPA::onOpenImg()
|
||||
QString baseName = fi.completeBaseName();
|
||||
|
||||
addLayer(baseName, uri, true);
|
||||
|
||||
// 获取影像行数并更新帧数显示
|
||||
MapLayer* mapLayer = m_MapLayerStore->getLayerByAbsolutePath(uri);
|
||||
if (mapLayer && m_recordFrameCounter)
|
||||
{
|
||||
RasterLayer* rasterLayer = static_cast<RasterLayer*>(mapLayer);
|
||||
m_recordFrameCounter->updateFrameCount(rasterLayer, rasterLayer->height());
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::disconnectImagerAndCleanup()
|
||||
@ -2405,6 +2455,12 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
return;
|
||||
}
|
||||
|
||||
MapLayer* mapLayer = m_MapLayerStore->getLayerByAbsolutePath(filePath);
|
||||
if (mapLayer && m_recordFrameCounter)
|
||||
{
|
||||
m_recordFrameCounter->updateFrameCount(static_cast<RasterLayer*>(mapLayer), m_Imager->getFrameCounter());
|
||||
}
|
||||
|
||||
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||
return;
|
||||
|
||||
@ -2416,11 +2472,6 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFrameCounter());//界面中显示已经采集的帧数
|
||||
|
||||
if (m_recordFrameCounter)
|
||||
{
|
||||
m_recordFrameCounter->updateFrameCount(currentWidget, m_Imager->getFrameCounter());
|
||||
}
|
||||
|
||||
//创建需要显示的图像--opencv版本
|
||||
ImageProcessor imageProcessor;
|
||||
//cv::Mat rgbImage(*m_Imager->getRgbImage()->m_matRgbImage, cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());//2022.3.18重构的
|
||||
@ -2622,9 +2673,14 @@ void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refres
|
||||
|
||||
if (m_MapLayerStore) m_MapLayerStore->addLayer(ml);
|
||||
|
||||
if (m_recordFrameCounter)
|
||||
{
|
||||
m_recordFrameCounter->addCounter(ml);
|
||||
}
|
||||
|
||||
if (isAddImage)
|
||||
{
|
||||
newImage(ml, RasterImageLayer::RendererType::Multiband, node);
|
||||
newImage(ml, RasterImageLayer::RendererType::Multiband, node, refresh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2658,6 +2714,12 @@ void HPPA::newImage(RasterLayer* ml, RasterImageLayer::RendererType type, LayerT
|
||||
|
||||
void HPPA::onLayerTreeSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
||||
{
|
||||
//采集过程中禁用图层树的选择功能
|
||||
if (m_RecordState % 2 == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Q_UNUSED(deselected);
|
||||
|
||||
if (selected.indexes().isEmpty())
|
||||
|
||||
@ -274,6 +274,7 @@ private:
|
||||
|
||||
MyCarousel* m_carousel;
|
||||
QLabel* m_cam_label;
|
||||
QLabel* m_SingleLensReflexCamera_label;
|
||||
QLabel* m_depthCamera_label;
|
||||
QPushButton* m_open_rgb_camera_btn;
|
||||
QPushButton* m_close_rgb_camera_btn;
|
||||
@ -358,6 +359,9 @@ public Q_SLOTS:
|
||||
void onPlotRgbImage();
|
||||
void onPlotDepthImage();
|
||||
|
||||
void onLiveViewImageReady(const QImage& image);
|
||||
void HPPA::onLiveViewStopped();
|
||||
|
||||
void onClearLabel();
|
||||
void onClearDepthLabel();
|
||||
|
||||
|
||||
@ -55,18 +55,18 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;C:\Program Files\OrbbecSDK 2.7.6\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;C:\Program Files\OrbbecSDK 2.7.6\lib;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Library;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>Spectral Insight</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;C:\Program Files\OrbbecSDK 2.7.6\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;C:\Program Files\OrbbecSDK 2.7.6\lib;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Library;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>Spectral Insight</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
@ -75,7 +75,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
@ -125,6 +125,15 @@ MapLayer* MapLayerStore::getLayerAt(int index) const
|
||||
return m_layers[index].mapLayer.get();
|
||||
}
|
||||
|
||||
MapLayer* MapLayerStore::getLayerByAbsolutePath(const QString& absolutePath) const
|
||||
{
|
||||
for (const auto& entry : m_layers) {
|
||||
if (entry.mapLayer->dataPath() == absolutePath)
|
||||
return entry.mapLayer.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int MapLayerStore::layerCount() const
|
||||
{
|
||||
return (int)m_layers.size();
|
||||
|
||||
@ -35,6 +35,7 @@ public:
|
||||
bool containsLayer(const QString& url, bool isAbsolutePath = true) const;
|
||||
|
||||
MapLayer* getLayer(const QString& name) const;
|
||||
MapLayer* getLayerByAbsolutePath(const QString& absolutePath) const;
|
||||
MapLayer* getLayerAt(int index) const;
|
||||
int layerCount() const;
|
||||
|
||||
|
||||
@ -8,32 +8,46 @@
|
||||
RasterImageLayer::RasterImageLayer(RasterLayer* layer, RendererType type)
|
||||
: m_layer(layer)
|
||||
, m_rendererType(type)
|
||||
, m_rendererInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
void RasterImageLayer::ensureRenderer()
|
||||
{
|
||||
if (m_rendererInitialized) return;
|
||||
if (!m_layer) return;
|
||||
|
||||
RasterDataProvider* provider = nullptr;
|
||||
if (m_layer->dataProvider()) {
|
||||
if (m_layer->dataProvider())
|
||||
{
|
||||
provider = m_layer->dataProvider();
|
||||
} else if (m_layer->openDataProvider()) {
|
||||
}
|
||||
else if (m_layer->openDataProvider())
|
||||
{
|
||||
provider = m_layer->dataProvider();
|
||||
}
|
||||
|
||||
if (!provider) return;
|
||||
|
||||
switch (type) {
|
||||
case RendererType::Multiband: {
|
||||
auto* multiRenderer = new MultibandRasterRenderer(provider);
|
||||
m_renderer.reset(multiRenderer);
|
||||
multiRenderer->setParams(m_multibandParams);
|
||||
break;
|
||||
}
|
||||
case RendererType::Singleband: {
|
||||
auto* singleRenderer = new SinglebandRasterRenderer(provider);
|
||||
m_renderer.reset(singleRenderer);
|
||||
singleRenderer->setParams(m_singlebandParams);
|
||||
break;
|
||||
}
|
||||
switch (m_rendererType)
|
||||
{
|
||||
case RendererType::Multiband:
|
||||
{
|
||||
auto* multiRenderer = new MultibandRasterRenderer(provider);
|
||||
m_renderer.reset(multiRenderer);
|
||||
multiRenderer->setParams(m_multibandParams);
|
||||
break;
|
||||
}
|
||||
case RendererType::Singleband:
|
||||
{
|
||||
auto* singleRenderer = new SinglebandRasterRenderer(provider);
|
||||
m_renderer.reset(singleRenderer);
|
||||
singleRenderer->setParams(m_singlebandParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_rendererInitialized = true;
|
||||
}
|
||||
|
||||
RasterImageLayer::~RasterImageLayer()
|
||||
@ -43,6 +57,7 @@ RasterImageLayer::~RasterImageLayer()
|
||||
|
||||
QImage RasterImageLayer::render()
|
||||
{
|
||||
ensureRenderer();
|
||||
if (!m_renderer) return QImage();
|
||||
return m_renderer->render();
|
||||
}
|
||||
@ -50,7 +65,7 @@ QImage RasterImageLayer::render()
|
||||
void RasterImageLayer::setMultibandParams(const MultibandRenderParams& params)
|
||||
{
|
||||
m_multibandParams = params;
|
||||
if (m_rendererType == RendererType::Multiband) {
|
||||
if (m_rendererInitialized && m_rendererType == RendererType::Multiband) {
|
||||
auto* r = static_cast<MultibandRasterRenderer*>(m_renderer.get());
|
||||
r->setParams(params);
|
||||
}
|
||||
@ -59,7 +74,7 @@ void RasterImageLayer::setMultibandParams(const MultibandRenderParams& params)
|
||||
void RasterImageLayer::setSinglebandParams(const SinglebandRenderParams& params)
|
||||
{
|
||||
m_singlebandParams = params;
|
||||
if (m_rendererType == RendererType::Singleband) {
|
||||
if (m_rendererInitialized && m_rendererType == RendererType::Singleband) {
|
||||
auto* r = static_cast<SinglebandRasterRenderer*>(m_renderer.get());
|
||||
r->setParams(params);
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ public:
|
||||
RasterImageLayer(RasterLayer* layer, RendererType type);
|
||||
~RasterImageLayer();
|
||||
|
||||
void ensureRenderer();
|
||||
QImage render();
|
||||
|
||||
RasterLayer* layer() const { return m_layer; }
|
||||
@ -41,4 +42,5 @@ private:
|
||||
std::unique_ptr<RasterRendererBase> m_renderer;
|
||||
MultibandRenderParams m_multibandParams;
|
||||
SinglebandRenderParams m_singlebandParams;
|
||||
bool m_rendererInitialized = false;
|
||||
};
|
||||
|
||||
@ -78,3 +78,21 @@ std::vector<double> RasterLayer::bandWavelengths() const
|
||||
}
|
||||
return m_provider->bandWavelengths();
|
||||
}
|
||||
|
||||
int RasterLayer::width() const
|
||||
{
|
||||
if (!m_provider) {
|
||||
auto* self = const_cast<RasterLayer*>(this);
|
||||
if (!self->openDataProvider()) return 0;
|
||||
}
|
||||
return m_provider->width();
|
||||
}
|
||||
|
||||
int RasterLayer::height() const
|
||||
{
|
||||
if (!m_provider) {
|
||||
auto* self = const_cast<RasterLayer*>(this);
|
||||
if (!self->openDataProvider()) return 0;
|
||||
}
|
||||
return m_provider->height();
|
||||
}
|
||||
|
||||
@ -31,6 +31,10 @@ public:
|
||||
// Get all band wavelengths
|
||||
std::vector<double> bandWavelengths() const;
|
||||
|
||||
// Get dimensions
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<RasterDataProvider> m_provider;
|
||||
};
|
||||
|
||||
@ -69,7 +69,7 @@ QPushButton:pressed
|
||||
padding-bottom: 7px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -97,21 +97,8 @@ QPushButton:pressed
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="closeSLRCamera_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关 闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="openSLRCamera_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
@ -124,9 +111,22 @@ QPushButton:pressed
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeSLRCamera_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关 闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<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>
|
||||
@ -152,7 +197,42 @@ QPushButton:pressed
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="takePhoto_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>拍 摄</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stopTakePhoto_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>停 拍</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>dataFolderLineEdit</zorder>
|
||||
<zorder>dataFolderBtn</zorder>
|
||||
<zorder>label</zorder>
|
||||
<zorder>openSLRCamera_btn</zorder>
|
||||
<zorder>layoutWidget</zorder>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
#include "SingleLensReflexCameraWindow.h"
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QBuffer>
|
||||
|
||||
// 全局变量用于回调函数访问
|
||||
static SingleLensReflexCameraOperation* g_cameraOperation = nullptr;
|
||||
|
||||
SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_isCapturing(false)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
@ -10,26 +17,81 @@ SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
||||
m_SingleLensReflexCameraOperation->moveToThread(m_SLRCameraThread);
|
||||
m_SLRCameraThread->start();
|
||||
|
||||
// 基本连接
|
||||
connect(ui.openSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::openSLRCamera);
|
||||
connect(ui.closeSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::closeSLRCamera);
|
||||
|
||||
connect(this, &SingleLensReflexCameraWindow::openSLRCameraSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::OpenSLRCamera);
|
||||
connect(ui.closeSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::closeSLRCamera);
|
||||
connect(this, &SingleLensReflexCameraWindow::closeSLRCameraSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CloseSLRCamera);
|
||||
|
||||
connect(ui.takePhoto_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::takePhoto);
|
||||
connect(this, &SingleLensReflexCameraWindow::takePhotoSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::takePhoto);
|
||||
connect(ui.stopTakePhoto_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::stopTakePhoto);
|
||||
connect(this, &SingleLensReflexCameraWindow::stopTakePhotoSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::stopTakePhoto);
|
||||
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamOpenedSignal, this, &SingleLensReflexCameraWindow::onCamOpened);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::onCamClosed);
|
||||
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::PlotSignal, this, &SingleLensReflexCameraWindow::PlotSLRImageSignal);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::SLRCamClosedSignal);
|
||||
|
||||
connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
|
||||
|
||||
// 新增信号连接
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::ImageCapturedSignal, this, &SingleLensReflexCameraWindow::onImageCaptured);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::ErrorSignal, this, &SingleLensReflexCameraWindow::onError);
|
||||
|
||||
// 实时取景信号连接
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::LiveViewImageReady, this, &SingleLensReflexCameraWindow::LiveViewImageReady, Qt::QueuedConnection);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::LiveViewStarted, this, &SingleLensReflexCameraWindow::LiveViewStarted);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::LiveViewStopped, this, &SingleLensReflexCameraWindow::LiveViewStopped);
|
||||
|
||||
// 拍照状态信号连接
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CaptureStartedSignal, this, &SingleLensReflexCameraWindow::onCaptureStarted);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CaptureStoppedSignal, this, &SingleLensReflexCameraWindow::onCaptureStopped);
|
||||
|
||||
// 拍照控制信号连接
|
||||
connect(this, &SingleLensReflexCameraWindow::startCaptureSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::startCapture);
|
||||
connect(this, &SingleLensReflexCameraWindow::stopCaptureSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::stopCapture);
|
||||
connect(this, &SingleLensReflexCameraWindow::captureOnceSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::captureOnce);
|
||||
|
||||
// 初始化按钮状态
|
||||
ui.closeSLRCamera_btn->setEnabled(false);
|
||||
|
||||
// 初始化数据保存路径显示(从 AppSettings 恢复或使用默认)
|
||||
ui.dataFolderLineEdit->setText(AppSettings::instance().slrDataFolder());
|
||||
}
|
||||
|
||||
SingleLensReflexCameraWindow::~SingleLensReflexCameraWindow()
|
||||
{
|
||||
// 先停止拍照
|
||||
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||
{
|
||||
m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||
}
|
||||
|
||||
m_SLRCameraThread->quit();
|
||||
m_SLRCameraThread->wait();
|
||||
delete m_SingleLensReflexCameraOperation;
|
||||
m_SingleLensReflexCameraOperation = nullptr;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onSelectDataFolder()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
QString::fromLocal8Bit("选择数据保存路径"),
|
||||
ui.dataFolderLineEdit->text());
|
||||
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
ui.dataFolderLineEdit->setText(dir);
|
||||
|
||||
m_SingleLensReflexCameraOperation->setSavePath(dir);
|
||||
|
||||
// 保存路径到 AppSettings
|
||||
AppSettings::instance().setSlrDataFolder(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::openSLRCamera()
|
||||
{
|
||||
if (!m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||
@ -38,46 +100,707 @@ void SingleLensReflexCameraWindow::openSLRCamera()
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::takePhoto()
|
||||
{
|
||||
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||
{
|
||||
emit takePhotoSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::stopTakePhoto()
|
||||
{
|
||||
if (m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||
{
|
||||
emit stopTakePhotoSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onCamOpened()
|
||||
{
|
||||
ui.openSLRCamera_btn->setEnabled(false);
|
||||
ui.closeSLRCamera_btn->setEnabled(true);
|
||||
|
||||
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::closeSLRCamera()
|
||||
{
|
||||
m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||
emit closeSLRCameraSignal();
|
||||
//m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onCamClosed()
|
||||
{
|
||||
ui.openSLRCamera_btn->setEnabled(true);
|
||||
ui.closeSLRCamera_btn->setEnabled(false);
|
||||
|
||||
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("打 开"));
|
||||
m_isCapturing = false;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onCaptureStarted()
|
||||
{
|
||||
ui.takePhoto_btn->setEnabled(false);
|
||||
ui.stopTakePhoto_btn->setEnabled(true);
|
||||
|
||||
m_btnOldText = ui.takePhoto_btn->text();
|
||||
ui.takePhoto_btn->setText(QString::fromLocal8Bit("采集中"));
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onCaptureStopped()
|
||||
{
|
||||
ui.takePhoto_btn->setEnabled(true);
|
||||
ui.stopTakePhoto_btn->setEnabled(false);
|
||||
ui.takePhoto_btn->setText(m_btnOldText);
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onImageCaptured(const QString& filePath)
|
||||
{
|
||||
std::cout << "Image captured: " << filePath.toStdString() << std::endl;
|
||||
// 可以在这里更新UI显示最新拍摄的图片
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onError(const QString& errorMsg)
|
||||
{
|
||||
QMessageBox::warning(this, QString::fromLocal8Bit("相机错误"), errorMsg);
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onStartCapture()
|
||||
{
|
||||
if (!m_isCapturing)
|
||||
{
|
||||
m_isCapturing = true;
|
||||
emit startCaptureSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onStopCapture()
|
||||
{
|
||||
if (m_isCapturing)
|
||||
{
|
||||
m_isCapturing = false;
|
||||
emit stopCaptureSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onCaptureOnce()
|
||||
{
|
||||
emit captureOnceSignal();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------
|
||||
// SingleLensReflexCameraOperation 实现
|
||||
//-------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
SingleLensReflexCameraOperation::SingleLensReflexCameraOperation()
|
||||
{
|
||||
m_func = nullptr;
|
||||
record = false;
|
||||
m_isRecord = false;
|
||||
m_camera = nullptr;
|
||||
m_isSDKInitialized = false;
|
||||
m_isSessionOpen = false;
|
||||
m_isLiveViewActive = false;
|
||||
m_imageCounter = 0;
|
||||
|
||||
// 设置保存路径(从 AppSettings 获取,如果为空则使用默认的 CapturedImages 目录)
|
||||
m_savePath = AppSettings::instance().slrDataFolder();
|
||||
|
||||
// 创建保存目录
|
||||
QDir dir;
|
||||
if (!dir.exists(m_savePath))
|
||||
{
|
||||
dir.mkpath(m_savePath);
|
||||
}
|
||||
|
||||
// 创建定时器
|
||||
m_captureTimer = new QTimer(this);
|
||||
connect(m_captureTimer, &QTimer::timeout, this, &SingleLensReflexCameraOperation::onCaptureTimer);
|
||||
|
||||
m_liveViewTimer = new QTimer(this);
|
||||
connect(m_liveViewTimer, &QTimer::timeout, this, &SingleLensReflexCameraOperation::onLiveViewTimer);
|
||||
|
||||
g_cameraOperation = this;
|
||||
}
|
||||
|
||||
SingleLensReflexCameraOperation::~SingleLensReflexCameraOperation()
|
||||
{
|
||||
if (m_isRecord)
|
||||
{
|
||||
CloseSLRCamera();
|
||||
}
|
||||
g_cameraOperation = nullptr;
|
||||
|
||||
// 销毁定时器
|
||||
if (m_captureTimer)
|
||||
{
|
||||
m_captureTimer->stop();
|
||||
m_captureTimer->deleteLater();
|
||||
m_captureTimer = nullptr;
|
||||
}
|
||||
if (m_liveViewTimer)
|
||||
{
|
||||
m_liveViewTimer->stop();
|
||||
m_liveViewTimer->deleteLater();
|
||||
m_liveViewTimer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::setSavePath(const QString& path)
|
||||
{
|
||||
m_savePath = path;
|
||||
if (!m_savePath.endsWith('/') && !m_savePath.endsWith('\\'))
|
||||
{
|
||||
m_savePath += '/';
|
||||
}
|
||||
|
||||
QDir dir;
|
||||
if (!dir.exists(m_savePath))
|
||||
{
|
||||
dir.mkpath(m_savePath);
|
||||
}
|
||||
}
|
||||
|
||||
QImage SingleLensReflexCameraOperation::getCurrentLiveViewImage()
|
||||
{
|
||||
QMutexLocker locker(&m_liveViewMutex);
|
||||
return m_liveViewImage.copy();
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::initializeSDK()
|
||||
{
|
||||
EdsError err = EdsInitializeSDK();
|
||||
if (err == EDS_ERR_OK)
|
||||
{
|
||||
m_isSDKInitialized = true;
|
||||
std::cout << "EDSDK initialized successfully" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Failed to initialize EDSDK, error: " << err << std::endl;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::terminateSDK()
|
||||
{
|
||||
if (m_isSDKInitialized)
|
||||
{
|
||||
EdsError err = EdsTerminateSDK();
|
||||
m_isSDKInitialized = false;
|
||||
std::cout << "EDSDK terminated" << std::endl;
|
||||
return err;
|
||||
}
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::openCamera()
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
EdsCameraListRef cameraList = nullptr;
|
||||
EdsUInt32 count = 0;
|
||||
|
||||
// 获取相机列表
|
||||
err = EdsGetCameraList(&cameraList);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to get camera list, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
// 获取相机数量
|
||||
err = EdsGetChildCount(cameraList, &count);
|
||||
if (err != EDS_ERR_OK || count == 0)
|
||||
{
|
||||
std::cout << "No camera found" << std::endl;
|
||||
EdsRelease(cameraList);
|
||||
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
std::cout << "Found " << count << " camera(s)" << std::endl;
|
||||
|
||||
// 获取第一台相机
|
||||
err = EdsGetChildAtIndex(cameraList, 0, &m_camera);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to get camera, error: " << err << std::endl;
|
||||
EdsRelease(cameraList);
|
||||
return err;
|
||||
}
|
||||
|
||||
// 释放相机列表
|
||||
EdsRelease(cameraList);
|
||||
|
||||
// 设置事件回调
|
||||
err = EdsSetObjectEventHandler(m_camera, kEdsObjectEvent_All, handleObjectEvent, this);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to set object event handler, error: " << err << std::endl;
|
||||
}
|
||||
|
||||
err = EdsSetPropertyEventHandler(m_camera, kEdsPropertyEvent_All, handlePropertyEvent, this);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to set property event handler, error: " << err << std::endl;
|
||||
}
|
||||
|
||||
err = EdsSetCameraStateEventHandler(m_camera, kEdsStateEvent_All, handleStateEvent, this);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to set state event handler, error: " << err << std::endl;
|
||||
}
|
||||
|
||||
// 打开会话
|
||||
err = EdsOpenSession(m_camera);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to open session, error: " << err << std::endl;
|
||||
EdsRelease(m_camera);
|
||||
m_camera = nullptr;
|
||||
return err;
|
||||
}
|
||||
|
||||
m_isSessionOpen = true;
|
||||
std::cout << "Camera session opened successfully" << std::endl;
|
||||
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::closeCamera()
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
|
||||
if (m_isSessionOpen && m_camera != nullptr)
|
||||
{
|
||||
err = EdsCloseSession(m_camera);
|
||||
m_isSessionOpen = false;
|
||||
std::cout << "Camera session closed" << std::endl;
|
||||
}
|
||||
|
||||
if (m_camera != nullptr)
|
||||
{
|
||||
EdsRelease(m_camera);
|
||||
m_camera = nullptr;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::setupSaveToHost()
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
|
||||
// 设置保存到PC
|
||||
EdsUInt32 saveTo = kEdsSaveTo_Host;
|
||||
err = EdsSetPropertyData(m_camera, kEdsPropID_SaveTo, 0, sizeof(saveTo), &saveTo);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to set SaveTo property, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
// 设置PC容量(告诉相机PC有足够空间)
|
||||
EdsCapacity capacity;
|
||||
capacity.numberOfFreeClusters = 0x7FFFFFFF;
|
||||
capacity.bytesPerSector = 0x1000;
|
||||
capacity.reset = true;
|
||||
err = EdsSetCapacity(m_camera, capacity);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to set capacity, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
std::cout << "Save to host configured successfully" << std::endl;
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::startLiveView()
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
|
||||
if (m_camera == nullptr || !m_isSessionOpen)
|
||||
{
|
||||
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
// 获取当前输出设备设置
|
||||
EdsUInt32 device = 0;
|
||||
err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to get Evf_OutputDevice, error: " << err << std::endl;
|
||||
// 某些相机可能不支持获取,继续尝试设置
|
||||
}
|
||||
|
||||
// 设置PC为实时取景输出设备
|
||||
device |= kEdsEvfOutputDevice_PC;
|
||||
err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to set Evf_OutputDevice, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
m_isLiveViewActive = true;
|
||||
std::cout << "Live view started" << std::endl;
|
||||
|
||||
emit LiveViewStarted();
|
||||
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::stopLiveView()
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
|
||||
if (m_camera == nullptr || !m_isSessionOpen)
|
||||
{
|
||||
m_isLiveViewActive = false;
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
// 获取当前输出设备设置
|
||||
EdsUInt32 device = 0;
|
||||
err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to get Evf_OutputDevice, error: " << err << std::endl;
|
||||
}
|
||||
|
||||
// 从输出设备中移除PC
|
||||
device &= ~kEdsEvfOutputDevice_PC;
|
||||
err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to clear Evf_OutputDevice, error: " << err << std::endl;
|
||||
}
|
||||
|
||||
m_isLiveViewActive = false;
|
||||
std::cout << "Live view stopped" << std::endl;
|
||||
|
||||
emit LiveViewStopped();
|
||||
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::downloadEvfImage()
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
EdsStreamRef stream = nullptr;
|
||||
EdsEvfImageRef evfImage = nullptr;
|
||||
|
||||
if (m_camera == nullptr || !m_isLiveViewActive)
|
||||
{
|
||||
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
// 创建内存流
|
||||
err = EdsCreateMemoryStream(0, &stream);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to create memory stream, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
// 创建实时取景图像引用
|
||||
err = EdsCreateEvfImageRef(stream, &evfImage);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to create evf image ref, error: " << err << std::endl;
|
||||
EdsRelease(stream);
|
||||
return err;
|
||||
}
|
||||
|
||||
// 下载实时取景图像
|
||||
err = EdsDownloadEvfImage(m_camera, evfImage);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
// EDS_ERR_OBJECT_NOTREADY 是正常的,表示图像还没准备好
|
||||
if (err != EDS_ERR_OBJECT_NOTREADY)
|
||||
{
|
||||
std::cout << "Failed to download evf image, error: " << err << std::endl;
|
||||
}
|
||||
EdsRelease(evfImage);
|
||||
EdsRelease(stream);
|
||||
return err;
|
||||
}
|
||||
|
||||
// 获取流数据
|
||||
EdsVoid* pData = nullptr;
|
||||
EdsUInt64 length = 0;
|
||||
|
||||
err = EdsGetPointer(stream, &pData);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
EdsRelease(evfImage);
|
||||
EdsRelease(stream);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = EdsGetLength(stream, &length);
|
||||
if (err != EDS_ERR_OK || length == 0)
|
||||
{
|
||||
EdsRelease(evfImage);
|
||||
EdsRelease(stream);
|
||||
return err;
|
||||
}
|
||||
|
||||
// 将JPEG数据转换为QImage
|
||||
QImage image;
|
||||
if (image.loadFromData(static_cast<const uchar*>(pData), static_cast<int>(length), "JPEG"))
|
||||
{
|
||||
QMutexLocker locker(&m_liveViewMutex);
|
||||
m_liveViewImage = image.copy();
|
||||
locker.unlock();
|
||||
|
||||
// 发送信号通知图像已准备好
|
||||
emit LiveViewImageReady(image);
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
EdsRelease(evfImage);
|
||||
EdsRelease(stream);
|
||||
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::takePicture()
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
|
||||
if (m_camera == nullptr || !m_isSessionOpen)
|
||||
{
|
||||
return EDS_ERR_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
// 按下快门
|
||||
err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton, kEdsCameraCommand_ShutterButton_Completely);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to press shutter button, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
// 释放快门
|
||||
err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton, kEdsCameraCommand_ShutterButton_OFF);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to release shutter button, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
std::cout << "Picture taken" << std::endl;
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError SingleLensReflexCameraOperation::downloadImage(EdsDirectoryItemRef directoryItem)
|
||||
{
|
||||
EdsError err = EDS_ERR_OK;
|
||||
EdsStreamRef stream = nullptr;
|
||||
EdsDirectoryItemInfo dirItemInfo;
|
||||
|
||||
// 获取文件信息
|
||||
err = EdsGetDirectoryItemInfo(directoryItem, &dirItemInfo);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to get directory item info, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
// 生成保存文件名(使用时间戳)
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss_zzz");
|
||||
QString fileName = m_savePath + QDir::separator() + "IMG_" + timestamp + "_" + QString::fromLocal8Bit(dirItemInfo.szFileName);
|
||||
|
||||
std::cout << "Downloading image to: " << fileName.toStdString() << std::endl;
|
||||
|
||||
// 创建文件流
|
||||
err = EdsCreateFileStream(fileName.toLocal8Bit().constData(),
|
||||
kEdsFileCreateDisposition_CreateAlways,
|
||||
kEdsAccess_ReadWrite, &stream);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to create file stream, error: " << err << std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
// 下载图像
|
||||
err = EdsDownload(directoryItem, dirItemInfo.size, stream);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to download image, error: " << err << std::endl;
|
||||
EdsRelease(stream);
|
||||
return err;
|
||||
}
|
||||
|
||||
// 通知下载完成
|
||||
err = EdsDownloadComplete(directoryItem);
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to complete download, error: " << err << std::endl;
|
||||
}
|
||||
|
||||
// 释放流
|
||||
EdsRelease(stream);
|
||||
|
||||
std::cout << "Image downloaded successfully: " << fileName.toStdString() << std::endl;
|
||||
|
||||
// 发送信号通知图片已保存
|
||||
emit ImageCapturedSignal(fileName);
|
||||
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
// 静态回调函数实现
|
||||
EdsError EDSCALLBACK SingleLensReflexCameraOperation::handleObjectEvent(EdsObjectEvent event, EdsBaseRef object, EdsVoid* context)
|
||||
{
|
||||
SingleLensReflexCameraOperation* pThis = static_cast<SingleLensReflexCameraOperation*>(context);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case kEdsObjectEvent_DirItemRequestTransfer:
|
||||
// 有图像需要传输
|
||||
if (pThis != nullptr)
|
||||
{
|
||||
pThis->downloadImage(object);
|
||||
}
|
||||
break;
|
||||
|
||||
case kEdsObjectEvent_DirItemCreated:
|
||||
std::cout << "New file created on camera" << std::endl;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 释放对象
|
||||
if (object)
|
||||
{
|
||||
EdsRelease(object);
|
||||
}
|
||||
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError EDSCALLBACK SingleLensReflexCameraOperation::handlePropertyEvent(EdsPropertyEvent event, EdsPropertyID property, EdsUInt32 param, EdsVoid* context)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case kEdsPropertyEvent_PropertyChanged:
|
||||
// 属性已更改
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
EdsError EDSCALLBACK SingleLensReflexCameraOperation::handleStateEvent(EdsStateEvent event, EdsUInt32 parameter, EdsVoid* context)
|
||||
{
|
||||
SingleLensReflexCameraOperation* pThis = static_cast<SingleLensReflexCameraOperation*>(context);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case kEdsStateEvent_Shutdown:
|
||||
std::cout << "Camera disconnected" << std::endl;
|
||||
if (pThis != nullptr && pThis->m_isRecord)
|
||||
{
|
||||
pThis->CloseSLRCamera();
|
||||
}
|
||||
break;
|
||||
|
||||
case kEdsStateEvent_WillSoonShutDown:
|
||||
// 相机即将自动关机,延长计时器
|
||||
if (pThis != nullptr && pThis->m_camera != nullptr)
|
||||
{
|
||||
EdsSendCommand(pThis->m_camera, kEdsCameraCommand_ExtendShutDownTimer, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return EDS_ERR_OK;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::OpenSLRCamera()
|
||||
{
|
||||
std::cout << "SingleLensReflexCameraOperation::OpenSLRCamera, 打开单反相机" << std::endl;
|
||||
|
||||
EdsError err = EDS_ERR_OK;
|
||||
|
||||
// 初始化SDK
|
||||
err = initializeSDK();
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
emit ErrorSignal(QString::fromLocal8Bit("初始化SDK失败,错误码: %1").arg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
// 打开相机
|
||||
err = openCamera();
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
terminateSDK();
|
||||
emit ErrorSignal(QString::fromLocal8Bit("打开相机失败,错误码: %1").arg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置保存到PC
|
||||
err = setupSaveToHost();
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
closeCamera();
|
||||
terminateSDK();
|
||||
emit ErrorSignal(QString::fromLocal8Bit("设置保存位置失败,错误码: %1").arg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
// 启动实时取景
|
||||
err = startLiveView();
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Warning: Failed to start live view, error: " << err << std::endl;
|
||||
// 实时取景启动失败不是致命错误,继续执行
|
||||
}
|
||||
|
||||
m_isRecord = true;
|
||||
|
||||
// 启动实时取景定时器(约30fps)
|
||||
if (m_liveViewTimer && !m_liveViewTimer->isActive()) {
|
||||
m_liveViewTimer->start(33); // 约30fps
|
||||
}
|
||||
|
||||
emit CamOpenedSignal();
|
||||
|
||||
std::cout << "Camera opened, live view started." << std::endl;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::takePhoto()
|
||||
{
|
||||
// 启动拍照定时器(每3秒拍一张)
|
||||
if (m_captureTimer && !m_captureTimer->isActive())
|
||||
{
|
||||
m_captureTimer->start(3000);
|
||||
std::cout << "capture timer started (1 photo 3 second)" << std::endl;
|
||||
|
||||
emit CaptureStartedSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::stopTakePhoto()
|
||||
{
|
||||
if (m_captureTimer && m_captureTimer->isActive())
|
||||
{
|
||||
m_captureTimer->stop();
|
||||
std::cout << "capture timer stopped" << std::endl;
|
||||
|
||||
emit CaptureStoppedSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::OpenSLRCamera_callback()
|
||||
{
|
||||
|
||||
// 不使用信号而使用回调函数来通知界面刷新视频
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::setCallback(void(*func)())
|
||||
@ -85,11 +808,111 @@ void SingleLensReflexCameraOperation::setCallback(void(*func)())
|
||||
m_func = func;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::onLiveViewTimer()
|
||||
{
|
||||
if (!m_isRecord || !m_isLiveViewActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理相机事件
|
||||
EdsGetEvent();
|
||||
|
||||
// 下载实时取景图像
|
||||
downloadEvfImage();
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::onCaptureTimer()
|
||||
{
|
||||
if (!m_isRecord)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
// 拍照
|
||||
EdsError err = takePicture();
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
std::cout << "Failed to take picture, error: " << err << std::endl;
|
||||
// 如果是设备忙,不发送错误信号,等待下次重试
|
||||
if (err != EDS_ERR_DEVICE_BUSY)
|
||||
{
|
||||
emit ErrorSignal(QString::fromLocal8Bit("拍照失败,错误码: %1").arg(err));
|
||||
}
|
||||
}
|
||||
|
||||
m_imageCounter++;
|
||||
std::cout << "Total pictures taken: " << m_imageCounter << std::endl;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::startCapture()
|
||||
{
|
||||
if (m_captureTimer && !m_captureTimer->isActive())
|
||||
{
|
||||
m_captureTimer->start(1000);
|
||||
std::cout << "Capture timer started" << std::endl;
|
||||
emit CaptureStartedSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::stopCapture()
|
||||
{
|
||||
if (m_captureTimer && m_captureTimer->isActive())
|
||||
{
|
||||
m_captureTimer->stop();
|
||||
std::cout << "Capture timer stopped" << std::endl;
|
||||
emit CaptureStoppedSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::captureOnce()
|
||||
{
|
||||
if (m_isRecord)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
takePicture();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::CloseSLRCamera()
|
||||
{
|
||||
std::cout << "SingleLensReflexCameraOperation::CloseSLRCamera,关闭单反相机" << std::endl;
|
||||
|
||||
record = false;
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
m_isRecord = false;
|
||||
|
||||
// 停止定时器
|
||||
if (m_captureTimer != nullptr)
|
||||
{
|
||||
m_captureTimer->stop();
|
||||
}
|
||||
|
||||
if (m_liveViewTimer != nullptr)
|
||||
{
|
||||
m_liveViewTimer->stop();
|
||||
}
|
||||
|
||||
// 停止实时取景
|
||||
stopLiveView();
|
||||
|
||||
// 处理剩余事件
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
EdsGetEvent();
|
||||
QThread::msleep(100);
|
||||
}
|
||||
|
||||
// 关闭相机
|
||||
closeCamera();
|
||||
|
||||
// 终止SDK
|
||||
terminateSDK();
|
||||
|
||||
std::cout << "Camera closed, total pictures: " << m_imageCounter << std::endl;
|
||||
m_imageCounter = 0;
|
||||
|
||||
emit CamClosedSignal();
|
||||
}
|
||||
|
||||
@ -5,8 +5,13 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QImage>
|
||||
#include <Qthread>
|
||||
#include <QThread>
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
#include <QDateTime>
|
||||
#include <QLabel>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <iostream>
|
||||
#include "ui_SingleLensReflexCamera.h"
|
||||
@ -14,63 +19,160 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
// 包含Canon EDSDK头文件
|
||||
#include "EDSDK.h"
|
||||
#include "EDSDKTypes.h"
|
||||
#include "EDSDKErrors.h"
|
||||
|
||||
typedef void(*func)();
|
||||
|
||||
class SingleLensReflexCameraOperation :public QObject
|
||||
class SingleLensReflexCameraOperation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SingleLensReflexCameraOperation();
|
||||
~SingleLensReflexCameraOperation();
|
||||
SingleLensReflexCameraOperation();
|
||||
~SingleLensReflexCameraOperation();
|
||||
|
||||
QImage m_colorImage;
|
||||
QImage m_depthImage;
|
||||
void setCallback(void(*func)());
|
||||
bool getRecordStatus() const { return record; }
|
||||
QImage m_colorImage;
|
||||
QImage m_depthImage;
|
||||
void setCallback(void(*func)());
|
||||
bool getRecordStatus() const { return m_isRecord; }
|
||||
|
||||
// 设置保存路径
|
||||
void setSavePath(const QString& path);
|
||||
|
||||
// 获取当前实时取景图像
|
||||
QImage getCurrentLiveViewImage();
|
||||
|
||||
private:
|
||||
cv::Mat frame;
|
||||
cv::Mat frame;
|
||||
func m_func;
|
||||
bool m_isRecord;
|
||||
|
||||
func m_func;
|
||||
// Canon EDSDK相关成员
|
||||
EdsCameraRef m_camera;
|
||||
bool m_isSDKInitialized;
|
||||
bool m_isSessionOpen;
|
||||
bool m_isLiveViewActive;
|
||||
|
||||
bool record;
|
||||
QTimer* m_captureTimer; // 拍照定时器
|
||||
QTimer* m_liveViewTimer; // 实时取景定时器
|
||||
|
||||
QString m_savePath;
|
||||
int m_imageCounter;
|
||||
QMutex m_mutex;
|
||||
QMutex m_liveViewMutex;
|
||||
|
||||
QImage m_liveViewImage; // 当前实时取景图像
|
||||
|
||||
// EDSDK辅助函数
|
||||
EdsError initializeSDK();
|
||||
EdsError terminateSDK();
|
||||
EdsError openCamera();
|
||||
EdsError closeCamera();
|
||||
EdsError takePicture();
|
||||
EdsError setupSaveToHost();
|
||||
|
||||
// 实时取景相关函数
|
||||
EdsError startLiveView();
|
||||
EdsError stopLiveView();
|
||||
EdsError downloadEvfImage();
|
||||
|
||||
// 静态回调函数
|
||||
static EdsError EDSCALLBACK handleObjectEvent(EdsObjectEvent event, EdsBaseRef object, EdsVoid* context);
|
||||
static EdsError EDSCALLBACK handlePropertyEvent(EdsPropertyEvent event, EdsPropertyID property, EdsUInt32 param, EdsVoid* context);
|
||||
static EdsError EDSCALLBACK handleStateEvent(EdsStateEvent event, EdsUInt32 parameter, EdsVoid* context);
|
||||
|
||||
// 下载图像
|
||||
EdsError downloadImage(EdsDirectoryItemRef directoryItem);
|
||||
|
||||
public slots:
|
||||
void OpenSLRCamera();
|
||||
void OpenSLRCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
||||
void CloseSLRCamera();
|
||||
void OpenSLRCamera();
|
||||
void takePhoto();
|
||||
void stopTakePhoto();
|
||||
void OpenSLRCamera_callback();
|
||||
void CloseSLRCamera();
|
||||
void onCaptureTimer();
|
||||
void onLiveViewTimer();
|
||||
|
||||
// 控制拍照
|
||||
void startCapture(); // 开始定时拍照
|
||||
void stopCapture(); // 停止定时拍照
|
||||
void captureOnce(); // 拍一张照片
|
||||
|
||||
signals:
|
||||
void PlotSignal();
|
||||
void PlotSignal();
|
||||
void CamOpenedSignal();
|
||||
void CamClosedSignal();
|
||||
void ImageCapturedSignal(const QString& filePath);
|
||||
void ErrorSignal(const QString& errorMsg);
|
||||
|
||||
void CamOpenedSignal();
|
||||
void CamClosedSignal();
|
||||
// 实时取景信号
|
||||
void LiveViewImageReady(const QImage& image);
|
||||
void LiveViewStarted();
|
||||
void LiveViewStopped();
|
||||
|
||||
void CaptureStartedSignal();
|
||||
void CaptureStoppedSignal();
|
||||
};
|
||||
|
||||
class SingleLensReflexCameraWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SingleLensReflexCameraWindow(QWidget* parent = nullptr);
|
||||
~SingleLensReflexCameraWindow();
|
||||
SingleLensReflexCameraWindow(QWidget* parent = nullptr);
|
||||
~SingleLensReflexCameraWindow();
|
||||
|
||||
SingleLensReflexCameraOperation* m_SingleLensReflexCameraOperation;
|
||||
SingleLensReflexCameraOperation* m_SingleLensReflexCameraOperation;
|
||||
|
||||
public Q_SLOTS:
|
||||
void openSLRCamera();
|
||||
void onCamOpened();
|
||||
void closeSLRCamera();
|
||||
void onCamClosed();
|
||||
void onSelectDataFolder();
|
||||
|
||||
void openSLRCamera();
|
||||
void takePhoto();
|
||||
void stopTakePhoto();
|
||||
void onCamOpened();
|
||||
void closeSLRCamera();
|
||||
void onCamClosed();
|
||||
void onImageCaptured(const QString& filePath);
|
||||
void onError(const QString& errorMsg);
|
||||
|
||||
// 拍照控制
|
||||
void onStartCapture();
|
||||
void onStopCapture();
|
||||
void onCaptureOnce();
|
||||
|
||||
void onCaptureStarted();
|
||||
void onCaptureStopped();
|
||||
|
||||
signals:
|
||||
void openSLRCameraSignal();
|
||||
void PlotSLRImageSignal();
|
||||
void SLRCamClosedSignal();
|
||||
void openSLRCameraSignal();
|
||||
void takePhotoSignal();
|
||||
void stopTakePhotoSignal();
|
||||
void closeSLRCameraSignal();
|
||||
void PlotSLRImageSignal();
|
||||
void SLRCamClosedSignal();
|
||||
|
||||
// 控制信号
|
||||
void startCaptureSignal();
|
||||
void stopCaptureSignal();
|
||||
void captureOnceSignal();
|
||||
|
||||
// 实时取景信号
|
||||
void LiveViewImageReady(const QImage& image);
|
||||
void LiveViewStarted();
|
||||
void LiveViewStopped();
|
||||
private:
|
||||
Ui::SingleLensReflexCameraClass ui;
|
||||
QThread* m_SLRCameraThread;
|
||||
Ui::SingleLensReflexCameraClass ui;
|
||||
QThread* m_SLRCameraThread;
|
||||
|
||||
// 用于显示实时取景的标签(如果UI中没有,可以动态创建)
|
||||
QLabel* m_liveViewLabel;
|
||||
|
||||
QString m_btnOldText; // 存储拍照按钮的原始文本
|
||||
|
||||
bool m_isCapturing; // 是否正在定时拍照
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "recordFrameCounter.h"
|
||||
#include "RasterLayer.h"
|
||||
|
||||
recordFrameCounter::recordFrameCounter(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@ -16,19 +17,19 @@ recordFrameCounter::recordFrameCounter(QWidget* parent)
|
||||
layout->addWidget(m_stackedWidget);
|
||||
}
|
||||
|
||||
void recordFrameCounter::addCounter(QWidget* tabWidget)
|
||||
void recordFrameCounter::addCounter(RasterLayer* mapLayer)
|
||||
{
|
||||
QLabel* label = new QLabel("0");
|
||||
label->setStyleSheet("color: white;");
|
||||
label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
m_labelMap.insert(tabWidget, label);
|
||||
m_labelMap.insert(mapLayer, label);
|
||||
m_stackedWidget->addWidget(label);
|
||||
m_stackedWidget->setCurrentWidget(label);
|
||||
}
|
||||
|
||||
void recordFrameCounter::removeCounter(QWidget* tabWidget)
|
||||
void recordFrameCounter::removeCounter(RasterLayer* mapLayer)
|
||||
{
|
||||
auto it = m_labelMap.find(tabWidget);
|
||||
auto it = m_labelMap.find(mapLayer);
|
||||
if (it != m_labelMap.end())
|
||||
{
|
||||
QLabel* label = it.value();
|
||||
@ -38,18 +39,18 @@ void recordFrameCounter::removeCounter(QWidget* tabWidget)
|
||||
}
|
||||
}
|
||||
|
||||
void recordFrameCounter::switchTo(QWidget* tabWidget)
|
||||
void recordFrameCounter::switchTo(RasterLayer* mapLayer)
|
||||
{
|
||||
auto it = m_labelMap.find(tabWidget);
|
||||
auto it = m_labelMap.find(mapLayer);
|
||||
if (it != m_labelMap.end())
|
||||
{
|
||||
m_stackedWidget->setCurrentWidget(it.value());
|
||||
}
|
||||
}
|
||||
|
||||
void recordFrameCounter::updateFrameCount(QWidget* tabWidget, int frameCount)
|
||||
void recordFrameCounter::updateFrameCount(RasterLayer* mapLayer, int frameCount)
|
||||
{
|
||||
auto it = m_labelMap.find(tabWidget);
|
||||
auto it = m_labelMap.find(mapLayer);
|
||||
if (it != m_labelMap.end())
|
||||
{
|
||||
it.value()->setText(QString::number(frameCount));
|
||||
|
||||
@ -6,19 +6,20 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QMap>
|
||||
|
||||
class RasterLayer;
|
||||
|
||||
class recordFrameCounter : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit recordFrameCounter(QWidget* parent = nullptr);
|
||||
|
||||
void addCounter(QWidget* tabWidget);
|
||||
void removeCounter(QWidget* tabWidget);
|
||||
void switchTo(QWidget* tabWidget);
|
||||
void updateFrameCount(QWidget* tabWidget, int frameCount);
|
||||
void addCounter(RasterLayer* mapLayer);
|
||||
void removeCounter(RasterLayer* mapLayer);
|
||||
void switchTo(RasterLayer* mapLayer);
|
||||
void updateFrameCount(RasterLayer* mapLayer, int frameCount);
|
||||
|
||||
private:
|
||||
QStackedWidget* m_stackedWidget = nullptr;
|
||||
QMap<QWidget*, QLabel*> m_labelMap;
|
||||
QMap<RasterLayer*, QLabel*> m_labelMap;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user