5 Commits
3.0.1 ... 3.0.2

Author SHA1 Message Date
e43d60e264 add:
1、增加显微镜场景:添加显微镜3D模型;
2、设置界面添加确认按钮;

fix:
1、相机看板:(1)帧率*积分时间=999,防止nir崩溃(2)记录帧率和积分时间,下次打开软件后恢复;(3)只能拖动slider改变值,不能点击slider改变值;
2、加入判断,不能多次打开同一个影像;
3、图像控制看板:只能拖动slider改变值,不能点击slider改变值;
2026-04-16 16:43:28 +08:00
24d34f39be 添加单反相机控制看板 2026-04-14 16:57:11 +08:00
d326dabff7 add,深度相机:
1、采集惯导数据并写入文件;
2、轮播看板添加深度图像;
3、植物表型场景控制深度相机看板;

fix:
优化调焦时,图像像素的填充方式;
2026-04-14 13:14:55 +08:00
5009832b3a add
1、采集深度、彩色、rgb点云,并存储到文件;
2、界面操作逻辑控制,防止用户错误操作;
2026-04-09 16:29:12 +08:00
5350d9431a add
添加深度相机1:控制看板界面
2026-04-08 17:04:51 +08:00
30 changed files with 1258 additions and 61 deletions

View File

@ -2,6 +2,9 @@
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;
AppSettings::AppSettings()
: m_settings(QSettings::IniFormat, QSettings::UserScope,
@ -33,3 +36,30 @@ void AppSettings::setFileName(const QString& path)
{
m_settings.setValue("General/FileName", path);
}
int AppSettings::frameRate() const
{
return m_settings.value("CameraParams/FrameRate", kDefaultFrameRate).toInt();
}
void AppSettings::setFrameRate(int value)
{
m_settings.setValue("CameraParams/FrameRate", value);
}
int AppSettings::integrationTime() const
{
return m_settings.value("CameraParams/IntegrationTime", kDefaultIntegrationTime).toInt();
}
void AppSettings::setIntegrationTime(int value)
{
m_settings.setValue("CameraParams/IntegrationTime", value);
}
int AppSettings::gain() const
{
return m_settings.value("CameraParams/Gain", kDefaultGain).toInt();
}
void AppSettings::setGain(int value)
{
m_settings.setValue("CameraParams/Gain", value);
}

View File

@ -14,6 +14,18 @@ public:
QString fileName() const;
void setFileName(const QString& path);
// 帧率
int frameRate() const;
void setFrameRate(int value);
// 积分时间
int integrationTime() const;
void setIntegrationTime(int value);
// 增益
int gain() const;
void setGain(int value);
// 在此处添加更多参数的 getter/setter ...
private:
@ -26,4 +38,7 @@ private:
// 默认值
static const QString kDefaultDataFolder;
static const QString kDefaultFileName;
static const int kDefaultFrameRate;
static const int kDefaultIntegrationTime;
static const int kDefaultGain;
};

160
HPPA/DepthCamera.ui Normal file
View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DepthCameraClass</class>
<widget class="QDialog" name="DepthCameraClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<height>219</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>DepthCamera</string>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox
{
border: 12px solid transparent;
/*border-top: 12px solid transparent;
border-right: 0px solid transparent;
border-bottom: 0px solid transparent;
border-left: 0px solid transparent;*/
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 19pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>100</height>
</size>
</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">
<widget class="QPushButton" name="closeDepthCamera_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">
<widget class="QPushButton" name="openDepthCamera_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">
<spacer name="horizontalSpacer_2">
<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="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>100</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

323
HPPA/DepthCameraWindow.cpp Normal file
View File

@ -0,0 +1,323 @@
#include "DepthCameraWindow.h"
DepthCameraWindow::DepthCameraWindow(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
m_DepthCameraThread = new QThread();
m_DepthCameraOperation = new DepthCameraOperation();
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(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::PlotSignal, this, &DepthCameraWindow::PlotDepthImageSignal);
connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::DepthCamClosedSignal);
}
DepthCameraWindow::~DepthCameraWindow()
{
m_DepthCameraThread->quit();
m_DepthCameraThread->wait();
delete m_DepthCameraOperation;
m_DepthCameraOperation = nullptr;
}
void DepthCameraWindow::openDepthCamera()
{
if (!m_DepthCameraOperation->getRecordStatus())
{
emit openDepthCameraSignal();
}
}
void DepthCameraWindow::onCamOpened()
{
ui.openDepthCamera_btn->setEnabled(false);
ui.closeDepthCamera_btn->setEnabled(true);
ui.openDepthCamera_btn->setText(QString::fromLocal8Bit("已打开"));
}
void DepthCameraWindow::closeDepthCamera()
{
m_DepthCameraOperation->CloseDepthCamera();
}
void DepthCameraWindow::onCamClosed()
{
ui.openDepthCamera_btn->setEnabled(true);
ui.closeDepthCamera_btn->setEnabled(false);
ui.openDepthCamera_btn->setText(QString::fromLocal8Bit("打 开"));
}
//-------------------------------------------------------------------------------------------------------------------------------
DepthCameraOperation::DepthCameraOperation()
{
m_pipe = nullptr;
m_func = nullptr;
record = false;
}
DepthCameraOperation::~DepthCameraOperation()
{
if (m_pipe)
{
m_pipe->stop();
delete m_pipe;
m_pipe = nullptr;
}
}
void DepthCameraOperation::OpenDepthCamera()
{
if (m_pipe)
{
return;
}
m_pipe = new ob::Pipeline();
std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
// Get device from pipeline.
auto device = m_pipe->getDevice();
auto devInfo = device->getDeviceInfo();
auto pid = devInfo->getPid();
auto vid = devInfo->getVid();
//// Get sensorList from device.
//auto sensorList = device->getSensorList();
//for (uint32_t index = 0; index < sensorList->getCount(); index++) {
// // Query all supported infrared sensor type and enable the infrared stream.
// // For dual infrared device, enable the left and right infrared streams.
// // For single infrared device, enable the infrared stream.
// OBSensorType sensorType = sensorList->getSensorType(index);
// std::cout << "Supported Sensor type: " << sensorType << std::endl;
// // Enable the stream for the sensor type.
// config->enableStream(sensorType);
//}
config->enableVideoStream(OB_STREAM_DEPTH, 640, 480, 15, OB_FORMAT_Y16);
config->enableVideoStream(OB_STREAM_COLOR, 640, 480, 15, OB_FORMAT_YUYV);
config->enableAccelStream();
config->enableGyroStream();
config->setFrameAggregateOutputMode(OB_FRAME_AGGREGATE_OUTPUT_ALL_TYPE_FRAME_REQUIRE);
config->setAlignMode(ALIGN_D2C_HW_MODE);
m_pipe->enableFrameSync();
// Create a format converter filter.
auto formatConverter = std::make_shared<ob::FormatConvertFilter>();
m_pipe->start(config);
// Drop several frames
for (int i = 0; i < 15; ++i) {
auto lost = m_pipe->waitForFrameset(100);
}
auto pointCloud = std::make_shared<ob::PointCloudFilter>();
int frameIndex = 0;
record = true;
QString fileNamePrefix = AppSettings::instance().dataFolder() + QDir::separator() + AppSettings::instance().fileName();
QString imuFilePath = fileNamePrefix + "_IMU.txt";
std::ofstream imuFile(imuFilePath.toStdString(), std::ios::out | std::ios::trunc);
while (record)
{
if(frameIndex==0)
{
emit CamOpenedSignal();
std::cout << "Start recording..." << std::endl;
}
auto frameSet = m_pipe->waitForFrameset(100);
if (frameSet == nullptr)
{
std::cout << "No frames received in 100ms..." << std::endl;
continue;
}
std::cout << "DepthCamera frameIndex"<< frameIndex << std::endl;
// 彩色和深度图像
auto depthFrame = frameSet->getFrame(OB_FRAME_DEPTH)->as<ob::DepthFrame>();
auto colorFrame = frameSet->getFrame(OB_FRAME_COLOR)->as<ob::ColorFrame>();
// Convert the color frame to RGB format.
if (colorFrame->format() != OB_FORMAT_RGB) {
if (colorFrame->format() == OB_FORMAT_MJPG) {
formatConverter->setFormatConvertType(FORMAT_MJPG_TO_RGB);
}
else if (colorFrame->format() == OB_FORMAT_UYVY) {
formatConverter->setFormatConvertType(FORMAT_UYVY_TO_RGB);
}
else if (colorFrame->format() == OB_FORMAT_YUYV) {
formatConverter->setFormatConvertType(FORMAT_YUYV_TO_RGB);
}
else {
std::cout << "Color format is not support!" << std::endl;
continue;
}
colorFrame = formatConverter->process(colorFrame)->as<ob::ColorFrame>();
}
// Processed the color frames to BGR format, use OpenCV to save to disk.
formatConverter->setFormatConvertType(FORMAT_RGB_TO_BGR);
colorFrame = formatConverter->process(colorFrame)->as<ob::ColorFrame>();
saveDepthFrame(depthFrame, frameIndex, fileNamePrefix.toStdString());
saveColorFrame(colorFrame, frameIndex, fileNamePrefix.toStdString());
cv::Mat colorMat(colorFrame->height(), colorFrame->width(), CV_8UC3, colorFrame->data());
cv::Mat rgbMat;
cv::cvtColor(colorMat, rgbMat, cv::COLOR_BGR2RGB);
m_colorImage = QImage(rgbMat.data, rgbMat.cols, rgbMat.rows, static_cast<int>(rgbMat.step), QImage::Format_RGB888).copy();
cv::Mat depthMat(depthFrame->height(), depthFrame->width(), CV_16UC1, depthFrame->data());
cv::Mat depthMat8U;
depthMat.convertTo(depthMat8U, CV_8UC1, 255.0 / 4096.0);
cv::Mat depthColorMap;
cv::applyColorMap(depthMat8U, depthColorMap, cv::COLORMAP_JET);
cv::Mat depthRgbMat;
cv::cvtColor(depthColorMap, depthRgbMat, cv::COLOR_BGR2RGB);
m_depthImage = QImage(depthRgbMat.data, depthRgbMat.cols, depthRgbMat.rows, static_cast<int>(depthRgbMat.step), QImage::Format_RGB888).copy();
//m_depthImage = QImage(depthMat.data, depthMat.cols, depthMat.rows, static_cast<int>(depthMat.step), QImage::Format_Grayscale16).copy();
emit PlotSignal();
//点云
pointCloud->setCreatePointFormat(OB_FORMAT_RGB_POINT);
std::shared_ptr<ob::Frame> frame = pointCloud->process(frameSet);
QString plyPath = fileNamePrefix + "_"+ QString::number(frameIndex) + ".ply";
ob::PointCloudHelper::savePointcloudToPly(plyPath.toStdString().c_str(), frame, false, false, 50);
//惯导数据
auto accelFrameRaw = frameSet->getFrame(OB_FRAME_ACCEL);
auto accelFrame = accelFrameRaw->as<ob::AccelFrame>();
auto accelIndex = accelFrame->getIndex();
auto accelTimeStampUs = accelFrame->getTimeStampUs();
auto accelTemperature = accelFrame->getTemperature();
auto accelType = accelFrame->getType();
//if (frameIndex % 50 == 0)
//{ // print information every 50 frames.
// auto accelValue = accelFrame->getValue();
// printImuValue(accelValue, accelIndex, accelTimeStampUs, accelTemperature, accelType, "m/s^2");
//}
//auto accelValue = accelFrame->getValue();
//printImuValue(accelValue, accelIndex, accelTimeStampUs, accelTemperature, accelType, "m/s^2");
auto gyroFrameRaw = frameSet->getFrame(OB_FRAME_GYRO);
auto gyroFrame = gyroFrameRaw->as<ob::GyroFrame>();
auto gyroIndex = gyroFrame->getIndex();
auto gyroTimeStampUs = gyroFrame->getTimeStampUs();
auto gyroTemperature = gyroFrame->getTemperature();
auto gyroType = gyroFrame->getType();
//if (frameIndex % 50 == 0) { // print information every 50 frames.
// auto gyroValue = gyroFrame->getValue();
// printImuValue(gyroValue, gyroIndex, gyroTimeStampUs, gyroTemperature, gyroType, "rad/s");
//}
//auto gyroValue = gyroFrame->getValue();
//printImuValue(gyroValue, gyroIndex, gyroTimeStampUs, gyroTemperature, gyroType, "rad/s");
saveImuData(imuFile, accelFrame, gyroFrame);
frameIndex++;
}
imuFile.close();
m_pipe->stop();
delete m_pipe;
m_pipe = nullptr;
}
void DepthCameraOperation::saveDepthFrame(const std::shared_ptr<ob::DepthFrame> depthFrame, const uint32_t frameIndex, std::string fileNamePrefix_)
{
std::vector<int> params;
params.push_back(cv::IMWRITE_PNG_COMPRESSION);
params.push_back(0);
params.push_back(cv::IMWRITE_PNG_STRATEGY);
params.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
std::string depthName = fileNamePrefix_ + "_Depth_" + std::to_string(depthFrame->width()) + "x" + std::to_string(depthFrame->height()) + "_" + std::to_string(frameIndex) + "_"
+ std::to_string(depthFrame->timeStamp()) + "ms.png";
cv::Mat depthMat(depthFrame->height(), depthFrame->width(), CV_16UC1, depthFrame->data());
cv::imwrite(depthName, depthMat, params);
//std::cout << "Depth saved:" << depthName << std::endl;
}
void DepthCameraOperation::saveColorFrame(const std::shared_ptr<ob::ColorFrame> colorFrame, const uint32_t frameIndex, std::string fileNamePrefix_)
{
std::vector<int> params;
params.push_back(cv::IMWRITE_PNG_COMPRESSION);
params.push_back(0);
params.push_back(cv::IMWRITE_PNG_STRATEGY);
params.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
std::string colorName = fileNamePrefix_ + "_Color_" + std::to_string(colorFrame->width()) + "x" + std::to_string(colorFrame->height()) + "_" + std::to_string(frameIndex) + "_"
+ std::to_string(colorFrame->timeStamp()) + "ms.png";
cv::Mat depthMat(colorFrame->height(), colorFrame->width(), CV_8UC3, colorFrame->data());
cv::imwrite(colorName, depthMat, params);
//std::cout << "Color saved:" << colorName << std::endl;
}
void DepthCameraOperation::printImuValue(OBFloat3D obFloat3d, uint64_t index, uint64_t timeStampUs, float temperature, OBFrameType type, const std::string& unitStr)
{
std::cout << "frame index: " << index << std::endl;
auto typeStr = ob::TypeHelper::convertOBFrameTypeToString(type);
std::cout << typeStr << " Frame: \n\r{\n\r"
<< " tsp = " << timeStampUs << "\n\r"
<< " temperature = " << temperature << "\n\r"
<< " " << typeStr << ".x = " << obFloat3d.x << unitStr << "\n\r"
<< " " << typeStr << ".y = " << obFloat3d.y << unitStr << "\n\r"
<< " " << typeStr << ".z = " << obFloat3d.z << unitStr << "\n\r"
<< "}\n\r" << std::endl;
}
void DepthCameraOperation::saveImuData(std::ofstream& imuFile, const std::shared_ptr<ob::AccelFrame>& accelFrame, const std::shared_ptr<ob::GyroFrame>& gyroFrame)
{
if (!imuFile.is_open())
return;
auto accelValue = accelFrame->getValue();
auto gyroValue = gyroFrame->getValue();
// position (acceleration): ax, ay, az
// attitude (angular velocity): gx, gy, gz
imuFile << accelFrame->getIndex() << ","
<< accelFrame->getTimeStampUs() << ","
<< accelValue.x << "," << accelValue.y << "," << accelValue.z << ","
<< gyroFrame->getIndex() << ","
<< gyroFrame->getTimeStampUs() << ","
<< gyroValue.x << "," << gyroValue.y << "," << gyroValue.z << "\n";
}
void DepthCameraOperation::OpenDepthCamera_callback()
{
}
void DepthCameraOperation::setCallback(void(*func)())
{
m_func = func;
}
void DepthCameraOperation::CloseDepthCamera()
{
std::cout << "DepthCameraOperation::CloseDepthCamera关闭深度相机" << std::endl;
record = false;
emit CamClosedSignal();
}

84
HPPA/DepthCameraWindow.h Normal file
View File

@ -0,0 +1,84 @@
#pragma once
#include <QDialog>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QImage>
#include <Qthread>
#include <QDir>
#include <iostream>
#include "ui_DepthCamera.h"
#include "AppSettings.h"
#include <fstream>
#include <opencv2/opencv.hpp>
#include <libobsensor/ObSensor.hpp>
#include "libobsensor/hpp/Utils.hpp"
typedef void(*func)();
class DepthCameraOperation :public QObject
{
Q_OBJECT
public:
DepthCameraOperation();
~DepthCameraOperation();
QImage m_colorImage;
QImage m_depthImage;
void setCallback(void(*func)());
bool getRecordStatus() const { return record; }
private:
ob::Pipeline* m_pipe;
cv::Mat frame;
func m_func;
void saveDepthFrame(const std::shared_ptr<ob::DepthFrame> depthFrame, const uint32_t frameIndex, std::string fileNamePrefix_);
void saveColorFrame(const std::shared_ptr<ob::ColorFrame> colorFrame, const uint32_t frameIndex, std::string fileNamePrefix_);
void printImuValue(OBFloat3D obFloat3d, uint64_t index, uint64_t timeStampUs, float temperature, OBFrameType type, const std::string& unitStr);
void saveImuData(std::ofstream& imuFile, const std::shared_ptr<ob::AccelFrame>& accelFrame, const std::shared_ptr<ob::GyroFrame>& gyroFrame);
bool record;
public slots:
void OpenDepthCamera();
void OpenDepthCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
void CloseDepthCamera();
signals:
void PlotSignal();
void CamOpenedSignal();
void CamClosedSignal();
};
class DepthCameraWindow : public QDialog
{
Q_OBJECT
public:
DepthCameraWindow(QWidget* parent = nullptr);
~DepthCameraWindow();
DepthCameraOperation* m_DepthCameraOperation;
public Q_SLOTS:
void openDepthCamera();
void onCamOpened();
void closeDepthCamera();
void onCamClosed();
signals:
void openDepthCameraSignal();
void PlotDepthImageSignal();
void DepthCamClosedSignal();
private:
Ui::DepthCameraClass ui;
QThread* m_DepthCameraThread;
};

View File

@ -111,6 +111,7 @@ HPPA::HPPA(QWidget* parent)
connect(this->ui.action_about, SIGNAL(triggered()), this, SLOT(onAbout()));
connect(this->ui.mActionOneMotorScenario, SIGNAL(triggered()), this, SLOT(createOneMotorScenario()));
connect(this->ui.mActionPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(createPlantPhenotypeScenario()));
connect(this->ui.mActionMicroscopicMotionControlScenario, SIGNAL(triggered()), this, SLOT(createMicroscopicMotionControlScenario()));
delete ui.centralWidget;
@ -399,12 +400,28 @@ HPPA::HPPA(QWidget* parent)
m_carousel->addWidget(sa);
m_carousel->setContentsMargins(0, 0, 0, 0);
QWidget* tmp8 = new QWidget();
tmp8->setStyleSheet(R"(
//---------------------------------------------------------------------
QScrollArea* sa_depthCamera = new QScrollArea();
sa_depthCamera->setObjectName("sa_depthCamera");
sa_depthCamera->setStyleSheet(R"(
border: none;
background-color: #0D1233;
)");
QGridLayout* gridLayout_sa_depthCamera = new QGridLayout(sa_depthCamera);
gridLayout_sa_depthCamera->setSpacing(6);
gridLayout_sa_depthCamera->setObjectName(QString::fromUtf8("gridLayout_sa_depthCamera"));
gridLayout_sa_depthCamera->setVerticalSpacing(0);
gridLayout_sa_depthCamera->setContentsMargins(0, 0, 0, 0);
m_depthCamera_label = new QLabel();
m_depthCamera_label->setAlignment(Qt::AlignHCenter);
m_depthCamera_label->setStyleSheet(R"(
background-color: #0D1233;
)");
m_carousel->addWidget(tmp8);
//m_carousel->setContentsMargins(0, 0, 0, 0);
gridLayout_sa_depthCamera->addWidget(m_depthCamera_label);
m_carousel->addWidget(sa_depthCamera);
m_carousel->setContentsMargins(0, 0, 0, 0);
m_carousel->play();
@ -453,6 +470,7 @@ HPPA::HPPA(QWidget* parent)
gridLayout_modelWidgetContainer->addWidget(m_view3DModelManager);
connect(m_view3DModelManager, SIGNAL(created3DModelPlantPhenotype()), this, SLOT(onCreated3DModelPlantPhenotype()));
connect(m_view3DModelManager, SIGNAL(created3DModelMicroscopicMotion()), this, SLOT(onCreated3DModelMicroscopicMotion()));
connect(m_view3DModelManager, SIGNAL(created3DModelOneMotor()), this, SLOT(onCreated3DModelOneMotor()));
ui.mDockWidgetSimulator->setWidget(tmp(modelWidgetContainer));
@ -753,11 +771,22 @@ void HPPA::initControlTabwidget()
this, SLOT(onBandSelectionChanged(double, double, double)));
ui.controlTabWidget->addTab(m_ic, QString::fromLocal8Bit("图像控制"));//?????????????????????????????????????????????????????????????????????????????????????????????????
//深度相机
m_depthCameraWindow = new DepthCameraWindow();
ui.controlTabWidget->addTab(m_depthCameraWindow, QString::fromLocal8Bit("深度相机"));
//单反相机
m_singleLensReflexCameraWindow = new SingleLensReflexCameraWindow();
ui.controlTabWidget->addTab(m_singleLensReflexCameraWindow, QString::fromLocal8Bit("单反相机"));
//rgb相机
m_rgbCameraControlWindow = new rgbCameraWindow();
connect(m_rgbCameraControlWindow, &rgbCameraWindow::PlotRgbImageSignal, this, &HPPA::onPlotRgbImage);
connect(m_rgbCameraControlWindow, &rgbCameraWindow::CamClosedSignal, this, &HPPA::onClearLabel);
connect(m_depthCameraWindow, &DepthCameraWindow::PlotDepthImageSignal, this, &HPPA::onPlotDepthImage);
connect(m_depthCameraWindow, &DepthCameraWindow::DepthCamClosedSignal, this, &HPPA::onClearDepthLabel);
ui.controlTabWidget->addTab(m_rgbCameraControlWindow, QString::fromLocal8Bit("rgb相机"));
//升降桌dock
@ -1164,6 +1193,7 @@ void HPPA::createScenarioActionGroup()
m_ScenarioActionGroup = new QActionGroup(this);
m_ScenarioActionGroup->addAction(ui.mActionOneMotorScenario);
m_ScenarioActionGroup->addAction(ui.mActionPlantPhenotypeScenario);
m_ScenarioActionGroup->addAction(ui.mActionMicroscopicMotionControlScenario);
// 读取上次选择的结果
QSettings settings;
@ -1180,6 +1210,11 @@ void HPPA::createScenarioActionGroup()
ui.mActionPlantPhenotypeScenario->setChecked(true);
ui.mActionPlantPhenotypeScenario->trigger();
}
else if (lastSelectedAction == "mActionMicroscopicMotionControlScenario")
{
ui.mActionMicroscopicMotionControlScenario->setChecked(true);
ui.mActionMicroscopicMotionControlScenario->trigger();
}
}
void HPPA::selectScenario(QAction* selectedAction)
@ -1210,6 +1245,8 @@ void HPPA::createOneMotorScenario()
ui.mAction_1AxisMotor->setChecked(true);
//右下角控制tab
m_tabManager->hideTab(m_singleLensReflexCameraWindow);
m_tabManager->hideTab(m_depthCameraWindow);
m_tabManager->hideTab(m_rgbCameraControlWindow);
m_tabManager->hideTab(m_adt);
m_tabManager->hideTab(m_pc);
@ -1229,6 +1266,11 @@ void HPPA::onCreated3DModelPlantPhenotype()
connect(m_tmc, SIGNAL(broadcastLocationSignal(std::vector<double>)), m_view3DModelManager->m_viewPlant, SLOT(setLoc(std::vector<double>)));
}
void HPPA::onCreated3DModelMicroscopicMotion()
{
connect(m_tmc, SIGNAL(broadcastLocationSignal(std::vector<double>)), m_view3DModelManager->m_viewMicroscopicMotionControlModel, SLOT(setLoc(std::vector<double>)));
}
void HPPA::createPlantPhenotypeScenario()
{
//if (ui.mActionPlantPhenotypeScenario->isChecked())
@ -1241,6 +1283,8 @@ void HPPA::createPlantPhenotypeScenario()
m_tabManager->hideTab(m_rac);
m_tabManager->hideTab(m_omc);
m_tabManager->showTab(m_depthCameraWindow);
m_tabManager->showTab(m_singleLensReflexCameraWindow);
m_tabManager->showTab(m_rgbCameraControlWindow);
m_tabManager->showTab(m_adt);
m_tabManager->showTab(m_pc);
@ -1252,6 +1296,31 @@ void HPPA::createPlantPhenotypeScenario()
}
void HPPA::createMicroscopicMotionControlScenario()
{
//if (ui.mActionMicroscopicMotionControl->isChecked())
// return;
//在菜单中选择移动平台
ui.mAction_2AxisMotor_new->setChecked(true);
//右下角控制tab
m_tabManager->hideTab(m_singleLensReflexCameraWindow);
m_tabManager->hideTab(m_depthCameraWindow);
m_tabManager->hideTab(m_rgbCameraControlWindow);
m_tabManager->hideTab(m_adt);
m_tabManager->hideTab(m_pc);
m_tabManager->hideTab(m_rac);
m_tabManager->hideTab(m_omc);
m_tabManager->showTab(m_tmc);
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::MicroscopicMotionControl);
//右上角轮播
}
bool HPPA::testImagerVality()
{
try
@ -1760,6 +1829,23 @@ void HPPA::onClearLabel()
m_cam_label->setText("closed");
}
void HPPA::onPlotDepthImage()
{
QPixmap pixmap = QPixmap::fromImage(m_depthCameraWindow->m_DepthCameraOperation->m_depthImage);
int width = m_depthCamera_label->width();
int height = m_depthCamera_label->height();
QPixmap fitpixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
m_depthCamera_label->setPixmap(fitpixmap);
}
void HPPA::onClearDepthLabel()
{
m_depthCamera_label->clear();
m_depthCamera_label->setText("closed");
}
void HPPA::onCopyFinished()
{
this->setEnabled(true);
@ -1821,6 +1907,10 @@ void HPPA::onOpenImg()
if (uri.isEmpty())
return;
//判断是否已经打开
if (m_MapLayerStore->containsLayer(uri))
return;
// 2) 创建 RasterLayer然后添加到图层管理器
if (!m_LayerTreeModel || !m_RasterGroup)
{
@ -2027,9 +2117,9 @@ void HPPA::onconnect()
ui.gain_lineEdit->setValidator(new QRegExpValidator(rx));*/
//获取相机参数并显示到界面中
m_hic->setFrameRate(m_Imager->getFramerate());
m_hic->setIntegrationTime(m_Imager->getIntegrationTime());
m_hic->setGain(m_Imager->getGain());
m_hic->setFrameRate(AppSettings::instance().frameRate());
m_hic->setIntegrationTime(AppSettings::instance().integrationTime());
m_hic->setGain(AppSettings::instance().gain());
}
catch (std::exception const& e)
{

View File

@ -78,6 +78,8 @@
#include "FileNameLineEdit.h"
#include "rgbCameraWindow.h"
#include "DepthCameraWindow.h"
#include "SingleLensReflexCameraWindow.h"
#define PI 3.1415926
@ -270,6 +272,7 @@ private:
MyCarousel* m_carousel;
QLabel* m_cam_label;
QLabel* m_depthCamera_label;
QPushButton* m_open_rgb_camera_btn;
QPushButton* m_close_rgb_camera_btn;
@ -278,6 +281,8 @@ private:
HyperImagerControl* m_hic;
rgbCameraWindow* m_rgbCameraControlWindow;
ImageControl* m_ic;
DepthCameraWindow* m_depthCameraWindow;
SingleLensReflexCameraWindow* m_singleLensReflexCameraWindow;
adjustTable* m_adt;
PowerControl* m_pc;
RobotArmControl* m_rac;
@ -349,8 +354,10 @@ public Q_SLOTS:
void OnSendLogToCallClass(QString str);
void onPlotRgbImage();
void onPlotDepthImage();
void onClearLabel();
void onClearDepthLabel();
void onCopyFinished();
@ -361,6 +368,8 @@ public Q_SLOTS:
void createOneMotorScenario();
void createPlantPhenotypeScenario();
void onCreated3DModelPlantPhenotype();
void onCreated3DModelMicroscopicMotion();
void createMicroscopicMotionControlScenario();
void onCreated3DModelOneMotor();
void addLayer(const QString& baseName, const QString& filePath, bool refresh);

View File

@ -133,6 +133,7 @@ color:white;
</property>
<addaction name="mActionOneMotorScenario"/>
<addaction name="mActionPlantPhenotypeScenario"/>
<addaction name="mActionMicroscopicMotionControlScenario"/>
</widget>
<widget class="QMenu" name="menu_4">
<property name="title">
@ -725,6 +726,14 @@ QPushButton:pressed
<string>光谱</string>
</property>
</action>
<action name="mActionMicroscopicMotionControlScenario">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>显微运动控制台</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View File

@ -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;$(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;$(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;$(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>
<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;$(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;$(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;$(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>
<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;%(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;%(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;%(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;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@ -114,6 +114,7 @@
<ClCompile Include="Carousel.cpp" />
<ClCompile Include="Corning410Imager.cpp" />
<ClCompile Include="CustomDockWidgetBase.cpp" />
<ClCompile Include="DepthCameraWindow.cpp" />
<ClCompile Include="FileNameLineEdit.cpp" />
<ClCompile Include="hppaConfigFile.cpp" />
<ClCompile Include="HyperImagerControl.cpp" />
@ -150,6 +151,7 @@
<ClCompile Include="rgbCameraWindow.cpp" />
<ClCompile Include="RobotArmControl.cpp" />
<ClCompile Include="setWindow.cpp" />
<ClCompile Include="SingleLensReflexCameraWindow.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
@ -162,6 +164,7 @@
<QtRcc Include="HPPA.qrc" />
<QtUic Include="about.ui" />
<QtUic Include="adjustTable.ui" />
<QtUic Include="DepthCamera.ui" />
<QtUic Include="FocusDialog.ui" />
<QtUic Include="HPPA.ui" />
<QtMoc Include="HPPA.h" />
@ -185,6 +188,7 @@
<QtUic Include="rgbCamera.ui" />
<QtUic Include="RobotArmControl.ui" />
<QtUic Include="set.ui" />
<QtUic Include="SingleLensReflexCamera.ui" />
<QtUic Include="twoMotorControl.ui" />
</ItemGroup>
<ItemGroup>
@ -211,6 +215,7 @@
<QtMoc Include="HyperImagerControl.h" />
<ClInclude Include="AppSettings.h" />
<QtMoc Include="FileNameLineEdit.h" />
<QtMoc Include="DepthCameraWindow.h" />
<ClInclude Include="imager_base.h" />
<ClInclude Include="irisximeaimager.h" />
<QtMoc Include="OneMotorControl.h" />
@ -236,6 +241,7 @@
<QtMoc Include="recordFrameCounter.h" />
<QtMoc Include="setWindow.h" />
<QtMoc Include="rgbCameraWindow.h" />
<QtMoc Include="SingleLensReflexCameraWindow.h" />
<ClInclude Include="utility_tc.h" />
<QtMoc Include="aboutWindow.h" />
<ClInclude Include="hppaConfigFile.h" />

View File

@ -214,6 +214,12 @@
<ClCompile Include="rgbCameraWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DepthCameraWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SingleLensReflexCameraWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="fileOperation.h">
@ -348,6 +354,12 @@
<QtMoc Include="rgbCameraWindow.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="DepthCameraWindow.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="SingleLensReflexCameraWindow.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<ClInclude Include="imageProcessor.h">
@ -439,6 +451,12 @@
<QtUic Include="rgbCamera.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="DepthCamera.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="SingleLensReflexCamera.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

View File

@ -83,6 +83,7 @@ void HyperImagerControl::setFrameRate(double frameRate)
ui.FramerateSlider->setValue(frameRate);
updateIntegrationTimeRange(frameRate);
AppSettings::instance().setFrameRate(frameRate);
}
void HyperImagerControl::setIntegrationTime(double integrationTime)
@ -91,12 +92,15 @@ void HyperImagerControl::setIntegrationTime(double integrationTime)
ui.IntegratioinTimeSlider->setValue(integrationTime);
updateFramerateRange(integrationTime);
AppSettings::instance().setIntegrationTime(integrationTime);
}
void HyperImagerControl::setGain(double gain)
{
ui.gain_spinBox->setValue(gain);
ui.GainSlider->setValue(gain);
AppSettings::instance().setGain(gain);
}
void HyperImagerControl::onFramerateSpinBoxEditingFinished()
@ -161,7 +165,7 @@ void HyperImagerControl::onGainSliderReleased()
void HyperImagerControl::updateIntegrationTimeRange(double frameRate)
{
double maxIntegrationTime = 1.0 / frameRate * 1000.0; // 毫秒
double maxIntegrationTime = 1.0 / frameRate * 999.0; // 毫秒
ui.IntegratioinTimeSlider->blockSignals(true);
ui.IntegratioinTimeSlider->setMaximum(maxIntegrationTime);
@ -176,7 +180,7 @@ void HyperImagerControl::updateIntegrationTimeRange(double frameRate)
void HyperImagerControl::updateFramerateRange(double integrationTime)
{
double maxFramerate = 1.0 / (integrationTime / 1000.0); // 积分时间(毫秒)转帧率
double maxFramerate = 1.0 / (integrationTime / 999.0); // 积分时间(毫秒)转帧率
if(maxFramerate > m_frameRateLimit)
{

View File

@ -5,6 +5,7 @@
#include "ui_hyperImagerControl.h"
#include "AspectRatioLabel.h"
#include "AppSettings.h"
class QDoubleSlider;

View File

@ -43,6 +43,22 @@ void MapLayerStore::removeLayerByName(const QString& name)
}
}
bool MapLayerStore::containsLayer(const QString& url, bool isAbsolutePath) const
{
QFileInfo fi(url);
QString fileName = fi.completeBaseName();
if (!isAbsolutePath)
{
return getLayer(fileName) != nullptr;
}
for (const auto& l : m_layers) {
if (l->dataPath() == url)
return true;
}
return false;
}
MapLayer* MapLayerStore::getLayer(const QString& name) const
{
for (const auto& l : m_layers) {

View File

@ -2,6 +2,7 @@
#include <QObject>
#include <QString>
#include <QFileInfo>
#include <vector>
#include <memory>
#include <unordered_map>
@ -20,6 +21,8 @@ public:
// Now also accept the associated QWidget so UI widget can be retrieved by layer pointer
void addLayer(MapLayer* layer, QWidget* widget = nullptr);
bool containsLayer(const QString& url, bool isAbsolutePath = true) const;
// Remove by pointer or by name. Destruction happens when removed from store.
public slots:
void removeLayer(MapLayer* layer);

View File

@ -6,7 +6,8 @@ m_Multiplier(100.0)
{
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
setSingleStep(1);
setSingleStep(0);
setPageStep(0);
setRange(1, 500);
setOrientation(Qt::Horizontal);

View File

@ -30,7 +30,7 @@ void RgbCameraOperation::OpenCamera()
cam->release();
emit CamClosed();
emit CamOpenedSignal();
}
@ -65,4 +65,6 @@ void RgbCameraOperation::CloseCamera()
std::cout << "关闭摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
record = false;
emit CamClosedSignal();
}

View File

@ -42,6 +42,7 @@ public slots:
signals:
void PlotSignal();
void CamClosed();
void CamOpenedSignal();
void CamClosedSignal();
};
#endif // !RGBCAMERAOPERATION_H

View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SingleLensReflexCameraClass</class>
<widget class="QDialog" name="SingleLensReflexCameraClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>855</width>
<height>481</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>SingleLensReflexCamera</string>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox
{
border: 12px solid transparent;
/*border-top: 12px solid transparent;
border-right: 0px solid transparent;
border-bottom: 0px solid transparent;
border-left: 0px solid transparent;*/
color: #ACCDFF;
}
QPushButton
{
/*width: 172px;
height: 56px;*/
font: 19pt &quot;新宋体&quot;;
background-color: qlineargradient(
spread:pad,
x1:0.5, y1:0, x2:0.5, y2:1,
stop:0 #283D86,
stop:1 #0F1A40
);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
QPushButton:hover
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #3A4875,
stop:1 #5F6B91
);
}
/* 按下时的效果 */
QPushButton:pressed
{
background-color: qlineargradient(
spread:pad,
x1:0, y1:0, x2:1, y2:0,
stop:0 #1A254F,
stop:1 #3A466B
);
/* 可选:添加下压效果 */
padding-top: 9px;
padding-bottom: 7px;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>100</height>
</size>
</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">
<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">
<widget class="QPushButton" name="openSLRCamera_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">
<spacer name="horizontalSpacer_2">
<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="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<height>100</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,95 @@
#include "SingleLensReflexCameraWindow.h"
SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
m_SLRCameraThread = new QThread();
m_SingleLensReflexCameraOperation = new SingleLensReflexCameraOperation();
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(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);
}
SingleLensReflexCameraWindow::~SingleLensReflexCameraWindow()
{
m_SLRCameraThread->quit();
m_SLRCameraThread->wait();
delete m_SingleLensReflexCameraOperation;
m_SingleLensReflexCameraOperation = nullptr;
}
void SingleLensReflexCameraWindow::openSLRCamera()
{
if (!m_SingleLensReflexCameraOperation->getRecordStatus())
{
emit openSLRCameraSignal();
}
}
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();
}
void SingleLensReflexCameraWindow::onCamClosed()
{
ui.openSLRCamera_btn->setEnabled(true);
ui.closeSLRCamera_btn->setEnabled(false);
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("打 开"));
}
//-------------------------------------------------------------------------------------------------------------------------------
SingleLensReflexCameraOperation::SingleLensReflexCameraOperation()
{
m_func = nullptr;
record = false;
}
SingleLensReflexCameraOperation::~SingleLensReflexCameraOperation()
{
}
void SingleLensReflexCameraOperation::OpenSLRCamera()
{
}
void SingleLensReflexCameraOperation::OpenSLRCamera_callback()
{
}
void SingleLensReflexCameraOperation::setCallback(void(*func)())
{
m_func = func;
}
void SingleLensReflexCameraOperation::CloseSLRCamera()
{
std::cout << "SingleLensReflexCameraOperation::CloseSLRCamera关闭单反相机" << std::endl;
record = false;
emit CamClosedSignal();
}

View File

@ -0,0 +1,76 @@
#pragma once
#include <QDialog>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QImage>
#include <Qthread>
#include <QDir>
#include <iostream>
#include "ui_SingleLensReflexCamera.h"
#include "AppSettings.h"
#include <fstream>
#include <opencv2/opencv.hpp>
typedef void(*func)();
class SingleLensReflexCameraOperation :public QObject
{
Q_OBJECT
public:
SingleLensReflexCameraOperation();
~SingleLensReflexCameraOperation();
QImage m_colorImage;
QImage m_depthImage;
void setCallback(void(*func)());
bool getRecordStatus() const { return record; }
private:
cv::Mat frame;
func m_func;
bool record;
public slots:
void OpenSLRCamera();
void OpenSLRCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
void CloseSLRCamera();
signals:
void PlotSignal();
void CamOpenedSignal();
void CamClosedSignal();
};
class SingleLensReflexCameraWindow : public QDialog
{
Q_OBJECT
public:
SingleLensReflexCameraWindow(QWidget* parent = nullptr);
~SingleLensReflexCameraWindow();
SingleLensReflexCameraOperation* m_SingleLensReflexCameraOperation;
public Q_SLOTS:
void openSLRCamera();
void onCamOpened();
void closeSLRCamera();
void onCamClosed();
signals:
void openSLRCameraSignal();
void PlotSLRImageSignal();
void SLRCamClosedSignal();
private:
Ui::SingleLensReflexCameraClass ui;
QThread* m_SLRCameraThread;
};

View File

@ -372,4 +372,18 @@ void View3DLinearStage::setLoc(std::vector<double> loc)
double x = round(loc[0] * 100) / 100;
m_armTransform->setTranslation(QVector3D(x, 0, 0));
}
}
View3DMicroscopicMotionModel::View3DMicroscopicMotionModel(const QString& baseModelPath, const QString& armModelPath, QWidget* parent)
:View3DBase(baseModelPath, armModelPath, parent)
{
}
void View3DMicroscopicMotionModel::setLoc(std::vector<double> loc)
{
double x = round(loc[0] * 100) / 100;
double y = round(loc[1] * 100) / 100;
m_armTransform->setTranslation(QVector3D(x, y, 0));
}

View File

@ -106,6 +106,24 @@ private:
private:
public Q_SLOTS:
void setLoc(std::vector<double> loc);
};
class View3DMicroscopicMotionModel : public View3DBase
{
Q_OBJECT
public:
View3DMicroscopicMotionModel(const QString& baseModelPath,
const QString& armModelPath,
QWidget* parent = nullptr);
protected:
private:
private:
public Q_SLOTS:
void setLoc(std::vector<double> loc);
};

View File

@ -13,15 +13,21 @@ View3DModelManager::View3DModelManager(QWidget* parent)
void View3DModelManager::switchScenario(ScenarioType type)
{
if (type == ScenarioType::PlantPhenotype) {
if (type == ScenarioType::PlantPhenotype)
{
ensurePlantPhenotypeView();
m_stackedWidget->setCurrentWidget(m_viewPlant);
}
else {
if (type == ScenarioType::OneMotor)
{
ensureOneMotorView();
m_stackedWidget->setCurrentWidget(m_viewMotor);
}
if (type == ScenarioType::MicroscopicMotionControl)
{
ensureMicroscopicMotionControlView();
m_stackedWidget->setCurrentWidget(m_viewMicroscopicMotionControlModel);
}
emit scenarioChanged(type);
}
@ -46,6 +52,27 @@ void View3DModelManager::ensurePlantPhenotypeView()
emit created3DModelPlantPhenotype();
}
void View3DModelManager::ensureMicroscopicMotionControlView()
{
if (m_viewMicroscopicMotionControlModel)
return;
QString basePath = QCoreApplication::applicationDirPath();
m_viewMicroscopicMotionControlModel = new View3DMicroscopicMotionModel(
basePath + "/3DModel/MicroscopicMotionModel_static.obj",
basePath + "/3DModel/MicroscopicMotionModel_moving.obj",
m_stackedWidget
);
m_viewMicroscopicMotionControlModel->setViewCenter(1000, 1000, -1000);
m_viewMicroscopicMotionControlModel->setDistance(5000);
m_stackedWidget->addWidget(m_viewMicroscopicMotionControlModel);
emit created3DModelMicroscopicMotion();
}
void View3DModelManager::ensureOneMotorView()
{
if (m_viewMotor)

View File

@ -16,7 +16,8 @@ class View3DModelManager : public QWidget
public:
enum class ScenarioType {
PlantPhenotype,
OneMotor
OneMotor,
MicroscopicMotionControl
};
explicit View3DModelManager(QWidget* parent = nullptr);
@ -25,14 +26,17 @@ public:
View3DPlantPhenotype* m_viewPlant = nullptr;
View3DLinearStage* m_viewMotor = nullptr;
View3DMicroscopicMotionModel* m_viewMicroscopicMotionControlModel = nullptr;
signals:
void scenarioChanged(ScenarioType type);
void created3DModelPlantPhenotype();
void created3DModelOneMotor();
void created3DModelMicroscopicMotion();
private:
void ensurePlantPhenotypeView();
void ensureMicroscopicMotionControlView();
void ensureOneMotorView();
private:

View File

@ -288,7 +288,7 @@ QPushButton:pressed
}</string>
</property>
<property name="text">
<string>版本3.0.1</string>
<string>版本3.0.2</string>
</property>
</widget>
</item>

View File

@ -153,22 +153,18 @@ void CImage::FillFocusGrayImage(unsigned short * datacube)
void CImage::FillFocusGrayQImage(unsigned short * datacube)
{
float two_eight = pow(2.0, 8);
float two_sixteen = pow(2.0, 12);
constexpr float scale = 256.0f / 4096.0f; // 2^8 / 2^12
int width = m_qimageFocusGrayImage->width();
int height = m_qimageFocusGrayImage->height();
for (unsigned short i = 0; i < height; i++)
for (int i = 0; i < height; i++)
{
for (unsigned short j = 0; j < width; j++)
QRgb* scanLine = reinterpret_cast<QRgb*>(m_qimageFocusGrayImage->scanLine(i));
const unsigned short* srcRow = datacube + width * i;
for (int j = 0; j < width; j++)
{
//uint tmp = (two_eight* *(datacube + width * i + j)) / two_sixteen;
uint tmp = (two_eight* datacube[width*i + j]) / two_sixteen;
//uint tmp = datacube[width*i + j];
//m_qimageFocusGrayImage->setPixel(j, i, tmp);
m_qimageFocusGrayImage->setPixel(j, i, qRgb((unsigned char)tmp, (unsigned char)tmp, (unsigned char)tmp));
unsigned char gray = static_cast<unsigned char>(srcRow[j] * scale);
scanLine[j] = qRgb(gray, gray, gray);
}
}

View File

@ -8,6 +8,14 @@ ImageControl::ImageControl(QWidget* parent)
{
ui.setupUi(this);
ui.sliderRed->setPageStep(0);
ui.sliderGreen->setPageStep(0);
ui.sliderBlue->setPageStep(0);
ui.sliderRed->setSingleStep(0);
ui.sliderGreen->setSingleStep(0);
ui.sliderBlue->setSingleStep(0);
// Spinbox valueChanged: only sync the paired slider (no render)
connect(ui.spinRed, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &ImageControl::onSpinRedValueChanged);
connect(ui.spinGreen, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &ImageControl::onSpinGreenValueChanged);
@ -137,16 +145,10 @@ void ImageControl::setActiveLayer(RasterLayer* layer)
int maxIdx = static_cast<int>(m_wavelengths.size()) - 1;
ui.sliderRed->setMinimum(0);
ui.sliderRed->setMaximum(maxIdx);
ui.sliderRed->setSingleStep(1);
ui.sliderRed->setPageStep(1);
ui.sliderGreen->setMinimum(0);
ui.sliderGreen->setMaximum(maxIdx);
ui.sliderGreen->setSingleStep(1);
ui.sliderGreen->setPageStep(1);
ui.sliderBlue->setMinimum(0);
ui.sliderBlue->setMaximum(maxIdx);
ui.sliderBlue->setSingleStep(1);
ui.sliderBlue->setPageStep(1);
// Set current values from layer's render params
auto params = layer->currentRenderParams();

View File

@ -18,7 +18,7 @@ rgbCameraWindow::rgbCameraWindow(QWidget* parent)
//connect(this->ui.open_rgb_camera_btn, SIGNAL(clicked()), m_RgbCamera, SLOT(OpenCamera_callback()));//ʹ<>ûص<C3BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3>ui<75>̣߳<DFB3><CCA3>ϵ<EFBFBD><CFB5><EFBFBD>Ƶ <20><> ʧ<><CAA7>
connect(ui.close_rgb_camera_btn, SIGNAL(clicked()), this, SLOT(onCloseRgbCamera()));//<2F>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD>
connect(m_RgbCamera, SIGNAL(CamClosed()), this, SIGNAL(CamClosedSignal()));
connect(m_RgbCamera, SIGNAL(CamClosedSignal()), this, SIGNAL(CamClosedSignal()));
}
rgbCameraWindow::~rgbCameraWindow()

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>486</width>
<height>229</height>
<width>641</width>
<height>320</height>
</rect>
</property>
<property name="windowTitle">
@ -234,26 +234,58 @@ QPushButton:pressed
</item>
<item row="1" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_2" rowstretch="3,2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>数据路径</string>
</property>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>数据路径</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="dataFolderLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="dataFolderBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="dataFolderLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="dataFolderBtn">
<property name="text">
<string>...</string>
</property>
<item row="1" column="0">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QGridLayout" name="gridLayout_4" columnstretch="5,2">
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>411</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="confirmBtn">
<property name="text">
<string>确认</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>

View File

@ -12,6 +12,7 @@ setWindow::setWindow(QWidget* parent)
connect(this->ui.closeBtn, SIGNAL(released()), this, SLOT(onExit()));
connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
connect(this->ui.confirmBtn, SIGNAL(clicked()), this, SLOT(onExit()));
loadSettings();
}