Compare commits
25 Commits
3.1.0
...
0562e8592c
| Author | SHA1 | Date | |
|---|---|---|---|
| 0562e8592c | |||
| 9bc2133e24 | |||
| e552dc2ed5 | |||
| 2e7bf50737 | |||
| 1a64fb32e3 | |||
| ebc39f9f9d | |||
| 9307947ed0 | |||
| 7452748324 | |||
| 6557916b7b | |||
| 392bc98ebf | |||
| 0866b9cd56 | |||
| 33e34aa125 | |||
| abdb27b228 | |||
| 64cdc7591d | |||
| f00fc6fdea | |||
| 10beb03843 | |||
| 64bc8a9d27 | |||
| 6b63d28d2c | |||
| 3feefe45c1 | |||
| 245fc7f4ef | |||
| a49f416551 | |||
| 39578dc9fe | |||
| e326dcb20c | |||
| 7ded94c2a4 | |||
| cb5a74f576 |
10
HPPA.sln
10
HPPA.sln
@ -12,6 +12,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vincecontrol", "vincecontro
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IrisMultiMotorController", "IrisMultiMotorController\IrisMultiMotorController\IrisMultiMotorController.vcxproj", "{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JinspSpectralmeterControl", "JinspSpectralmeterControl\JinspSpectralmeterControl.vcxproj", "{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@ -44,6 +46,14 @@ Global
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x64.Build.0 = Release|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.ActiveCfg = Release|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.Build.0 = Release|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x64.Build.0 = Debug|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x86.Build.0 = Debug|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x64.ActiveCfg = Release|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x64.Build.0 = Release|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x86.ActiveCfg = Release|x64
|
||||
{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x86.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -8,6 +8,10 @@ const int AppSettings::kDefaultIntegrationTime = 1;
|
||||
const int AppSettings::kDefaultGain = 0;
|
||||
const QString AppSettings::kDefaultSLRDataFolder = QString();
|
||||
const QString AppSettings::kDefaultDepthCameraDataFolder = QString();
|
||||
const double AppSettings::kDefaultScanSpeed = 1.0;
|
||||
const double AppSettings::kDefaultReturnSpeed = 5.0;
|
||||
const int AppSettings::kDefaultGonggaShanRecordPort = 666;
|
||||
const AppSettings::HyperimgDisplayMode AppSettings::kDefaultHyperimgDisplayMode = HyperimgDisplayMode::Waterfall;
|
||||
|
||||
AppSettings::AppSettings()
|
||||
: m_settings(QSettings::IniFormat, QSettings::UserScope,
|
||||
@ -100,3 +104,95 @@ void AppSettings::setDepthCameraDataFolder(const QString& path)
|
||||
{
|
||||
m_settings.setValue("General/DepthCameraDataFolder", path);
|
||||
}
|
||||
|
||||
QString AppSettings::FiberImagerDataFolder() const
|
||||
{
|
||||
QString path = m_settings.value("General/FiberImagerDataFolder").toString();
|
||||
if (path.isEmpty())
|
||||
{
|
||||
return QCoreApplication::applicationDirPath() + "/CapturedFiberImagerData/";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
void AppSettings::setFiberImagerDataFolder(const QString& path)
|
||||
{
|
||||
m_settings.setValue("General/FiberImagerDataFolder", path);
|
||||
}
|
||||
|
||||
QString AppSettings::rgbCameraDataFolder() const
|
||||
{
|
||||
QString path = m_settings.value("RgbCamera/RgbCameraDataFolder", "D:").toString();
|
||||
if (path.isEmpty())
|
||||
{
|
||||
return QCoreApplication::applicationDirPath() + "/CapturedRgbCameraData/";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
void AppSettings::setRgbCameraDataFolder(const QString& path)
|
||||
{
|
||||
m_settings.setValue("RgbCamera/RgbCameraDataFolder", path);
|
||||
}
|
||||
|
||||
QString AppSettings::rgbCameraFileName() const
|
||||
{
|
||||
return m_settings.value("RgbCamera/FileName", "test_rgb_data").toString();
|
||||
}
|
||||
|
||||
void AppSettings::setRgbCameraFileName(const QString& name)
|
||||
{
|
||||
m_settings.setValue("RgbCamera/FileName", name);
|
||||
}
|
||||
|
||||
QString AppSettings::fodisCameraFileName() const
|
||||
{
|
||||
return m_settings.value("FodisCamera/FileName", "test_fodis_data").toString();
|
||||
}
|
||||
|
||||
void AppSettings::setFodisCameraFileName(const QString& name)
|
||||
{
|
||||
m_settings.setValue("FodisCamera/FileName", name);
|
||||
}
|
||||
|
||||
double AppSettings::scanSpeed() const
|
||||
{
|
||||
return m_settings.value("OneMotorControl/ScanSpeed", kDefaultScanSpeed).toDouble();
|
||||
}
|
||||
|
||||
void AppSettings::setScanSpeed(double value)
|
||||
{
|
||||
m_settings.setValue("OneMotorControl/ScanSpeed", value);
|
||||
}
|
||||
|
||||
double AppSettings::returnSpeed() const
|
||||
{
|
||||
return m_settings.value("OneMotorControl/ReturnSpeed", kDefaultReturnSpeed).toDouble();
|
||||
}
|
||||
|
||||
void AppSettings::setReturnSpeed(double value)
|
||||
{
|
||||
m_settings.setValue("OneMotorControl/ReturnSpeed", value);
|
||||
}
|
||||
|
||||
int AppSettings::gonggaShanRecordPort() const
|
||||
{
|
||||
return m_settings.value("GonggaShanRecordCtl/Port", kDefaultGonggaShanRecordPort).toInt();
|
||||
}
|
||||
|
||||
void AppSettings::setGonggaShanRecordPort(int value)
|
||||
{
|
||||
m_settings.setValue("GonggaShanRecordCtl/Port", value);
|
||||
}
|
||||
|
||||
AppSettings::HyperimgDisplayMode AppSettings::hyperimgDisplayMode() const
|
||||
{
|
||||
return static_cast<HyperimgDisplayMode>(
|
||||
m_settings.value("Display/HyperimgDisplayMode",
|
||||
static_cast<int>(kDefaultHyperimgDisplayMode)).toInt());
|
||||
}
|
||||
|
||||
void AppSettings::setHyperimgDisplayMode(HyperimgDisplayMode mode)
|
||||
{
|
||||
m_settings.setValue("Display/HyperimgDisplayMode", static_cast<int>(mode));
|
||||
}
|
||||
|
||||
@ -34,6 +34,38 @@ public:
|
||||
// 深度相机数据保存路径
|
||||
QString depthCameraDataFolder() const;
|
||||
void setDepthCameraDataFolder(const QString& path);
|
||||
|
||||
QString FiberImagerDataFolder() const;
|
||||
void setFiberImagerDataFolder(const QString& path);
|
||||
|
||||
QString rgbCameraDataFolder() const;
|
||||
void setRgbCameraDataFolder(const QString& path);
|
||||
|
||||
// RGB相机文件名
|
||||
QString rgbCameraFileName() const;
|
||||
void setRgbCameraFileName(const QString& name);
|
||||
|
||||
QString fodisCameraFileName() const;
|
||||
void setFodisCameraFileName(const QString& name);
|
||||
|
||||
// 扫描速度
|
||||
double scanSpeed() const;
|
||||
void setScanSpeed(double value);
|
||||
|
||||
// 返回速度
|
||||
double returnSpeed() const;
|
||||
void setReturnSpeed(double value);
|
||||
|
||||
// 贡嘎山记录端口
|
||||
int gonggaShanRecordPort() const;
|
||||
void setGonggaShanRecordPort(int value);
|
||||
|
||||
// 图像显示模式枚举
|
||||
enum class HyperimgDisplayMode { Full, Waterfall };
|
||||
|
||||
// 图像显示模式
|
||||
HyperimgDisplayMode hyperimgDisplayMode() const;
|
||||
void setHyperimgDisplayMode(HyperimgDisplayMode mode);
|
||||
// 在此处添加更多参数的 getter/setter ...
|
||||
|
||||
private:
|
||||
@ -51,4 +83,8 @@ private:
|
||||
static const int kDefaultGain;
|
||||
static const QString kDefaultSLRDataFolder;
|
||||
static const QString kDefaultDepthCameraDataFolder;
|
||||
static const double kDefaultScanSpeed;
|
||||
static const double kDefaultReturnSpeed;
|
||||
static const int kDefaultGonggaShanRecordPort;
|
||||
static const HyperimgDisplayMode kDefaultHyperimgDisplayMode;
|
||||
};
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "CaptureCoordinator.h"
|
||||
#include <algorithm>
|
||||
|
||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
@ -458,7 +459,9 @@ OneMotionCaptureCoordinator::OneMotionCaptureCoordinator(
|
||||
connect(this, &OneMotionCaptureCoordinator::stopRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::stop_record);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet,
|
||||
this, &OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
this, &OneMotionCaptureCoordinator::handleHyperImagerCaptureComplete);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberNotMeet,
|
||||
this, &OneMotionCaptureCoordinator::handleHyperImagerCaptureComplete);
|
||||
}
|
||||
|
||||
OneMotionCaptureCoordinator::~OneMotionCaptureCoordinator()
|
||||
@ -467,7 +470,7 @@ OneMotionCaptureCoordinator::~OneMotionCaptureCoordinator()
|
||||
this, &OneMotionCaptureCoordinator::handleMotorStoped);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathLine)
|
||||
void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathLine)//这个函数为啥被调用了2次?
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
@ -497,13 +500,12 @@ void OneMotionCaptureCoordinator::stopStepMotion()
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
void OneMotionCaptureCoordinator::handleHyperImagerCaptureComplete()
|
||||
{
|
||||
emit stopMotorSignal(0);
|
||||
m_isHypercamStopRecord = true;
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::getLocBeforeStart()
|
||||
@ -528,6 +530,10 @@ void OneMotionCaptureCoordinator::getLocBeforeStart()
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
|
||||
std::vector<double> pos;
|
||||
pos.push_back(0);
|
||||
m_locBeforeStart = pos;
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::move2LocBeforeStart()
|
||||
@ -563,25 +569,30 @@ bool OneMotionCaptureCoordinator::saveToCsv(const QString& filename)
|
||||
|
||||
void OneMotionCaptureCoordinator::handleMotorStoped(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
// 记录位置信息
|
||||
m_pathLine.stopPosition = pos;
|
||||
m_pathLine.timestamp2 = QDateTime::currentDateTime();
|
||||
|
||||
//光谱仪停止采集,马达回到初始位置
|
||||
emit stopRecordHSISignal();
|
||||
if (m_cameraCtrl != nullptr)
|
||||
if (m_isHypercamStopRecord == true)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
move2LocBeforeStart();
|
||||
m_isHypercamStopRecord = false;
|
||||
|
||||
// emit sequenceComplete last: the slot connected to it may delete this object,
|
||||
// so no member access is allowed after this point.
|
||||
emit sequenceComplete(0);
|
||||
// 记录位置信息
|
||||
m_pathLine.stopPosition = pos;
|
||||
m_pathLine.timestamp2 = QDateTime::currentDateTime();
|
||||
|
||||
//光谱仪停止采集,马达回到初始位置
|
||||
emit stopRecordHSISignal();
|
||||
if (m_cameraCtrl != nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
move2LocBeforeStart();
|
||||
|
||||
emit sequenceCompleteSignal_hyperImagerStopRecord(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sequenceCompleteSignal_motorBack2Origin(0);
|
||||
}
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureComplete(double index)
|
||||
@ -711,3 +722,513 @@ void DarkAndWhiteCaptureCoordinator::handleCaptureComplete(double index)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
}
|
||||
|
||||
|
||||
TwoMotor1PosCoordinator::TwoMotor1PosCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_isMoving2Target(false)
|
||||
, m_isMoving2Origin(false)
|
||||
, m_targetX(0)
|
||||
, m_targetY(0)
|
||||
, m_speedX(0)
|
||||
, m_speedY(0)
|
||||
, m_actualX(0)
|
||||
, m_actualY(0)
|
||||
, m_retryTimesX(0)
|
||||
, m_retryTimesY(0)
|
||||
, m_xReached(false)
|
||||
, m_yReached(false)
|
||||
{
|
||||
//因为IrisMultiMotorController::moveTo有多个重载版本,所以使用信号槽连接时需要使用SIGNAL和SLOT宏来指定参数类型,避免编译器无法推断出正确的函数签名。
|
||||
//connect(this, &TwoMotor1PosCoordinator::moveTo, m_motorCtrl, &IrisMultiMotorController::moveTo);//这行代码会报错,因为moveTo有多个重载版本,编译器无法推断出正确的函数签名。
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)), m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveTo(const std::vector<double>, const std::vector<double>, int)), m_motorCtrl, SLOT(moveTo(const std::vector<double>, const std::vector<double>, int)));
|
||||
|
||||
|
||||
connect(this, &TwoMotor1PosCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal, this, &TwoMotor1PosCoordinator::handlePositionReached);
|
||||
}
|
||||
|
||||
TwoMotor1PosCoordinator::~TwoMotor1PosCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TwoMotor1PosCoordinator::moveToTarget(double xTarget, double yTarget, double xSpeed, double ySpeed)
|
||||
{
|
||||
m_isMoving2Target = true;
|
||||
m_isMoving2Origin = false;
|
||||
|
||||
moveToTargetPrivate(xTarget, yTarget, xSpeed, ySpeed);
|
||||
}
|
||||
|
||||
void TwoMotor1PosCoordinator::back2origin()
|
||||
{
|
||||
m_isMoving2Target = false;
|
||||
m_isMoving2Origin = true;
|
||||
|
||||
moveToTargetPrivate(0, 0, m_speedX, m_speedY);
|
||||
}
|
||||
|
||||
void TwoMotor1PosCoordinator::moveToTargetPrivate(double xTarget, double yTarget, double xSpeed, double ySpeed)
|
||||
{
|
||||
m_targetX = xTarget;
|
||||
m_targetY = yTarget;
|
||||
m_speedX = xSpeed;
|
||||
m_speedY = ySpeed;
|
||||
|
||||
m_xReached = false;
|
||||
m_yReached = false;
|
||||
m_retryTimesX = 0;
|
||||
m_retryTimesY = 0;
|
||||
|
||||
std::vector<double> loc = { m_targetX, m_targetY };
|
||||
std::vector<double> speed = { m_speedX, m_speedY };
|
||||
|
||||
std::cout << "TwoMotor1PosCoordinator: moving to (" << m_targetX << ", " << m_targetY << ")" << std::endl;
|
||||
emit moveTo(loc, speed, 1000);
|
||||
}
|
||||
|
||||
void TwoMotor1PosCoordinator::handlePositionReached(int motorID, double pos)
|
||||
{
|
||||
if (!m_isMoving2Target && !m_isMoving2Origin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double errorRateThreshold = 5;
|
||||
if (motorID == 0)
|
||||
{
|
||||
m_actualX = pos;
|
||||
|
||||
double errorRate = getErrorRate(m_targetX, m_actualX);
|
||||
|
||||
if (errorRate > errorRateThreshold && m_retryTimesX < m_retryLimit)
|
||||
{
|
||||
m_retryTimesX++;
|
||||
std::cout << "X motor retry " << m_retryTimesX << ", target: " << m_targetX << ", actual: " << m_actualX << std::endl;
|
||||
emit moveTo(0, m_targetX, m_speedX, 1000);
|
||||
return;
|
||||
}
|
||||
m_retryTimesX = 0;
|
||||
m_xReached = true;
|
||||
|
||||
std::cout << "X motor reached: " << m_actualX << std::endl;
|
||||
}
|
||||
else if (motorID == 1)
|
||||
{
|
||||
m_actualY = pos;
|
||||
|
||||
double errorRate = getErrorRate(m_targetY, m_actualY);
|
||||
if (errorRate > errorRateThreshold && m_retryTimesY < m_retryLimit)
|
||||
{
|
||||
m_retryTimesY++;
|
||||
std::cout << "Y motor retry " << m_retryTimesY << ", target: " << m_targetY << ", actual: " << m_actualY << std::endl;
|
||||
emit moveTo(1, m_targetY, m_speedY, 1000);
|
||||
return;
|
||||
}
|
||||
m_retryTimesY = 0;
|
||||
m_yReached = true;
|
||||
|
||||
std::cout << "Y motor reached: " << m_actualY << std::endl;
|
||||
}
|
||||
|
||||
if (checkArrival())
|
||||
{
|
||||
std::cout << "TwoMotor1PosCoordinator: Arrived at (" << m_actualX << ", " << m_actualY << ")" << std::endl;
|
||||
|
||||
if (m_isMoving2Origin)
|
||||
{
|
||||
m_isMoving2Origin = false;
|
||||
|
||||
emit back2OriginSignal();
|
||||
}
|
||||
|
||||
if (m_isMoving2Target)
|
||||
{
|
||||
m_isMoving2Target = false;
|
||||
|
||||
emit ArrivalSignal(m_actualX, m_actualY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double TwoMotor1PosCoordinator::getErrorRate(double targetLoc, double actualLoc)
|
||||
{
|
||||
double targetLocTmp;
|
||||
if (targetLoc == 0)
|
||||
{
|
||||
targetLocTmp = 0.001;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetLocTmp = targetLoc;
|
||||
}
|
||||
double errorRate = abs(targetLoc - actualLoc) / targetLocTmp * 100;
|
||||
|
||||
return errorRate;
|
||||
}
|
||||
|
||||
bool TwoMotor1PosCoordinator::checkArrival()
|
||||
{
|
||||
return m_xReached && m_yReached;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
OneMotionCoordinator::OneMotionCoordinator(IrisMultiMotorController* motorCtrl, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_targetPosition(0)
|
||||
, m_speed(0)
|
||||
, m_actualPosition(0)
|
||||
, m_isMoving(false)
|
||||
, m_retryTimes(0)
|
||||
, m_reached(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)), m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal, this, &OneMotionCoordinator::handlePositionReached);
|
||||
}
|
||||
|
||||
OneMotionCoordinator::~OneMotionCoordinator()
|
||||
{
|
||||
}
|
||||
|
||||
void OneMotionCoordinator::moveToTarget(double position, double speed)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_targetPosition = position;
|
||||
m_speed = speed;
|
||||
m_retryTimes = 0;
|
||||
m_reached = false;
|
||||
m_isMoving = true;
|
||||
|
||||
qDebug() << "OneMotionCoordinator: moving to" << position;
|
||||
emit moveTo(0, position, speed, 1000);
|
||||
}
|
||||
|
||||
void OneMotionCoordinator::handlePositionReached(int motorID, double position)
|
||||
{
|
||||
if (!m_isMoving || motorID != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_actualPosition = position;
|
||||
|
||||
double errorRate = getErrorRate(m_targetPosition, m_actualPosition);
|
||||
|
||||
if (errorRate > 5 && m_retryTimes < m_retryLimit)
|
||||
{
|
||||
m_retryTimes++;
|
||||
qDebug() << "OneMotionCoordinator: retry" << m_retryTimes << ", target:" << m_targetPosition << ", actual:" << m_actualPosition;
|
||||
emit moveTo(0, m_targetPosition, m_speed, 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
m_retryTimes = 0;
|
||||
m_reached = true;
|
||||
m_isMoving = false;
|
||||
|
||||
qDebug() << "OneMotionCoordinator: Arrived at" << m_actualPosition;
|
||||
|
||||
emit sequenceComplete(0);
|
||||
emit ArrivalSignal(m_actualPosition);
|
||||
}
|
||||
|
||||
double OneMotionCoordinator::getErrorRate(double targetLoc, double actualLoc)
|
||||
{
|
||||
double targetLocTmp;
|
||||
if (targetLoc == 0)
|
||||
{
|
||||
targetLocTmp = 0.001;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetLocTmp = targetLoc;
|
||||
}
|
||||
double errorRate = abs(targetLoc - actualLoc) / targetLocTmp * 100;
|
||||
|
||||
return errorRate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------
|
||||
OneMotorMultiPosCoordinator::OneMotorMultiPosCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_currentPos(0)
|
||||
, m_isRunning(false)
|
||||
, m_isZeroing(false)
|
||||
{
|
||||
//这些信号槽是按照逻辑顺序的
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
|
||||
connect(this, &OneMotorMultiPosCoordinator::zeroStart,
|
||||
m_motorCtrl, &IrisMultiMotorController::zeroStart);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &OneMotorMultiPosCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &OneMotorMultiPosCoordinator::handleError);
|
||||
|
||||
connect(this, &OneMotorMultiPosCoordinator::startAutoExposureSignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::auto_exposure);
|
||||
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::autoExposureSignal,
|
||||
this, &OneMotorMultiPosCoordinator::onAutoExposureFinished);
|
||||
//connect(m_cameraCtrl, &ImagerOperationBase::captureFailed,
|
||||
// this, &OneMotorMultiPosCoordinator::handleError);
|
||||
}
|
||||
|
||||
OneMotorMultiPosCoordinator::~OneMotorMultiPosCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::startStepMotion(double speed, std::vector<double> locations)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (locations.empty())
|
||||
{
|
||||
emit sequenceComplete(1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
emit errorOccurred("Sequence already running");
|
||||
return;
|
||||
}
|
||||
m_locations = locations;
|
||||
|
||||
m_counter = 0;
|
||||
|
||||
m_positionData.clear();
|
||||
|
||||
m_speed = speed;
|
||||
m_iStepIntervalRealTime = 1;
|
||||
|
||||
m_isRunning = true;
|
||||
m_isZeroing = true;
|
||||
|
||||
// 先执行归零操作
|
||||
emit zeroStart(0);
|
||||
qDebug() << "OneMotorMultiPosCoordinator::startStepMotion: Zeroing started.";
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::startMotionSequence()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
m_isZeroing = false;
|
||||
qDebug() << "OneMotorMultiPosCoordinator::startMotionSequence: Zeroing complete. Starting motion sequence.";
|
||||
|
||||
processNextPosition();
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::handleZeroComplete(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning || !m_isZeroing) return;
|
||||
|
||||
// 归零完成,开始分步运动
|
||||
startMotionSequence();
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::stopStepMotion()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit sequenceStopped();
|
||||
}
|
||||
|
||||
QVector<PositionsLogData> OneMotorMultiPosCoordinator::getAllPositionData() const
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
return m_positionData;
|
||||
}
|
||||
|
||||
bool OneMotorMultiPosCoordinator::saveToCsv(const QString& filename)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << "Timestamp,targetPosition,ActualPosition,exposureTime\n";
|
||||
|
||||
for (const auto& data : m_positionData)
|
||||
{
|
||||
out << data.timestamp.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< QString::number(data.targetPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualPosition, 'f', 4) << ","
|
||||
<< QString::number(data.exposureTime, 'f', 4) << "\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::handlePositionReached(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
// 如果正在等待归零完成,调用归零完成处理
|
||||
if (m_isZeroing)
|
||||
{
|
||||
handleZeroComplete(motorID, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
//验证马达运动位置是否到达指定位置
|
||||
//if (pos != m_currentPos) return;
|
||||
|
||||
// 记录位置信息
|
||||
PositionsLogData data;
|
||||
data.targetPosition = m_currentPos;
|
||||
data.actualPosition = pos;
|
||||
data.timestamp = QDateTime::currentDateTime();
|
||||
data.frameRate = 10;
|
||||
m_positionData.append(data);
|
||||
|
||||
// 开始自动曝光
|
||||
m_cameraCtrl->setFramerate(m_positionData.last().frameRate);
|
||||
emit startAutoExposureSignal();
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::onAutoExposureFinished(double exposureTime)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
// 在保证曝光质量的前提下,尽量提高帧率,帧率下限为10hz
|
||||
|
||||
m_positionData.last().exposureTime = exposureTime;
|
||||
|
||||
std::cout << "第" << m_counter << "次曝光:" << std::endl;
|
||||
std::cout << "目标位置:" << m_positionData.last().targetPosition << std::endl;
|
||||
std::cout << "实际位置:" << m_positionData.last().actualPosition << std::endl;
|
||||
std::cout << "曝光时间:" << m_positionData.last().exposureTime << std::endl;
|
||||
|
||||
// 如果曝光时间过低(< 2ms),基于曝光时间计算新的帧率并重新进行自动曝光
|
||||
if (exposureTime < 2.0) {
|
||||
int currentFrameRate = m_positionData.last().frameRate;
|
||||
|
||||
// 基于曝光时间计算理论最大帧率:fps = 1000 / exposureTime(ms)
|
||||
// 乘以0.8作为安全系数,确保不会达到极限
|
||||
int newFrameRate = static_cast<int>((1000.0 / exposureTime) * 0.8);
|
||||
|
||||
// 设置合理的帧率范围:[currentFrameRate + 10, min(200, newFrameRate)]
|
||||
newFrameRate = std::max(currentFrameRate + 10, newFrameRate);
|
||||
newFrameRate = std::min(newFrameRate, 200);
|
||||
|
||||
m_positionData.last().frameRate = newFrameRate;
|
||||
|
||||
std::cout << "曝光时间过低,基于曝光时间计算新帧率:" << currentFrameRate << " -> " << newFrameRate << std::endl;
|
||||
std::cout << "(曝光时间 " << exposureTime << "ms -> 理论最大帧率 " << (1000.0 / exposureTime) << "fps)" << std::endl;
|
||||
|
||||
m_cameraCtrl->setFramerate(newFrameRate);
|
||||
}
|
||||
|
||||
processNextPosition();
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::handleError(const QString& error)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit errorOccurred(error);
|
||||
}
|
||||
|
||||
void OneMotorMultiPosCoordinator::processNextPosition()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
if (m_locations.empty())
|
||||
{
|
||||
m_isRunning = false;
|
||||
emit sequenceComplete(0);
|
||||
|
||||
// 找到曝光时间最大的那组数据
|
||||
double maxExposureTime = 0.0;
|
||||
double maxFrameRate = 10;
|
||||
for (const auto& data : m_positionData) {
|
||||
if (data.exposureTime > maxExposureTime) {
|
||||
maxExposureTime = data.exposureTime;
|
||||
maxFrameRate = data.frameRate;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "自动曝光完成,使用最大曝光时间参数:" << std::endl;
|
||||
std::cout << " 曝光时间:" << maxExposureTime << "ms" << std::endl;
|
||||
std::cout << " 帧率:" << maxFrameRate << "Hz" << std::endl;
|
||||
|
||||
emit hyperAutoExposureDoneSignal(maxExposureTime, maxFrameRate);
|
||||
m_cameraCtrl->setIntegrationTime(maxExposureTime);
|
||||
m_cameraCtrl->setFramerate(maxFrameRate);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentPos = m_locations.front();
|
||||
m_locations.erase(m_locations.begin());
|
||||
|
||||
emit moveTo(0, m_currentPos, m_speed, 1000);
|
||||
}
|
||||
|
||||
@ -141,10 +141,11 @@ public slots:
|
||||
void startStepMotion(OneMotionCapturePathLine pathLine);
|
||||
void stopStepMotion();
|
||||
|
||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||
void handleHyperImagerCaptureComplete();
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int);
|
||||
void sequenceCompleteSignal_hyperImagerStopRecord(int);
|
||||
void sequenceCompleteSignal_motorBack2Origin(int);
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveSignal(int, bool, double, int);
|
||||
@ -165,6 +166,7 @@ private:
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
bool m_isHypercamStopRecord = false;
|
||||
|
||||
std::vector<double> m_locBeforeStart;
|
||||
void getLocBeforeStart();
|
||||
@ -211,3 +213,162 @@ private:
|
||||
void getLocBeforeStart();
|
||||
void move2LocBeforeStart();
|
||||
};
|
||||
|
||||
|
||||
class TwoMotor1PosCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TwoMotor1PosCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~TwoMotor1PosCoordinator();
|
||||
|
||||
public slots:
|
||||
void moveToTarget(double xTarget, double yTarget, double xSpeed, double ySpeed);
|
||||
void back2origin();
|
||||
|
||||
signals:
|
||||
void ArrivalSignal(double xPos, double yPos);
|
||||
void back2OriginSignal();
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveTo(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
private slots:
|
||||
void handlePositionReached(int motorID, double pos);
|
||||
|
||||
private:
|
||||
void moveToTargetPrivate(double xTarget, double yTarget, double xSpeed, double ySpeed);
|
||||
double getErrorRate(double targetLoc, double actualLoc);
|
||||
bool checkArrival();
|
||||
void move2Origin();
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isMoving2Target;
|
||||
bool m_isMoving2Origin;
|
||||
|
||||
double m_targetX;
|
||||
double m_targetY;
|
||||
double m_speedX;
|
||||
double m_speedY;
|
||||
|
||||
double m_actualX;
|
||||
double m_actualY;
|
||||
|
||||
int m_retryLimit = 3;
|
||||
int m_retryTimesX;
|
||||
int m_retryTimesY;
|
||||
|
||||
bool m_xReached;
|
||||
bool m_yReached;
|
||||
};
|
||||
|
||||
class OneMotionCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OneMotionCoordinator(IrisMultiMotorController* motorCtrl, QObject* parent = nullptr);
|
||||
~OneMotionCoordinator();
|
||||
|
||||
public slots:
|
||||
void moveToTarget(double position, double speed);
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int status);
|
||||
void ArrivalSignal(double position);
|
||||
void moveTo(int, double, double, int);
|
||||
|
||||
private slots:
|
||||
void handlePositionReached(int motorID, double position);
|
||||
|
||||
private:
|
||||
bool checkArrival();
|
||||
double getErrorRate(double targetLoc, double actualLoc);
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
double m_targetPosition;
|
||||
double m_speed;
|
||||
double m_actualPosition;
|
||||
bool m_isMoving;
|
||||
|
||||
int m_retryLimit = 3;
|
||||
int m_retryTimes;
|
||||
bool m_reached;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 数据记录结构体
|
||||
struct PositionsLogData
|
||||
{
|
||||
double targetPosition; // 目标位置
|
||||
double actualPosition; // 实际马达位置
|
||||
double frameRate; // 帧率
|
||||
double exposureTime; //
|
||||
QDateTime timestamp; // 时间戳
|
||||
|
||||
PositionsLogData(double target = 0, double actual = 0.0, double exposure = 0.0, double frameRate = 10.0)
|
||||
: targetPosition(target), actualPosition(actual), frameRate(frameRate),
|
||||
exposureTime(exposure ), timestamp(QDateTime::currentDateTime()) {
|
||||
}
|
||||
};
|
||||
|
||||
// 协调控制器
|
||||
class OneMotorMultiPosCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OneMotorMultiPosCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~OneMotorMultiPosCoordinator();
|
||||
|
||||
QVector<PositionsLogData> getAllPositionData() const;
|
||||
bool saveToCsv(const QString& filename);
|
||||
|
||||
public slots:
|
||||
void startStepMotion(double speed, std::vector<double> locations);
|
||||
void stopStepMotion();
|
||||
|
||||
signals:
|
||||
void progressChanged(int progress);
|
||||
void sequenceComplete(int status);
|
||||
void sequenceStopped();
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void startAutoExposureSignal();
|
||||
void zeroStart(int motorID);
|
||||
|
||||
void hyperAutoExposureDoneSignal(double exposureTime, double frameRate);
|
||||
|
||||
private slots:
|
||||
void handlePositionReached(int motorID, double pos);
|
||||
void onAutoExposureFinished(double exposureTime);
|
||||
void handleError(const QString& error);
|
||||
void handleZeroComplete(int motorID, double pos);
|
||||
|
||||
private:
|
||||
void processNextPosition();
|
||||
void startMotionSequence();
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
QVector<PositionsLogData> m_positionData;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
double m_currentPos;
|
||||
bool m_isRunning;
|
||||
double m_speed;
|
||||
|
||||
int m_iStepInterval;
|
||||
int m_iStepIntervalRealTime;
|
||||
int m_counter;
|
||||
bool m_isZeroing;
|
||||
|
||||
std::vector<double> m_locations;
|
||||
};
|
||||
|
||||
@ -32,6 +32,7 @@ void CommunicationViaTCP::onNewConnection()
|
||||
m_bConnected = true;
|
||||
m_tcpSocket = m_tcpServer->nextPendingConnection();
|
||||
connect(m_tcpSocket, SIGNAL(disconnected()), this, SLOT(onTcpSocketDisconnected()));
|
||||
connect(m_tcpSocket, &QTcpSocket::readyRead, this, &CommunicationViaTCP::receiveData);
|
||||
|
||||
emit connected();
|
||||
}
|
||||
@ -49,6 +50,32 @@ void CommunicationViaTCP::onTcpSocketDisconnected()
|
||||
m_tcpSocket->deleteLater();
|
||||
}
|
||||
|
||||
void CommunicationViaTCP::receiveData()
|
||||
{
|
||||
if (!isConnected())
|
||||
{
|
||||
qWarning() << "receiveData: No client connected";
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray data = m_tcpSocket->readAll();
|
||||
if (data.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
int position = QString::fromUtf8(data).toInt(&ok);
|
||||
if (ok)
|
||||
{
|
||||
qDebug() << "Received position:" << position;
|
||||
emit positionReceived(position);
|
||||
} else
|
||||
{
|
||||
qWarning() << "Failed to parse position data:" << data;
|
||||
}
|
||||
}
|
||||
|
||||
int CommunicationViaTCP::sendCommand(const QString cmd)
|
||||
{
|
||||
if (!isConnected()) {
|
||||
|
||||
@ -37,9 +37,11 @@ namespace MotorParams {
|
||||
|
||||
public Q_SLOTS:
|
||||
void onNewConnection();
|
||||
void receiveData();
|
||||
void onTcpSocketDisconnected();
|
||||
|
||||
signals:
|
||||
void commandSendResult(int bytesWritten, const QString& error = QString());
|
||||
void positionReceived(int position);
|
||||
};
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ DepthCameraWindow::DepthCameraWindow(QWidget* parent)
|
||||
connect(ui.closeDepthCamera_btn, &QPushButton::clicked, this, &DepthCameraWindow::closeDepthCamera);
|
||||
|
||||
connect(this, &DepthCameraWindow::openDepthCameraSignal, m_DepthCameraOperation, &DepthCameraOperation::OpenDepthCamera);
|
||||
connect(this, &DepthCameraWindow::OpenDepthCamera_getDepthValueSignal, m_DepthCameraOperation, &DepthCameraOperation::OpenDepthCamera_getDepthValue);
|
||||
|
||||
connect(m_DepthCameraOperation, &DepthCameraOperation::CamOpenedSignal, this, &DepthCameraWindow::onCamOpened);
|
||||
connect(m_DepthCameraOperation, &DepthCameraOperation::CamClosedSignal, this, &DepthCameraWindow::onCamClosed);
|
||||
@ -66,6 +67,14 @@ void DepthCameraWindow::openDepthCamera()
|
||||
}
|
||||
}
|
||||
|
||||
void DepthCameraWindow::OpenDepthCamera_getDepthValue()
|
||||
{
|
||||
if (!m_DepthCameraOperation->getRecordStatus())
|
||||
{
|
||||
emit OpenDepthCamera_getDepthValueSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void DepthCameraWindow::onCamOpened()
|
||||
{
|
||||
ui.openDepthCamera_btn->setEnabled(false);
|
||||
@ -279,6 +288,274 @@ void DepthCameraOperation::OpenDepthCamera()
|
||||
m_pipe = nullptr;
|
||||
}
|
||||
|
||||
void DepthCameraOperation::OpenDepthCamera_getDepthValue()
|
||||
{
|
||||
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();
|
||||
|
||||
config->enableVideoStream(OB_STREAM_DEPTH, 640, 480, 15, OB_FORMAT_Y16);
|
||||
config->enableVideoStream(OB_STREAM_COLOR, 640, 480, 15, OB_FORMAT_YUYV);
|
||||
config->setFrameAggregateOutputMode(OB_FRAME_AGGREGATE_OUTPUT_ALL_TYPE_FRAME_REQUIRE);
|
||||
|
||||
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(m_captureIntervalMilliseconds);
|
||||
}
|
||||
|
||||
auto pointCloud = std::make_shared<ob::PointCloudFilter>();
|
||||
|
||||
int frameIndex = 0;
|
||||
record = true;
|
||||
QString fileNamePrefix = AppSettings::instance().depthCameraDataFolder() + QDir::separator() + "Gemini336L";
|
||||
|
||||
// 增量平均所需的变量
|
||||
cv::Mat avgRgbMat, avgDepthMat;
|
||||
int avgFrameCount = 0;
|
||||
|
||||
for (size_t i = 0; i < m_averageNumberOfTimes; i++)
|
||||
{
|
||||
if(frameIndex==0)
|
||||
{
|
||||
emit CamOpenedSignal();
|
||||
std::cout << "Start recording..." << std::endl;
|
||||
}
|
||||
|
||||
auto frameSet = m_pipe->waitForFrameset(m_captureIntervalMilliseconds);
|
||||
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());
|
||||
|
||||
// 增量平均计算
|
||||
if (avgFrameCount == 0)
|
||||
{
|
||||
avgRgbMat = cv::Mat::zeros(rgbMat.size(), CV_32FC3);
|
||||
avgDepthMat = cv::Mat::zeros(depthMat.size(), CV_32F);
|
||||
}
|
||||
avgFrameCount++;
|
||||
cv::Mat rgbFloat;
|
||||
rgbMat.convertTo(rgbFloat, CV_32FC3);
|
||||
avgRgbMat = avgRgbMat + (rgbFloat - avgRgbMat) / avgFrameCount;
|
||||
|
||||
cv::Mat depthMatTmp;
|
||||
depthMat.convertTo(depthMatTmp, CV_32F);
|
||||
avgDepthMat = avgDepthMat + (depthMatTmp - avgDepthMat) / avgFrameCount;
|
||||
|
||||
|
||||
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();
|
||||
|
||||
frameIndex++;
|
||||
}
|
||||
m_pipe->stop();
|
||||
|
||||
// 对累积平均后的图像进行处理
|
||||
double depthValue;
|
||||
if (avgFrameCount > 0)
|
||||
{
|
||||
cv::Mat avgRgbResult, avgDepthResult;
|
||||
avgRgbMat.convertTo(avgRgbResult, CV_8UC3);
|
||||
avgDepthMat.convertTo(avgDepthResult, CV_16UC1);
|
||||
|
||||
// 保存平均结果图像
|
||||
std::vector<int> pngParams;
|
||||
pngParams.push_back(cv::IMWRITE_PNG_COMPRESSION);
|
||||
pngParams.push_back(0);
|
||||
pngParams.push_back(cv::IMWRITE_PNG_STRATEGY);
|
||||
pngParams.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
|
||||
cv::imwrite(getTestFilePath("_AvgRGB_").toStdString(), avgRgbResult, pngParams);
|
||||
cv::imwrite(getTestFilePath("_AvgDepth_").toStdString(), avgDepthResult, pngParams);
|
||||
|
||||
// 创建掩膜,排除深度值为0的区域
|
||||
cv::Mat mask = avgDepthResult != 0;
|
||||
|
||||
// 保存掩膜
|
||||
cv::Mat mask8U;
|
||||
mask.convertTo(mask8U, CV_8UC1, 255.0);
|
||||
std::string maskName = fileNamePrefix.toStdString() + "_Mask_" + std::to_string(mask.cols) + "x" + std::to_string(mask.rows) + ".png";
|
||||
cv::imwrite(maskName, mask8U, pngParams);
|
||||
|
||||
if (m_depthAlgorithm == 0)
|
||||
{
|
||||
depthValue = processAveragedImages_roiAvg(avgDepthResult, mask);
|
||||
}
|
||||
else if (m_depthAlgorithm == 1)
|
||||
{
|
||||
depthValue = processAveragedImages_depthRangePercentage(avgDepthResult, mask);
|
||||
}
|
||||
else if (m_depthAlgorithm == 2)
|
||||
{
|
||||
depthValue = processAveragedImages_segmentation(avgRgbResult, avgDepthResult, mask);
|
||||
}
|
||||
}
|
||||
|
||||
//计算平均深度值
|
||||
std::cout << "Depth value: " << depthValue << " m" << std::endl;
|
||||
emit DepthValueSignal(depthValue);
|
||||
|
||||
delete m_pipe;
|
||||
m_pipe = nullptr;
|
||||
|
||||
record = false;
|
||||
}
|
||||
|
||||
double DepthCameraOperation::processAveragedImages_roiAvg(const cv::Mat& avgDepthResult, const cv::Mat& mask)
|
||||
{
|
||||
//裁剪边缘区域
|
||||
int cropRows = static_cast<int>(avgDepthResult.rows * (1 - m_percentageOfEffectiveArea) / 2);
|
||||
int cropCols = static_cast<int>(avgDepthResult.cols * (1 - m_percentageOfEffectiveArea) / 2);
|
||||
cv::Rect roi(cropCols, cropRows,
|
||||
avgDepthResult.cols - 2 * cropCols,
|
||||
avgDepthResult.rows - 2 * cropRows);
|
||||
cv::Mat depthRoi = avgDepthResult(roi);
|
||||
cv::Mat maskRoi = mask(roi);
|
||||
//计算平均深度值,使用掩膜排除深度值为0的区域
|
||||
cv::Scalar meanDepth = cv::mean(depthRoi, maskRoi);
|
||||
double depthValue = meanDepth[0] / 1000.0; // 转换为米
|
||||
|
||||
return depthValue;
|
||||
}
|
||||
|
||||
double DepthCameraOperation::processAveragedImages_depthRangePercentage(const cv::Mat& avgDepthResult, const cv::Mat& mask)
|
||||
{
|
||||
// 找出最大最小值
|
||||
double minVal, maxVal;
|
||||
cv::minMaxLoc(avgDepthResult, &minVal, &maxVal, nullptr, nullptr, mask);
|
||||
|
||||
// 检查是否有有效数据
|
||||
if (minVal == std::numeric_limits<double>::max())
|
||||
{
|
||||
std::cout << "Warning: No valid depth pixels found in masked region!" << std::endl;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// 返回最小值乘以m_depthRangePercentage
|
||||
double depthValue = minVal * m_depthRangePercentage / 1000.0; // 转换为米
|
||||
|
||||
return depthValue;
|
||||
}
|
||||
|
||||
double DepthCameraOperation::processAveragedImages_segmentation(const cv::Mat& avgRgbResult, const cv::Mat& avgDepthResult, const cv::Mat& mask)
|
||||
{
|
||||
// 转换到 HSV 颜色空间进行植被分割
|
||||
cv::Mat hsvMat;
|
||||
cv::cvtColor(avgRgbResult, hsvMat, cv::COLOR_RGB2HSV);
|
||||
|
||||
// 分离通道
|
||||
std::vector<cv::Mat> hsvChannels;
|
||||
cv::split(hsvMat, hsvChannels);
|
||||
cv::Mat hue = hsvChannels[0];
|
||||
cv::Mat sat = hsvChannels[1];
|
||||
cv::Mat val = hsvChannels[2];
|
||||
|
||||
// 定义绿色植被的Hue范围 (OpenCV中Hue范围是0-180,实际绿色约35-90度)
|
||||
// 扩展范围以覆盖不同光照条件下的绿色
|
||||
cv::Mat hueMask1 = (hue >= 35) & (hue <= 85);
|
||||
cv::Mat satMask = sat > 30; // 饱和度阈值,去除灰色区域
|
||||
cv::Mat valMask = val > 50; // 亮度阈值,去除过暗区域
|
||||
|
||||
// 组合条件生成植被掩膜
|
||||
cv::Mat vmask;
|
||||
cv::bitwise_and(hueMask1, satMask, vmask);
|
||||
cv::bitwise_and(vmask, valMask, vmask);
|
||||
|
||||
// 结合深度掩膜,计算两个mask的交集
|
||||
cv::Mat combinedMask;
|
||||
cv::bitwise_and(mask, vmask, combinedMask);
|
||||
|
||||
// 保存 vmask 和 combinedMask 到 exe 所在文件夹的文件夹
|
||||
cv::Mat vmask8U, combinedMask8U;
|
||||
vmask.convertTo(vmask8U, CV_8UC1, 255.0);
|
||||
combinedMask.convertTo(combinedMask8U, CV_8UC1, 255.0);
|
||||
cv::imwrite(getTestFilePath("vmask").toStdString(), vmask8U);
|
||||
cv::imwrite(getTestFilePath("combinedMask").toStdString(), combinedMask8U);
|
||||
|
||||
// 计算 avgRgbResult 在 combinedMask 区域内的平均深度值
|
||||
double depthValue = 0.0;
|
||||
if (cv::countNonZero(combinedMask) > 0) {
|
||||
cv::Scalar meanDepth = cv::mean(avgDepthResult, combinedMask);
|
||||
depthValue = meanDepth[0] / 1000.0; // 转换为米
|
||||
} else {
|
||||
std::cout << "Warning: No valid pixels in combined mask!" << std::endl;
|
||||
}
|
||||
|
||||
return depthValue;
|
||||
}
|
||||
|
||||
QString DepthCameraOperation::getTestFilePath(const QString& fileName)
|
||||
{
|
||||
QString testFolder = QCoreApplication::applicationDirPath() + QDir::separator() + "depthValueTest";
|
||||
QDir().mkpath(testFolder);
|
||||
QString timestamp = QString::number(QDateTime::currentMSecsSinceEpoch());
|
||||
return testFolder + QDir::separator() + fileName + "_" + timestamp + ".png";
|
||||
}
|
||||
|
||||
void DepthCameraOperation::saveDepthFrame(const std::shared_ptr<ob::DepthFrame> depthFrame, const uint32_t frameIndex, std::string fileNamePrefix_)
|
||||
{
|
||||
std::vector<int> params;
|
||||
|
||||
@ -5,8 +5,10 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QImage>
|
||||
#include <Qthread>
|
||||
#include <QThread>
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
//#include <QLabel>
|
||||
#include <QFileDialog>
|
||||
|
||||
@ -35,6 +37,11 @@ public:
|
||||
|
||||
void setCaptureInterval(int captureIntervalSeconds);
|
||||
|
||||
void setDepthAlgorithm(int depthAlgorithm) { m_depthAlgorithm = depthAlgorithm; }
|
||||
void setAverageNumberOfTimes(double averageNumberOfTimes) { m_averageNumberOfTimes = averageNumberOfTimes; }
|
||||
void setPercentageOfEffectiveArea(double percentageOfEffectiveArea) { m_percentageOfEffectiveArea = percentageOfEffectiveArea; }
|
||||
void setDepthRangePercentage(double depthRangePercentage) { m_depthRangePercentage = depthRangePercentage; }
|
||||
|
||||
private:
|
||||
ob::Pipeline* m_pipe;
|
||||
cv::Mat frame;
|
||||
@ -50,13 +57,26 @@ private:
|
||||
|
||||
int m_captureIntervalMilliseconds;
|
||||
|
||||
int m_depthAlgorithm;
|
||||
double m_averageNumberOfTimes;
|
||||
double m_percentageOfEffectiveArea;
|
||||
double m_depthRangePercentage;
|
||||
|
||||
double processAveragedImages_roiAvg(const cv::Mat& avgDepthResult, const cv::Mat& mask);
|
||||
double processAveragedImages_depthRangePercentage(const cv::Mat& avgDepthResult, const cv::Mat& mask);
|
||||
double processAveragedImages_segmentation(const cv::Mat& avgRgbResult, const cv::Mat& avgDepthResult, const cv::Mat& mask);
|
||||
|
||||
QString getTestFilePath(const QString& fileName);
|
||||
|
||||
public slots:
|
||||
void OpenDepthCamera();
|
||||
void OpenDepthCamera_getDepthValue();
|
||||
void OpenDepthCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
||||
void CloseDepthCamera();
|
||||
|
||||
signals:
|
||||
void PlotSignal();
|
||||
void DepthValueSignal(double depthValue);
|
||||
|
||||
void CamOpenedSignal();
|
||||
void CamClosedSignal();
|
||||
@ -77,6 +97,7 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void openDepthCamera();
|
||||
void OpenDepthCamera_getDepthValue();
|
||||
void onCamOpened();
|
||||
void closeDepthCamera();
|
||||
void onCamClosed();
|
||||
@ -84,12 +105,12 @@ public Q_SLOTS:
|
||||
void onSelectDataFolder();
|
||||
|
||||
signals:
|
||||
void openDepthCameraSignal();
|
||||
void PlotDepthImageSignal();
|
||||
void DepthCamClosedSignal();
|
||||
void openDepthCameraSignal();
|
||||
void OpenDepthCamera_getDepthValueSignal();
|
||||
void PlotDepthImageSignal();
|
||||
void DepthCamClosedSignal();
|
||||
|
||||
private:
|
||||
Ui::DepthCameraClass ui;
|
||||
QThread* m_DepthCameraThread;
|
||||
|
||||
};
|
||||
|
||||
138
HPPA/DepthValueLogger.cpp
Normal file
138
HPPA/DepthValueLogger.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
#include "stdafx.h"
|
||||
#include "DepthValueLogger.h"
|
||||
#include "AppSettings.h"
|
||||
#include "fileOperation.h"
|
||||
#include <QDir>
|
||||
|
||||
DepthValueLogger& DepthValueLogger::instance()
|
||||
{
|
||||
static DepthValueLogger instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
DepthValueLogger::DepthValueLogger()
|
||||
{
|
||||
}
|
||||
|
||||
DepthValueLogger::~DepthValueLogger()
|
||||
{
|
||||
}
|
||||
|
||||
QString DepthValueLogger::getLogFilePath(DepthValueType type) const
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
QString directory = QString::fromStdString(fileOperation->getDirectoryOfExe());
|
||||
QString basePath = directory + QDir::separator() + "3DPlantPhenotypeScenario";
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DepthValueType::Plant:
|
||||
return basePath + QDir::separator() + "plant_depth_values.txt";
|
||||
case DepthValueType::LiftingPlatform:
|
||||
return basePath + QDir::separator() + "LiftingPlatform_depth_values.txt";
|
||||
default:
|
||||
return basePath + QDir::separator() + "plant_depth_values.txt";
|
||||
}
|
||||
}
|
||||
|
||||
void DepthValueLogger::appendDepthValue(double depthValue, DepthValueType type)
|
||||
{
|
||||
QString filePath = getLogFilePath(type);
|
||||
QFileInfo fileInfo(filePath);
|
||||
QDir dir = fileInfo.absoluteDir();
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkpath(".");
|
||||
}
|
||||
|
||||
QFile file(filePath);
|
||||
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz");
|
||||
out << timestamp << "\t" << QString::number(depthValue, 'f', 6) << "\n";
|
||||
file.close();
|
||||
|
||||
emit depthValueLogged(depthValue, type);
|
||||
}
|
||||
}
|
||||
|
||||
double DepthValueLogger::readLatestDepthValue(DepthValueType type) const
|
||||
{
|
||||
QString filePath = getLogFilePath(type);
|
||||
QFile file(filePath);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double latestValue = 0.0;
|
||||
QTextStream in(&file);
|
||||
|
||||
while (!in.atEnd())
|
||||
{
|
||||
QString line = in.readLine().trimmed();
|
||||
if (line.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList parts = line.split("\t");
|
||||
if (parts.size() >= 2)
|
||||
{
|
||||
latestValue = parts.last().toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
return latestValue;
|
||||
}
|
||||
|
||||
bool DepthValueLogger::hasValidDepthValue(DepthValueType type) const
|
||||
{
|
||||
QString filePath = getLogFilePath(type);
|
||||
QFile file(filePath);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasValue = false;
|
||||
QTextStream in(&file);
|
||||
|
||||
while (!in.atEnd())
|
||||
{
|
||||
QString line = in.readLine().trimmed();
|
||||
if (!line.isEmpty())
|
||||
{
|
||||
hasValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
return hasValue;
|
||||
}
|
||||
|
||||
void DepthValueLogger::appendPlantDepthValue(double depthValue)
|
||||
{
|
||||
appendDepthValue(depthValue, DepthValueType::Plant);
|
||||
}
|
||||
|
||||
void DepthValueLogger::appendLiftingPlatformDepthValue(double depthValue)
|
||||
{
|
||||
appendDepthValue(depthValue, DepthValueType::LiftingPlatform);
|
||||
}
|
||||
|
||||
double DepthValueLogger::readLatestPlantDepthValue() const
|
||||
{
|
||||
return readLatestDepthValue(DepthValueType::Plant);
|
||||
}
|
||||
|
||||
double DepthValueLogger::readLatestLiftingPlatformDepthValue() const
|
||||
{
|
||||
return readLatestDepthValue(DepthValueType::LiftingPlatform);
|
||||
}
|
||||
41
HPPA/DepthValueLogger.h
Normal file
41
HPPA/DepthValueLogger.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef DEPTH_VALUE_LOGGER_H
|
||||
#define DEPTH_VALUE_LOGGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
enum class DepthValueType
|
||||
{
|
||||
Plant,
|
||||
LiftingPlatform
|
||||
};
|
||||
|
||||
class DepthValueLogger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static DepthValueLogger& instance();
|
||||
|
||||
void appendDepthValue(double depthValue, DepthValueType type);
|
||||
double readLatestDepthValue(DepthValueType type) const;
|
||||
bool hasValidDepthValue(DepthValueType type) const;
|
||||
|
||||
void appendPlantDepthValue(double depthValue);
|
||||
void appendLiftingPlatformDepthValue(double depthValue);
|
||||
double readLatestPlantDepthValue() const;
|
||||
double readLatestLiftingPlatformDepthValue() const;
|
||||
|
||||
signals:
|
||||
void depthValueLogged(double value, DepthValueType type);
|
||||
|
||||
private:
|
||||
DepthValueLogger();
|
||||
~DepthValueLogger();
|
||||
DepthValueLogger(const DepthValueLogger&) = delete;
|
||||
DepthValueLogger& operator=(const DepthValueLogger&) = delete;
|
||||
|
||||
QString getLogFilePath(DepthValueType type) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
61
HPPA/FiberSpectrometerOperationBase.h
Normal file
61
HPPA/FiberSpectrometerOperationBase.h
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// Created by tangchao on 2022/1/11.
|
||||
//
|
||||
|
||||
#ifndef OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H
|
||||
#define OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H
|
||||
|
||||
|
||||
#include "ZZ_Types.h"
|
||||
|
||||
using namespace ZZ_MISCDEF;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class FiberSpectrometerOperationBase
|
||||
{
|
||||
|
||||
public:
|
||||
// FiberSpectrometerOperationBase();
|
||||
// ~FiberSpectrometerOperationBase();
|
||||
|
||||
virtual void connectFiberSpectrometer(QString& sn, QString& pixelCount, QString& wavelengthInfo) = 0;
|
||||
virtual void disconnectFiberSpectrometer() = 0;
|
||||
virtual void getDeviceAttribute(DeviceAttribute& deviceAttribute) = 0;
|
||||
virtual void getDeviceInfo(DeviceInfo& deviceInfo) = 0;
|
||||
|
||||
virtual void setExposureTime(int iExposureTimeInMS) = 0;
|
||||
|
||||
virtual void getExposureTime(int &iExposureTimeInMS) = 0;
|
||||
virtual void getDeviceTemperature(float &fTemperature) = 0;
|
||||
|
||||
virtual void singleShot(DataFrame &dfData) = 0;
|
||||
|
||||
// typedef struct coeffs
|
||||
// {
|
||||
// ZZ_U32 coeffsCounter;
|
||||
// double coeffs[100];
|
||||
// }coeffsFrame;
|
||||
virtual void getNonlinearityCoeffs(coeffsFrame &coeffs) = 0;
|
||||
|
||||
|
||||
// ZZ_S32 GetMaxValue(ZZ_S32 * dark, int number) = 0;
|
||||
|
||||
DataFrame m_IntegratingSphereData;
|
||||
DataFrame m_DarkData;
|
||||
protected:
|
||||
ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
private:
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void recordDark(QString path) = 0;
|
||||
virtual void recordTarget2csv(int recordTimes, QString path) = 0;
|
||||
virtual void autoExpose() = 0;
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
|
||||
};
|
||||
|
||||
#endif //OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>557</width>
|
||||
<height>432</height>
|
||||
<width>582</width>
|
||||
<height>465</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -154,7 +154,7 @@ QSlider::handle:horizontal:pressed {
|
||||
border: 1px solid #2f6bff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -168,7 +168,7 @@ QSlider::handle:horizontal:pressed {
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="titlebarWidget" native="true">
|
||||
@ -242,23 +242,11 @@ QSlider::handle:horizontal:pressed {
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="2,3">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="connectFocusModule_widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #connectFocusModule_widget
|
||||
@ -274,85 +262,185 @@ QRadioButton
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>连接调焦模块</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>线性平台</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="motorPort_comboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="ultrasound_radioButton">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="ultrasoundPort_comboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="is_new_version_radioButton">
|
||||
<property name="text">
|
||||
<string>新版</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>107</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="connectMotor_btn">
|
||||
<property name="text">
|
||||
<string>连接线性平台</string>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>连接调焦线性平台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="is_new_version_radioButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>新版</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QStackedWidget" name="stackedWidget_connetcParm">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout_12">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QGridLayout" name="gridLayout_13">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>线性平台</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="motorPort_comboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="ultrasound_radioButton">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="ultrasoundPort_comboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="connectMotor_btn">
|
||||
<property name="text">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>状态</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="motor_state_label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel#motor_state_label
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -368,151 +456,147 @@ QRadioButton
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="moveto_btn">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="move2_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="add_btn">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="updateCurrentLocation_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新实时位置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="addStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="currentLocation_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>null</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="subtract_btn">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="max_btn">
|
||||
<property name="text">
|
||||
<string>max</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<item row="0" column="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>调整线性平台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="updateCurrentLocation_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新实时位置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="subtract_btn">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="add_btn">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="move2_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="moveto_btn">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="currentLocation_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>null</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="max_btn">
|
||||
<property name="text">
|
||||
<string>max</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="addStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QWidget" name="controlFocus_widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #controlFocus_widget
|
||||
@ -521,53 +605,53 @@ QRadioButton
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>采样率</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="sample_ratio_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>20</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QProgressBar {
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>采样数</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="sample_ratio_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>20</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="autoFocus_btn">
|
||||
<property name="text">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QProgressBar {
|
||||
border: 2px solid #08FACE; /* 边框颜色和宽度 */
|
||||
border-radius: 8px; /* 圆角 */
|
||||
background-color: #eee; /* 未完成部分颜色 */
|
||||
@ -579,37 +663,29 @@ QRadioButton
|
||||
background-color: #08FACE; /* 渐变色进度块 */
|
||||
border-radius: 8px; /* 保持和整体圆角一致 */
|
||||
}</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="autoFocus_btn">
|
||||
<property name="text">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>171</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="manualFocus_btn">
|
||||
<property name="text">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>手动调焦</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="manualFocus_btn">
|
||||
<property name="text">
|
||||
<string>手动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
128
HPPA/FodisWindow.cpp
Normal file
128
HPPA/FodisWindow.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
#include "FodisWindow.h"
|
||||
#include "JinspFiberImagerConfig.h"
|
||||
|
||||
FodisWindow::FodisWindow(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
m_FiberImagerThread = new QThread();
|
||||
m_JinspFiberImagerOperation = new JinspFiberImager(false, JinspFiberImagerConfig::instance().portName().toStdString(), "JINSP");
|
||||
connect(m_JinspFiberImagerOperation, &JinspFiberImager::spectalCaptured, this, &FodisWindow::spectalCaptured);
|
||||
connect(m_JinspFiberImagerOperation, &JinspFiberImager::startExposureSignal, this, &FodisWindow::startExposureSignal);
|
||||
connect(m_JinspFiberImagerOperation, &JinspFiberImager::exposureCompleteSignal, this, &FodisWindow::exposureCompleteSignal);
|
||||
m_JinspFiberImagerOperation->moveToThread(m_FiberImagerThread);
|
||||
m_FiberImagerThread->start();
|
||||
|
||||
connect(ui.open_btn, &QPushButton::clicked, this, &FodisWindow::openFiberImager);
|
||||
connect(ui.close_btn, &QPushButton::clicked, this, &FodisWindow::closeFiberImager);
|
||||
|
||||
connect(this, &FodisWindow::openFiberImagerSignal, m_JinspFiberImagerOperation, &JinspFiberImager::OpenFiberImagerAndRecord);
|
||||
|
||||
//connect(m_JinspFiberImagerOperation, &JinspFiberImager::CamOpenedSignal, this, &FodisWindow::onCamOpened);
|
||||
//connect(m_JinspFiberImagerOperation, &JinspFiberImager::CamClosedSignal, this, &FodisWindow::onCamClosed);
|
||||
|
||||
//connect(m_JinspFiberImagerOperation, &JinspFiberImager::PlotSignal, this, &FodisWindow::PlotSpectralSignal);
|
||||
//connect(m_JinspFiberImagerOperation, &JinspFiberImager::CamClosedSignal, this, &FodisWindow::FiberImagerClosedSignal);
|
||||
|
||||
connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
|
||||
|
||||
connect(ui.fileNameLineEdit, &QLineEdit::textChanged, this, &FodisWindow::onFileNameChanged);
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
FodisWindow::~FodisWindow()
|
||||
{
|
||||
m_FiberImagerThread->quit();
|
||||
m_FiberImagerThread->wait();
|
||||
delete m_JinspFiberImagerOperation;
|
||||
m_JinspFiberImagerOperation = nullptr;
|
||||
}
|
||||
|
||||
void FodisWindow::loadSettings()
|
||||
{
|
||||
ui.dataFolderLineEdit->setText(AppSettings::instance().FiberImagerDataFolder());
|
||||
ui.fileNameLineEdit->setText(AppSettings::instance().fodisCameraFileName());
|
||||
}
|
||||
|
||||
void FodisWindow::onSelectDataFolder()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
QString::fromLocal8Bit("选择数据保存路径"),
|
||||
ui.dataFolderLineEdit->text());
|
||||
|
||||
setDataFolder(dir);
|
||||
}
|
||||
|
||||
void FodisWindow::setDataFolder(QString dir)
|
||||
{
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
ui.dataFolderLineEdit->setText(dir);
|
||||
AppSettings::instance().setFiberImagerDataFolder(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void FodisWindow::setFileName(QString name)
|
||||
{
|
||||
ui.fileNameLineEdit->setText(name);
|
||||
AppSettings::instance().setFodisCameraFileName(name);
|
||||
}
|
||||
|
||||
void FodisWindow::onFileNameChanged(const QString& text)
|
||||
{
|
||||
AppSettings::instance().setFodisCameraFileName(text);
|
||||
}
|
||||
|
||||
void FodisWindow::setCaptureInterval(int captureIntervalSeconds)
|
||||
{
|
||||
m_JinspFiberImagerOperation->setCaptureInterval(captureIntervalSeconds);
|
||||
}
|
||||
|
||||
void FodisWindow::openFiberImager()
|
||||
{
|
||||
openFiberImager_expose_record("pos_null");
|
||||
}
|
||||
|
||||
void FodisWindow::openFiberImager_expose_record(QString posInfo, QString dataFolder)
|
||||
{
|
||||
setDataFolder(dataFolder);
|
||||
setFileName(posInfo);
|
||||
|
||||
if (!m_JinspFiberImagerOperation->getRecordStatus())
|
||||
{
|
||||
QString folder = AppSettings::instance().FiberImagerDataFolder();
|
||||
QDir dir(folder);
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkpath(".");
|
||||
}
|
||||
QString eventPrefix = posInfo.isEmpty() ? "default" : posInfo;
|
||||
QString dateStr = QDateTime::currentDateTime().toString("yyyy-MM-dd_HH-mm-ss");
|
||||
QString m_qstrFullFileName = folder + QDir::separator() + dateStr + "_" + eventPrefix + "_fodis_data.dat";
|
||||
|
||||
emit openFiberImagerSignal(m_qstrFullFileName);
|
||||
}
|
||||
}
|
||||
|
||||
void FodisWindow::onCamOpened()
|
||||
{
|
||||
ui.open_btn->setEnabled(false);
|
||||
ui.close_btn->setEnabled(true);
|
||||
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||
}
|
||||
|
||||
void FodisWindow::closeFiberImager()
|
||||
{
|
||||
m_JinspFiberImagerOperation->disconnectFiberSpectrometer();
|
||||
}
|
||||
|
||||
void FodisWindow::onCamClosed()
|
||||
{
|
||||
ui.open_btn->setEnabled(true);
|
||||
ui.close_btn->setEnabled(false);
|
||||
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("打 开"));
|
||||
}
|
||||
60
HPPA/FodisWindow.h
Normal file
60
HPPA/FodisWindow.h
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QImage>
|
||||
#include <Qthread>
|
||||
#include <QDir>
|
||||
//#include <QLabel>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <iostream>
|
||||
#include "ui_fodis.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "JinspFiberImager.h"
|
||||
|
||||
class FodisWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FodisWindow(QWidget* parent = nullptr);
|
||||
~FodisWindow();
|
||||
|
||||
void setDataFolder(QString dir);
|
||||
void setCaptureInterval(int captureIntervalSeconds);
|
||||
|
||||
public Q_SLOTS:
|
||||
void openFiberImager();
|
||||
void openFiberImager_expose_record(QString posInfo, QString dataFolder = "");
|
||||
void onCamOpened();
|
||||
void closeFiberImager();
|
||||
void onCamClosed();
|
||||
|
||||
void onSelectDataFolder();
|
||||
void onFileNameChanged(const QString& text);
|
||||
void setFileName(QString name);
|
||||
|
||||
signals:
|
||||
void openFiberImagerSignal(QString filePath);
|
||||
void PlotSpectralSignal();
|
||||
void FiberImagerClosedSignal();
|
||||
|
||||
void spectalCaptured(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void startExposureSignal();
|
||||
void exposureCompleteSignal(int exposureTime);
|
||||
|
||||
private:
|
||||
Ui::FodisWindow ui;
|
||||
QThread* m_FiberImagerThread;
|
||||
|
||||
JinspFiberImager* m_JinspFiberImagerOperation;
|
||||
|
||||
void loadSettings();
|
||||
};
|
||||
1046
HPPA/GonggaShanRecordCtl.cpp
Normal file
1046
HPPA/GonggaShanRecordCtl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
349
HPPA/GonggaShanRecordCtl.h
Normal file
349
HPPA/GonggaShanRecordCtl.h
Normal file
@ -0,0 +1,349 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <vector>
|
||||
#include <QPointer>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDir>
|
||||
#include <QStateMachine>
|
||||
#include <QSignalTransition>
|
||||
#include <QFinalState>
|
||||
#include <QTimer>
|
||||
#include <QSerialPort>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "ui_gonggashanCtl.h"
|
||||
|
||||
#include "CommunicationViaTCP.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
class GsbGpsParse;
|
||||
class GsbGpsReader;
|
||||
|
||||
// ============ 执行阶段枚举 ============
|
||||
enum class GonggaShanExecPhase {
|
||||
Idle, // 空闲
|
||||
Preparation, // 准备阶段
|
||||
HyperExposure, // 高光谱传感器曝光
|
||||
FiberExposure, // 光纤光谱仪曝光
|
||||
GpsAcquisition, // 获取GPS位置
|
||||
MotorCalc, // 计算马达速度
|
||||
DataCollection, // 开始采集:高光谱、FODIS、rgb相机
|
||||
Completed // 完成
|
||||
};
|
||||
|
||||
// ============ 任务执行器 ============
|
||||
class GonggashanTaskExecutor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GonggashanTaskExecutor(QObject* parent = nullptr);
|
||||
~GonggashanTaskExecutor();
|
||||
|
||||
bool isRunning() const { return m_machine && m_machine->isRunning() && !m_machine->configuration().isEmpty(); }
|
||||
|
||||
public slots:
|
||||
void start(const QString& posInfo);
|
||||
void stop();
|
||||
|
||||
void onHyperExposureComplete(double exposureTime, double frameRate);
|
||||
void onFiberExposureComplete(double exposureTime);
|
||||
void onGpsAcquired(double latitude, double longitude, double altitude);
|
||||
void onMotorSpeedCalculated(double rotationSpeed);
|
||||
void onRcordComplete();
|
||||
|
||||
signals:
|
||||
void hyperAutoExposureSignal_gonggashan();
|
||||
void fiberExposureRecordSignal(QString posInfo, QString dataFolder);
|
||||
void gpsAcquisitionSignal();
|
||||
void motorSpeedSignal(double speed);
|
||||
void startCollectionSignal(const QString& posInfo, const QString& gpsData, double m_motorRotationSpeed, QString dataFolder);
|
||||
|
||||
void calculateMotorSpeedSignal(double hyperFrameRate);
|
||||
|
||||
void finished(bool success);
|
||||
void errorOccurred(const QString& error);
|
||||
|
||||
// ---- 以下为状态机内部信号,供 transition 使用 ----
|
||||
void taskStartRequested(const QString& posInfo);
|
||||
void preparationComplete();
|
||||
void hyperExposureDone();
|
||||
void fiberExposureDone();
|
||||
void gpsAcquisitionDone();
|
||||
void motorSpeedDone();
|
||||
void dataCollectionDone();
|
||||
void stopRequested();
|
||||
|
||||
protected:
|
||||
virtual bool preparationImpl();
|
||||
virtual bool hyperExposureImpl(int exposureTime);
|
||||
virtual bool fiberExposureImpl(int exposureTime);
|
||||
virtual bool gpsAcquisitionImpl(double lat, double lon, double alt);
|
||||
virtual bool motorCalcImpl();
|
||||
|
||||
private slots:
|
||||
void onFinalStateEntered();
|
||||
|
||||
private:
|
||||
void buildStateMachine();
|
||||
QState* currentState() const;
|
||||
void leavePhase(QState* state);
|
||||
|
||||
QString m_posInfo;
|
||||
QString m_gpsData;
|
||||
double m_motorRotationSpeed = 0.0;
|
||||
double m_hyperExposureTime = 0;
|
||||
double m_hyperFrameRate = 0;
|
||||
double m_fiberExposureTime = 0;
|
||||
bool m_stopRequested = false;
|
||||
QString m_todayDataFolder; // 当天日期的数据保存文件夹
|
||||
|
||||
// Qt State Machine
|
||||
QStateMachine* m_machine = nullptr;
|
||||
QState* m_hyperExposureState = nullptr;
|
||||
QState* m_fiberExposureState = nullptr;
|
||||
QState* m_gpsAcquisitionState = nullptr;
|
||||
QState* m_motorCalcState = nullptr;
|
||||
QState* m_dataCollectionState = nullptr;
|
||||
QFinalState* m_finalState = nullptr;
|
||||
};
|
||||
|
||||
class GonggaShanRecordCtl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GonggaShanRecordCtl(QWidget* parent = nullptr);
|
||||
~GonggaShanRecordCtl();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onFiberImagerStartExposureSignal();
|
||||
void onRcordFinished();
|
||||
void onFiberImagerExposureCompleteSignal(int exposureTime);
|
||||
|
||||
Q_SIGNALS:
|
||||
void gpsAcquisitionDoneSignal_gonggashan(double lat, double lon, double alt);
|
||||
|
||||
void calculateMotorSpeedDoneSignal_gonggashan(double rotationSpeed);
|
||||
|
||||
void hyperAutoExposureSignal_gonggashan();
|
||||
void hyperAutoExposureDoneSignal_gonggashan(double exposureTime, double frameRate);
|
||||
|
||||
void fiberExposureRecordSignal_gonggashan(QString posInfo, QString dataFolder);
|
||||
void fiberExposureDoneSignal_gonggashan(double exposureTime);
|
||||
|
||||
void startRcordSignal_gonggashan(const QString& posInfo, const QString& gpsData, double m_motorRotationSpeed, QString dataFolder);
|
||||
void recordFinishedSignal_gonggashan();
|
||||
|
||||
private Q_SLOTS:
|
||||
void startListen();
|
||||
void stopListen();
|
||||
|
||||
void startRecord(int position);
|
||||
|
||||
// GonggashanTaskExecutor 反馈槽
|
||||
void onTaskExecutorFinished(bool success);
|
||||
|
||||
void onGpsAcquisition();
|
||||
void onCalculateMotorSpeed(double hyperFrameRate);
|
||||
|
||||
private:
|
||||
void logStatus(const QString& message, bool isHearderBlankLine = false, bool isTailBlankLine = false);
|
||||
|
||||
Ui::gongga_control ui;
|
||||
QPointer<MotorParams::CommunicationViaTCP> tcpServer6005;
|
||||
GonggashanTaskExecutor* m_taskExecutor; // 新增
|
||||
QString m_logFilePath;
|
||||
QFile m_logFile;
|
||||
QTextStream m_logStream;
|
||||
|
||||
// GPS 串口读取器
|
||||
GsbGpsReader* m_gpsReader = nullptr;
|
||||
};
|
||||
|
||||
// ============ USB GPS NMEA-0183 解析器 (G6301, COM17) ============
|
||||
class GsbGpsParse : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// GPS数据有效性状态
|
||||
enum class GpsStatus {
|
||||
Invalid, // 无效或未定位
|
||||
Valid, // 有效定位
|
||||
Differential // 差分定位
|
||||
};
|
||||
|
||||
// GPS解析数据结构
|
||||
struct GpsData {
|
||||
QString rawNmea; // 原始NMEA语句
|
||||
QString utcTime; // UTC时间 (HHMMSS.SSS)
|
||||
QString utcDate; // UTC日期 (DDMMYY)
|
||||
double latitude = 0.0; // 纬度 (十进制度)
|
||||
double longitude = 0.0; // 经度 (十进制度)
|
||||
double altitude = 0.0; // 高程 (米)
|
||||
int satelliteCount = 0; // 卫星数目
|
||||
GpsStatus status = GpsStatus::Invalid; // 定位状态
|
||||
bool isValid = false; // 综合有效性
|
||||
bool hasGga = false; // 是否已收到GPGGA语句
|
||||
bool hasRmc = false; // 是否已收到GPRMC语句
|
||||
};
|
||||
|
||||
explicit GsbGpsParse(QObject* parent = nullptr);
|
||||
~GsbGpsParse() = default;
|
||||
|
||||
// 设置最小卫星数目要求 (默认4颗)
|
||||
void setMinSatelliteCount(int count) { m_minSatelliteCount = count; }
|
||||
int minSatelliteCount() const { return m_minSatelliteCount; }
|
||||
|
||||
// 解析单条NMEA语句
|
||||
bool parseNmeaSentence(const QString& sentence);
|
||||
|
||||
// 获取当前解析的GPS数据
|
||||
const GpsData& gpsData() const { return m_gpsData; }
|
||||
|
||||
// 检查GPS数据是否有效
|
||||
bool isGpsDataValid() const;
|
||||
|
||||
// 格式化输出
|
||||
QString toDisplayString() const;
|
||||
|
||||
// 获取状态描述
|
||||
QString statusDescription() const;
|
||||
|
||||
signals:
|
||||
void gpsDataUpdated(const GpsData& data);
|
||||
void gpsStatusChanged(bool isValid);
|
||||
|
||||
private:
|
||||
// 解析 $GPGGA - GPS定位数据
|
||||
bool parseGpgga(const QStringList& fields);
|
||||
|
||||
// 解析 $GPRMC - 推荐最小定位数据
|
||||
bool parseGprmc(const QStringList& fields);
|
||||
|
||||
// NMEA校验
|
||||
bool validateNmeaChecksum(const QString& sentence);
|
||||
|
||||
// 转换纬度格式 (DDMM.MMMM -> DD.DDDDD)
|
||||
double convertLatitude(const QString& degMin, const QString& direction);
|
||||
|
||||
// 转换经度格式 (DDDMM.MMMM -> DDD.DDDDD)
|
||||
double convertLongitude(const QString& degMin, const QString& direction);
|
||||
|
||||
// 检查数据有效性
|
||||
void validateData();
|
||||
|
||||
GpsData m_gpsData;
|
||||
int m_minSatelliteCount = 4; // 默认要求至少4颗卫星
|
||||
QString m_pendingTime;
|
||||
QString m_pendingDate;
|
||||
};
|
||||
|
||||
// ============ USB GPS 串口读取器 (G6301, COM17) ============
|
||||
class GsbGpsReader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GsbGpsReader(QObject* parent = nullptr);
|
||||
~GsbGpsReader();
|
||||
|
||||
// 打开指定串口
|
||||
bool openPort(const QString& portName, qint32 baudRate = 4800);
|
||||
|
||||
// 关闭串口
|
||||
void closePort();
|
||||
|
||||
// 串口是否打开
|
||||
bool isPortOpen() const;
|
||||
|
||||
// 获取GPS解析器(用于设置参数如最小卫星数)
|
||||
GsbGpsParse* gpsParser() { return &m_parser; }
|
||||
const GsbGpsParse* gpsParser() const { return &m_parser; }
|
||||
|
||||
// 获取GPS数据
|
||||
GsbGpsParse::GpsData currentGpsData() const;
|
||||
|
||||
// 等待有效GPS数据 (带超时)
|
||||
bool waitForValidData(int timeoutMs = 30000);
|
||||
|
||||
signals:
|
||||
void gpsDataReady(const GsbGpsParse::GpsData& data);
|
||||
void portOpened();
|
||||
void portClosed();
|
||||
void portError(const QString& error);
|
||||
|
||||
private slots:
|
||||
void onReadyRead();
|
||||
|
||||
private:
|
||||
GsbGpsParse m_parser;
|
||||
QSerialPort* m_serialPort;
|
||||
};
|
||||
|
||||
// ============ 帧率与旋转速度计算器 ============
|
||||
class FramerateRotateSpeedCal : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FramerateRotateSpeedCal(QObject* parent = nullptr);
|
||||
~FramerateRotateSpeedCal() = default;
|
||||
|
||||
// 设置参数
|
||||
void setAltitude(double altitude) { m_altitude = altitude; }
|
||||
void setVerticalFov(double fovDegrees) { m_verticalFov = fovDegrees; }
|
||||
void setVerticalPixels(int pixels) { m_verticalPixels = pixels; }
|
||||
void setFramerate(double framerate) { m_framerate = framerate; }
|
||||
|
||||
// 获取参数
|
||||
double altitude() const { return m_altitude; }
|
||||
double verticalFov() const { return m_verticalFov; }
|
||||
int verticalPixels() const { return m_verticalPixels; }
|
||||
double framerate() const { return m_framerate; }
|
||||
|
||||
// 计算垂直航向分辨率(地面分辨率)
|
||||
// 基于高度、视场角和像素个数
|
||||
// 公式: resolution = 2 * altitude * tan(FOV/2) / pixels
|
||||
double calculateVerticalGroundResolution();
|
||||
|
||||
// 计算速度
|
||||
// 基于帧率和垂直航向分辨率
|
||||
// 公式: speed = framerate * ground_resolution
|
||||
double calculateSpeed();
|
||||
|
||||
// 计算旋转速度
|
||||
// 基于高度和计算出的速度
|
||||
// 公式: rotation_speed = speed / (2 * PI * altitude)
|
||||
double calculateRotationSpeed();
|
||||
|
||||
// 一站式计算:设置参数后一次性计算所有结果
|
||||
double calculate(double altitude, double verticalFov, int verticalPixels, double framerate);
|
||||
|
||||
// 获取计算结果
|
||||
double groundResolution() const { return m_groundResolution; }
|
||||
double speed() const { return m_speed; }
|
||||
double rotationSpeed() const { return m_rotationSpeedDegPerSec; }
|
||||
|
||||
signals:
|
||||
void calculationCompleted(double groundResolution, double speed, double rotationSpeed);
|
||||
|
||||
private:
|
||||
double m_pi = 3.14159265358979323846; // 圆周率
|
||||
double m_altitude = 0.0; // 高度(米)
|
||||
double m_verticalFov = 0.0; // 垂直视场角(度)
|
||||
int m_verticalPixels = 0; // 垂直方向像素个数
|
||||
double m_framerate = 0.0; // 帧率(Hz)
|
||||
|
||||
double m_groundResolution = 0.0; // 垂直航向分辨率(米/像素)
|
||||
double m_speed = 0.0; // 速度(米/秒)
|
||||
double m_rotationSpeedDegPerSec = 0.0; // 旋转速度(度/秒)
|
||||
};
|
||||
296
HPPA/HPPA.cpp
296
HPPA/HPPA.cpp
@ -116,6 +116,7 @@ HPPA::HPPA(QWidget* parent)
|
||||
connect(this->ui.mSetting, SIGNAL(triggered()), this, SLOT(settingWindow()));
|
||||
connect(this->ui.action_about, SIGNAL(triggered()), this, SLOT(onAbout()));
|
||||
connect(this->ui.mActionOneMotorScenario, SIGNAL(triggered()), this, SLOT(createOneMotorScenario()));
|
||||
connect(this->ui.mActionGonggaRotatingPlatformScenario, SIGNAL(triggered()), this, SLOT(createGonggaRotatingPlatformScenario()));
|
||||
connect(this->ui.mActionPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(createPlantPhenotypeScenario()));
|
||||
connect(this->ui.mAction3DPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(create3DPlantPhenotypeScenario()));
|
||||
connect(this->ui.mActionMicroscopicMotionControlScenario, SIGNAL(triggered()), this, SLOT(createMicroscopicMotionControlScenario()));
|
||||
@ -454,6 +455,44 @@ HPPA::HPPA(QWidget* parent)
|
||||
m_carousel->addWidget(sa_SingleLensReflexCamera);
|
||||
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
QChartView * m_FiberImagerChartView = new QChartView();
|
||||
m_FiberImagerChartView->setRenderHint(QPainter::Antialiasing);
|
||||
m_FiberImagerChartView->setStyleSheet(R"(
|
||||
background: #0D1233;
|
||||
)");
|
||||
|
||||
m_FiberImagerChart = new QChart();
|
||||
m_FiberImagerChart->setBackgroundBrush(QColor("#0D1233"));
|
||||
m_FiberImagerChart->legend()->hide();
|
||||
//m_FiberImagerChart->setTitle("Simple line chart example");
|
||||
|
||||
QValueAxis* axisX_FiberImagerChart = new QValueAxis();
|
||||
QValueAxis* axisY_FiberImagerChart = new QValueAxis();
|
||||
setAxis(axisX, axisY);
|
||||
m_FiberImagerChart->addAxis(axisX_FiberImagerChart, Qt::AlignBottom);
|
||||
m_FiberImagerChart->addAxis(axisY_FiberImagerChart, Qt::AlignLeft);
|
||||
m_FiberImagerChartView->setChart(m_FiberImagerChart);
|
||||
|
||||
QScrollArea* sa_FiberImager = new QScrollArea();
|
||||
sa_FiberImager->setObjectName("sa_FiberImager");
|
||||
sa_FiberImager->setStyleSheet(R"(
|
||||
border: none;
|
||||
background-color: #0D1233;
|
||||
)");
|
||||
QGridLayout* gridLayout_sa_FiberImager = new QGridLayout(sa_FiberImager);
|
||||
gridLayout_sa_FiberImager->setSpacing(6);
|
||||
gridLayout_sa_FiberImager->setObjectName(QString::fromUtf8("gridLayout_sa_FiberImager"));
|
||||
gridLayout_sa_FiberImager->setVerticalSpacing(0);
|
||||
gridLayout_sa_FiberImager->setContentsMargins(0, 0, 0, 0);
|
||||
gridLayout_sa_FiberImager->addWidget(m_FiberImagerChartView);
|
||||
|
||||
m_carousel->addWidget(sa_FiberImager);
|
||||
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
m_carousel->play();
|
||||
|
||||
gridLayout_carouselContainer->addWidget(m_carousel);
|
||||
@ -620,6 +659,7 @@ void HPPA::initTimedDataCollection()
|
||||
m_tdc->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
m_tmc->connectMotor(false);
|
||||
m_omc_LiftingPlatform->connectMotor(false);
|
||||
|
||||
// 定时采集控制器 → 相机/马达
|
||||
connect(m_tdc, &TimedDataCollection::hyperCamParm, this, &HPPA::setTimedDataCollectionHyperCamParm);
|
||||
@ -627,6 +667,8 @@ void HPPA::initTimedDataCollection()
|
||||
connect(m_tdc, &TimedDataCollection::motorParm, this, &HPPA::setTimedDataCollectionMotorParm);
|
||||
connect(m_tdc, &TimedDataCollection::startRecordSignal, this, &HPPA::onStartTimedDataCollection);
|
||||
|
||||
connect(m_tdc, &TimedDataCollection::ObtainingDepthInformationSignals, this, &HPPA::onObtainTargetDepthInformation);
|
||||
|
||||
connect(m_tdc, &TimedDataCollection::switchHalogenLampSignal, m_pc3D, &PowerControl3D::switchHalogenLampPower);
|
||||
connect(m_tdc, &TimedDataCollection::switchD65LampSignal, m_pc3D, &PowerControl3D::switchD65LampPower);
|
||||
connect(m_tdc, &TimedDataCollection::switchSlrSignal, m_pc3D, &PowerControl3D::switchSlrPower);
|
||||
@ -635,6 +677,14 @@ void HPPA::initTimedDataCollection()
|
||||
connect(m_tmc, &TwoMotorControl::sequenceComplete, m_tdc, &TimedDataCollection::subTaskCompleted);
|
||||
connect(m_tmc, &TwoMotorControl::back2OriginSignal_TimedDataCollection, m_tdc, &TimedDataCollection::onBack2Origin);
|
||||
|
||||
//升降台
|
||||
connect(m_tdc, &TimedDataCollection::LiftingPlatformSignals, this, &HPPA::onLiftingPlatform);
|
||||
connect(m_omc_LiftingPlatform, &OneMotorControl_LiftingPlatform::sequenceComplete, m_tdc, &TimedDataCollection::subTaskCompleted);
|
||||
connect(m_omc_LiftingPlatform, &OneMotorControl_LiftingPlatform::back2OriginSignal_TimedDataCollection, m_tdc, &TimedDataCollection::onBack2Origin);
|
||||
|
||||
//自动调焦
|
||||
connect(m_tdc, &TimedDataCollection::AutoFocusSignals, this, &HPPA::onAutoFocus_TimedDataCollection);
|
||||
|
||||
m_tdc->show();
|
||||
}
|
||||
|
||||
@ -733,6 +783,24 @@ void HPPA::onStartTimedDataCollection(int camType)
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::onObtainTargetDepthInformation(SubTask subTaskParams)
|
||||
{
|
||||
m_tmc->run4_ObtainTargetDepthInfo(m_depthCameraWindow, subTaskParams.depthAlgorithm, subTaskParams.depthType, subTaskParams.depthInfoX, subTaskParams.depthInfoY,
|
||||
subTaskParams.averageNumberOfTimes, subTaskParams.percentageOfEffectiveArea, subTaskParams.depthRangePercentage);
|
||||
}
|
||||
|
||||
void HPPA::onLiftingPlatform(SubTask subTaskParams)
|
||||
{
|
||||
m_omc_LiftingPlatform->run();
|
||||
}
|
||||
|
||||
void HPPA::onAutoFocus_TimedDataCollection(SubTask subTaskParams)
|
||||
{
|
||||
m_tmc->setImager(m_Imager);
|
||||
//先使用subTaskParams.autoFocusMotorConfigFilePath替换文件oneMotorConfigFile_focus.cfg
|
||||
m_tmc->run5_AutoFocus(subTaskParams.autoFocusX, subTaskParams.autoFocusY);
|
||||
}
|
||||
|
||||
void HPPA::onTimedDataCollection()
|
||||
{
|
||||
QAction* checkedScenario = m_ScenarioActionGroup->checkedAction();
|
||||
@ -1011,6 +1079,11 @@ void HPPA::initControlTabwidget()
|
||||
m_omc->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_omc, QString::fromLocal8Bit("1轴马达控制"));
|
||||
|
||||
//1轴马达控制,上海3D植物表情,白板/调焦纸升降
|
||||
m_omc_LiftingPlatform = new OneMotorControl_LiftingPlatform();
|
||||
m_omc_LiftingPlatform->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_omc_LiftingPlatform, QString::fromLocal8Bit("白板/调焦升降台"));
|
||||
|
||||
//2轴马达控制
|
||||
m_tmc = new TwoMotorControl(this);
|
||||
//connect(m_tmc, SIGNAL(startLineNumSignal(int)), this, SLOT(onCreateTab(int)));
|
||||
@ -1018,11 +1091,90 @@ void HPPA::initControlTabwidget()
|
||||
m_tmc->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_tmc, QString::fromLocal8Bit("2轴控制"));
|
||||
|
||||
//贡嘎山定时采集
|
||||
m_gonggaShanRecordCtl = new GonggaShanRecordCtl(this);
|
||||
m_gonggaShanRecordCtl->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_gonggaShanRecordCtl, QString::fromLocal8Bit("触发采集"));
|
||||
|
||||
//is11
|
||||
m_fodisWindow = new FodisWindow(this);
|
||||
connect(m_fodisWindow, &FodisWindow::spectalCaptured, this, &HPPA::showFiberImagerSpectral);
|
||||
m_fodisWindow->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_fodisWindow, QString::fromLocal8Bit("FODIS"));
|
||||
|
||||
setupGonggashanAutoRecordConnection();
|
||||
|
||||
|
||||
// Connect ImageControl band change to re-render (m_ic created in initControlTabwidget)
|
||||
//connect(m_ic, SIGNAL(bandSelectionChanged(double, double, double)),
|
||||
// this, SLOT(onBandSelectionChanged(double, double, double)));
|
||||
}
|
||||
|
||||
void HPPA::setupGonggashanAutoRecordConnection()
|
||||
{
|
||||
connect(m_gonggaShanRecordCtl, &GonggaShanRecordCtl::hyperAutoExposureSignal_gonggashan, this, &HPPA::onGonggashanHyperAutoExposure);
|
||||
connect(m_omc, &OneMotorControl::hyperAutoExposureDoneSignal_gonggashan, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::hyperAutoExposureDoneSignal_gonggashan);
|
||||
|
||||
connect(m_gonggaShanRecordCtl, &GonggaShanRecordCtl::fiberExposureRecordSignal_gonggashan, this, &HPPA::onGonggashanFiberAutoExposureRecord);
|
||||
connect(m_fodisWindow, &FodisWindow::startExposureSignal, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::onFiberImagerStartExposureSignal);
|
||||
connect(m_fodisWindow, &FodisWindow::exposureCompleteSignal, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::onFiberImagerExposureCompleteSignal);
|
||||
connect(m_fodisWindow, &FodisWindow::exposureCompleteSignal, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::fiberExposureDoneSignal_gonggashan);
|
||||
|
||||
connect(m_gonggaShanRecordCtl, &GonggaShanRecordCtl::startRcordSignal_gonggashan, this, &HPPA::onGonggashanRecord);
|
||||
connect(m_omc, &OneMotorControl::sequenceCompleteSignal_hyperImagerStopRecord, m_rgbCameraControlWindow, &rgbCameraWindow::toggleTakePhoto);
|
||||
connect(m_omc, &OneMotorControl::sequenceCompleteSignal_hyperImagerStopRecord, m_fodisWindow, &FodisWindow::closeFiberImager);
|
||||
connect(m_omc, &OneMotorControl::sequenceCompleteSignal_hyperImagerStopRecord, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::recordFinishedSignal_gonggashan);
|
||||
//connect(m_omc, &OneMotorControl::sequenceComplete_motorBack2Origin, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::);
|
||||
}
|
||||
|
||||
void HPPA::onGonggashanHyperAutoExposure()
|
||||
{
|
||||
//连接马达和光谱仪
|
||||
m_omc->connectMotor(false);
|
||||
|
||||
if (!testImagerVality())
|
||||
{
|
||||
onconnect();
|
||||
}
|
||||
|
||||
m_omc->setImager(m_Imager);
|
||||
m_omc->multiPosHyperAutoExposure();
|
||||
}
|
||||
|
||||
void HPPA::onGonggashanFiberAutoExposureRecord(QString posInfo, QString dataFolder)
|
||||
{
|
||||
//设置数据存储路径和文件名
|
||||
m_fodisWindow->openFiberImager_expose_record(posInfo, dataFolder);
|
||||
}
|
||||
|
||||
void HPPA::onGonggashanRecord(const QString& posInfo, const QString& gpsData, double motorRotationSpeed, QString dataFolder)
|
||||
{
|
||||
//设置文件名
|
||||
//AppSettings::instance().setFrameRate(f);
|
||||
//AppSettings::instance().setIntegrationTime(e);
|
||||
AppSettings::instance().setDataFolder(dataFolder);
|
||||
|
||||
QString dateStr = QDateTime::currentDateTime().toString("yyyy-MM-dd_HH-mm-ss");
|
||||
//QString fi = AppSettings::instance().fileName() + "_" + dateStr;
|
||||
AppSettings::instance().setFileName(dateStr + "_" + posInfo);
|
||||
|
||||
this->frame_number->setText("100000");
|
||||
|
||||
//连接马达和光谱仪
|
||||
m_omc->connectMotor(false);
|
||||
m_omc->setScanSpeed(motorRotationSpeed);
|
||||
|
||||
if (!testImagerVality())
|
||||
{
|
||||
onconnect();
|
||||
}
|
||||
|
||||
onStartRecordStep1();
|
||||
|
||||
//采集rgb图像
|
||||
m_rgbCameraControlWindow->toggleTakePhoto();
|
||||
}
|
||||
|
||||
void HPPA::recordFromRobotArm(int fileCounter)
|
||||
{
|
||||
if (!testImagerVality())
|
||||
@ -1435,6 +1587,7 @@ void HPPA::createScenarioActionGroup()
|
||||
{
|
||||
m_ScenarioActionGroup = new QActionGroup(this);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionOneMotorScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionGonggaRotatingPlatformScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionPlantPhenotypeScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mAction3DPlantPhenotypeScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionMicroscopicMotionControlScenario);
|
||||
@ -1449,6 +1602,11 @@ void HPPA::createScenarioActionGroup()
|
||||
ui.mActionOneMotorScenario->setChecked(true);
|
||||
ui.mActionOneMotorScenario->trigger();
|
||||
}
|
||||
else if (lastSelectedAction == "mActionGonggaRotatingPlatformScenario")
|
||||
{
|
||||
ui.mActionGonggaRotatingPlatformScenario->setChecked(true);
|
||||
ui.mActionGonggaRotatingPlatformScenario->trigger();
|
||||
}
|
||||
else if (lastSelectedAction == "mActionPlantPhenotypeScenario")
|
||||
{
|
||||
ui.mActionPlantPhenotypeScenario->setChecked(true);
|
||||
@ -1506,6 +1664,24 @@ void HPPA::createOneMotorScenario()
|
||||
|
||||
}
|
||||
|
||||
void HPPA::createGonggaRotatingPlatformScenario()
|
||||
{
|
||||
//在菜单中选择移动平台
|
||||
ui.mAction_1AxisMotor->setChecked(true);
|
||||
|
||||
//右下角控制tab
|
||||
m_tabManager->hideAllTabs();
|
||||
|
||||
m_tabManager->showTab(m_hic);
|
||||
m_tabManager->showTab(m_ic);
|
||||
m_tabManager->showTab(m_rgbCameraControlWindow);
|
||||
m_tabManager->showTab(m_fodisWindow);
|
||||
m_tabManager->showTab(m_omc);
|
||||
m_tabManager->showTab(m_gonggaShanRecordCtl);
|
||||
|
||||
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::OneMotor);
|
||||
}
|
||||
|
||||
void HPPA::onCreated3DModelPlantPhenotype()
|
||||
{
|
||||
connect(m_tmc, SIGNAL(broadcastLocationSignal(std::vector<double>)), m_view3DModelManager->m_viewPlant, SLOT(setLoc(std::vector<double>)));
|
||||
@ -1560,6 +1736,7 @@ void HPPA::create3DPlantPhenotypeScenario()
|
||||
//m_tabManager->showTab(m_pc);
|
||||
m_tabManager->showTab(m_pc3D);
|
||||
m_tabManager->showTab(m_tmc);
|
||||
m_tabManager->showTab(m_omc_LiftingPlatform);
|
||||
|
||||
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::PlantPhenotype);
|
||||
|
||||
@ -1869,7 +2046,10 @@ QWidget* HPPA::onCreateTab(QString tabName)
|
||||
QWidget* tabTmp = new QWidget();
|
||||
|
||||
QGridLayout* GridLayout = new QGridLayout();
|
||||
GridLayout->addWidget(new Mapcavas(tabTmp));
|
||||
|
||||
Mapcavas* canvas = new Mapcavas(tabTmp);
|
||||
canvas->updateDisplayMode();
|
||||
GridLayout->addWidget(canvas);
|
||||
|
||||
tabTmp->setLayout(GridLayout);
|
||||
|
||||
@ -1903,6 +2083,10 @@ void HPPA::onTabWidgetCurrentChanged(int index)//代码新建一个tab,会调
|
||||
//获取绘图控件
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->widget(index);
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-apply the current active map tool to the new canvas
|
||||
Mapcavas* canvas = currentImageViewer[0];
|
||||
@ -2056,6 +2240,37 @@ void HPPA::setAxis(QValueAxis* axisX, QValueAxis* axisY)
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::showFiberImagerSpectral(DeviceAttribute attribute, DataFrame dataFrame)
|
||||
{
|
||||
try
|
||||
{
|
||||
QLineSeries* series = new QLineSeries();
|
||||
|
||||
const int count = qMin(attribute.iPixels, 4096);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double wavelength = attribute.fWaveLengthInNM[i];
|
||||
double intensity = dataFrame.lData[i];
|
||||
series->append(wavelength, intensity);
|
||||
}
|
||||
|
||||
series->setPen(QPen(QColor("#FF928A"), 2));
|
||||
|
||||
m_FiberImagerChart->removeAllSeries();
|
||||
m_FiberImagerChart->addSeries(series);
|
||||
m_FiberImagerChart->createDefaultAxes();
|
||||
|
||||
QValueAxis* axisX = qobject_cast<QValueAxis*>(m_FiberImagerChart->axisX());
|
||||
QValueAxis* axisY = qobject_cast<QValueAxis*>(m_FiberImagerChart->axisY());
|
||||
|
||||
setAxis(axisX, axisY);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
std::cout << "显示光谱有错误!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::timerEvent(QTimerEvent* event)
|
||||
{
|
||||
}
|
||||
@ -2249,7 +2464,7 @@ void HPPA::disconnectImagerAndCleanup()
|
||||
{
|
||||
m_RecordThread->quit();
|
||||
m_RecordThread->wait(3000);
|
||||
delete m_RecordThread;
|
||||
m_RecordThread->deleteLater();
|
||||
m_RecordThread = nullptr;
|
||||
}
|
||||
|
||||
@ -2386,7 +2601,7 @@ void HPPA::onconnect()
|
||||
connect(m_Imager, SIGNAL(RecordDarlFinishSignal()), this, SLOT(recordDarkFinish()));
|
||||
|
||||
// Connect LayerFileCreated from imager to HPPA slot
|
||||
connect(m_Imager, SIGNAL(LayerFileCreated(QString,QString,int)), this, SLOT(onLayerCreatedFromFile(QString,QString,int)));
|
||||
connect(m_Imager, SIGNAL(LayerFileCreated(QString,QString,int, QString)), this, SLOT(onLayerCreatedFromFile(QString,QString,int, QString)));
|
||||
|
||||
connect(this->ui.actionOpenDirectory, SIGNAL(triggered()), this, SLOT(onActionOpenDirectory()));
|
||||
|
||||
@ -2416,6 +2631,15 @@ void HPPA::onconnect()
|
||||
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
|
||||
QString errorFilePath = QCoreApplication::applicationDirPath() + "/camerror.txt";
|
||||
QFile file(errorFilePath);
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
out << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << " - std::exception: " << e.what() << "\n";
|
||||
file.close();
|
||||
}
|
||||
|
||||
delete m_Imager;
|
||||
m_Imager = nullptr;
|
||||
|
||||
@ -2425,6 +2649,15 @@ void HPPA::onconnect()
|
||||
{
|
||||
ui.action_connect_imager->setIcon(QIcon(":/svg/resources/icons/svg/connect_imager.svg"));
|
||||
|
||||
QString errorFilePath = QCoreApplication::applicationDirPath() + "/camerror.txt";
|
||||
QFile file(errorFilePath);
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
out << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << " - int exception: " << e << "\n";
|
||||
file.close();
|
||||
}
|
||||
|
||||
delete m_Imager;
|
||||
m_Imager = nullptr;
|
||||
|
||||
@ -2646,6 +2879,10 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
//QWidget* currentWidget = m_imageViewerTabWidget->widget(fileNumber);
|
||||
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFrameCounter());//界面中显示已经采集的帧数
|
||||
|
||||
cv::Mat rgbImage(*m_Imager->getMatRgbImage(), cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());
|
||||
@ -2705,6 +2942,10 @@ void HPPA::onStretchedImageReady(int fileNumber, const QString& filePath, QPixma
|
||||
QWidget* currentWidget = m_MapLayerStore->widgetForLayer(filePath);
|
||||
if (!currentWidget) return;
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (currentImageViewer.isEmpty()) return;
|
||||
// 在界面中显示拉伸后的图像
|
||||
currentImageViewer[0]->SetImage(&pixmap);
|
||||
@ -2726,6 +2967,10 @@ void HPPA::focusPlotSpectralImg(int state)
|
||||
//显示影像
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->currentWidget();
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFocusFrameCounter());//界面中显示已经采集的帧数
|
||||
|
||||
ImageProcessor imageProcessor;
|
||||
@ -2868,22 +3113,22 @@ void WorkerThread3::run()
|
||||
emit AutoFocusFinishedSignal();
|
||||
}
|
||||
|
||||
void HPPA::onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex)
|
||||
void HPPA::onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex, const QString& hyperimagerTppe)
|
||||
{
|
||||
if (!m_LayerTreeModel || !m_RasterGroup) return;
|
||||
|
||||
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||
{
|
||||
//addLayer(baseName, filePath, false, false);
|
||||
addLayer(baseName, filePath, false);
|
||||
addLayer(baseName, filePath, false, true, hyperimagerTppe);
|
||||
}
|
||||
else
|
||||
{
|
||||
addLayer(baseName, filePath, false);
|
||||
addLayer(baseName, filePath, false, true, hyperimagerTppe);
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refresh, bool isAddImage)
|
||||
void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refresh, bool isAddImage, const QString& hyperimagerTppe)
|
||||
{
|
||||
// Create MapLayer first and attach it to a LayerTreeLayerNode
|
||||
RasterLayer* ml = new RasterLayer(baseName, filePath);
|
||||
@ -2900,15 +3145,46 @@ void HPPA::addLayer(const QString& baseName, const QString& filePath,bool refres
|
||||
|
||||
if (isAddImage)
|
||||
{
|
||||
newImage(ml, RasterImageLayer::RendererType::Multiband, node, refresh);
|
||||
newImage(ml, RasterImageLayer::RendererType::Multiband, node, refresh, hyperimagerTppe);
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::newImage(RasterLayer* ml, RasterImageLayer::RendererType type, LayerTreeNode* parent, bool refresh)
|
||||
void HPPA::newImage(RasterLayer* ml, RasterImageLayer::RendererType type, LayerTreeNode* parent, bool refresh, const QString& hyperimagerTppe)
|
||||
{
|
||||
QWidget* mapcavasContainer = onCreateTab(ml->name());
|
||||
RasterImageLayer* rasterImageLayer = new RasterImageLayer(ml, type);
|
||||
RasterImageLayer* rasterImageLayer;
|
||||
|
||||
//当边采集边显示时,需要修改rasterImageLayer默认渲染波段
|
||||
if (hyperimagerTppe== "visibleLight")
|
||||
{
|
||||
rasterImageLayer = new RasterImageLayer(ml, type, false);
|
||||
|
||||
auto params = rasterImageLayer->multibandParams();
|
||||
params.rWave = 665;
|
||||
params.gWave = 560;
|
||||
params.bWave = 490;
|
||||
rasterImageLayer->setMultibandParams(params);
|
||||
}
|
||||
else if (hyperimagerTppe == "nearInfrared")
|
||||
{
|
||||
rasterImageLayer = new RasterImageLayer(ml, type, false);
|
||||
|
||||
auto params = rasterImageLayer->multibandParams();
|
||||
params.rWave = 1500;
|
||||
params.gWave = 1300;
|
||||
params.bWave = 1100;
|
||||
rasterImageLayer->setMultibandParams(params);
|
||||
}
|
||||
else//当打开影像文件时,rasterImageLayer默认渲染波段由头文件决定
|
||||
{
|
||||
rasterImageLayer = new RasterImageLayer(ml, type, true);
|
||||
}
|
||||
|
||||
QList<Mapcavas*> mapcavas = mapcavasContainer->findChildren<Mapcavas*>();
|
||||
if (mapcavas.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mapcavas[0]->setImageLayer(rasterImageLayer);
|
||||
|
||||
QString title = ml->name();
|
||||
|
||||
26
HPPA/HPPA.h
26
HPPA/HPPA.h
@ -87,6 +87,9 @@
|
||||
#include "TimedDataCollection.h"
|
||||
|
||||
#include "PowerControl3D.h"
|
||||
#include "FodisWindow.h"
|
||||
|
||||
#include "GonggaShanRecordCtl.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -318,7 +321,10 @@ private:
|
||||
PowerControl3D* m_pc3D;
|
||||
RobotArmControl* m_rac;
|
||||
OneMotorControl* m_omc;
|
||||
OneMotorControl_LiftingPlatform* m_omc_LiftingPlatform;
|
||||
TwoMotorControl* m_tmc;
|
||||
FodisWindow* m_fodisWindow;
|
||||
GonggaShanRecordCtl* m_gonggaShanRecordCtl;
|
||||
QPointer<TimedDataCollection> m_tdc;
|
||||
|
||||
View3DModelManager* m_view3DModelManager;
|
||||
@ -354,6 +360,12 @@ private:
|
||||
void showQuickPreview(int fileNumber, const QString& filePath, const cv::Mat& rgbImage);
|
||||
|
||||
|
||||
QChart* m_FiberImagerChart;
|
||||
void showFiberImagerSpectral(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void setupGonggashanAutoRecordConnection();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
|
||||
void focusPlotSpectralImg(int state);
|
||||
@ -410,6 +422,7 @@ public Q_SLOTS:
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
|
||||
void createOneMotorScenario();
|
||||
void createGonggaRotatingPlatformScenario();
|
||||
void createPlantPhenotypeScenario();
|
||||
void create3DPlantPhenotypeScenario();
|
||||
void onCreated3DModelPlantPhenotype();
|
||||
@ -417,9 +430,9 @@ public Q_SLOTS:
|
||||
void createMicroscopicMotionControlScenario();
|
||||
void onCreated3DModelOneMotor();
|
||||
|
||||
void addLayer(const QString& baseName, const QString& filePath, bool refresh, bool isAddImage = true);
|
||||
void newImage(RasterLayer* ml, RasterImageLayer::RendererType, LayerTreeNode* parent, bool refresh=true);
|
||||
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex);
|
||||
void addLayer(const QString& baseName, const QString& filePath, bool refresh, bool isAddImage = true, const QString& hyperimagerTppe="");
|
||||
void newImage(RasterLayer* ml, RasterImageLayer::RendererType, LayerTreeNode* parent, bool refresh=true, const QString& hyperimagerTppe="");
|
||||
void onLayerCreatedFromFile(const QString& baseName, const QString& filePath, int fileIndex, const QString& hyperimagerTppe);
|
||||
void removeLayerByTreeIndex();
|
||||
void removeLayerByNode(LayerTreeNode* node);
|
||||
void showColorImageByTreeIndex();
|
||||
@ -437,10 +450,17 @@ public Q_SLOTS:
|
||||
void setTimedDataCollectionCamParm(int camType, int captureIntervalSeconds, QString folder);
|
||||
void setTimedDataCollectionMotorParm(QString pathLineFilePath);
|
||||
void onStartTimedDataCollection(int camType);
|
||||
void onObtainTargetDepthInformation(SubTask subTaskParams);
|
||||
void onLiftingPlatform(SubTask subTaskParams);
|
||||
void onAutoFocus_TimedDataCollection(SubTask subTaskParams);
|
||||
|
||||
void onStretchedImageReady(int fileNumber, const QString& filePath, QPixmap& pixmap);
|
||||
void onStretchProcessingError(int fileNumber, const QString& filePath, const QString& error);
|
||||
|
||||
void onGonggashanRecord(const QString& posInfo, const QString& gpsData, double motorRotationSpeed, QString dataFolder);
|
||||
void onGonggashanHyperAutoExposure();
|
||||
void onGonggashanFiberAutoExposureRecord(QString posInfo, QString dataFolder);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
|
||||
@ -133,6 +133,7 @@ color:white;
|
||||
<string>应用场景</string>
|
||||
</property>
|
||||
<addaction name="mActionOneMotorScenario"/>
|
||||
<addaction name="mActionGonggaRotatingPlatformScenario"/>
|
||||
<addaction name="mActionPlantPhenotypeScenario"/>
|
||||
<addaction name="mActionMicroscopicMotionControlScenario"/>
|
||||
<addaction name="mAction3DPlantPhenotypeScenario"/>
|
||||
@ -749,6 +750,14 @@ QPushButton:pressed
|
||||
<string>定时采集</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionGonggaRotatingPlatformScenario">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>贡嘎山旋转平台</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
||||
@ -55,27 +55,28 @@
|
||||
</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;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;$(IncludePath)</IncludePath>
|
||||
<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;D:\cpp_project_vs2022\HPPA\JinspSpectralmeterControl;$(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;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;$(IncludePath)</IncludePath>
|
||||
<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;D:\cpp_project_vs2022\HPPA\JinspSpectralmeterControl;$(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;EDSDK.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;JinspSpectralmeterControl.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp14</LanguageStandard>
|
||||
</ClCompile>
|
||||
</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;EDSDK.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;JinspSpectralmeterControl.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -118,12 +119,16 @@
|
||||
<ClCompile Include="CustomDockWidgetBase.cpp" />
|
||||
<ClCompile Include="DepthCameraWindow.cpp" />
|
||||
<ClCompile Include="FileNameLineEdit.cpp" />
|
||||
<ClCompile Include="FodisWindow.cpp" />
|
||||
<ClCompile Include="GonggaShanRecordCtl.cpp" />
|
||||
<ClCompile Include="hppaConfigFile.cpp" />
|
||||
<ClCompile Include="HyperImagerControl.cpp" />
|
||||
<ClCompile Include="imageControl.cpp" />
|
||||
<ClCompile Include="ImagerOperationBase.cpp" />
|
||||
<ClCompile Include="imager_base.cpp" />
|
||||
<ClCompile Include="irisximeaimager.cpp" />
|
||||
<ClCompile Include="JinspFiberImager.cpp" />
|
||||
<ClCompile Include="JinspFiberImagerConfig.cpp" />
|
||||
<ClCompile Include="LayerTree.cpp" />
|
||||
<ClCompile Include="LayerTreeGroupNode.cpp" />
|
||||
<ClCompile Include="LayerTreeImageNode.cpp" />
|
||||
@ -155,6 +160,7 @@
|
||||
<ClCompile Include="recordFrameCounter.cpp" />
|
||||
<ClCompile Include="resononImager.cpp" />
|
||||
<ClCompile Include="ResononNirImager.cpp" />
|
||||
<ClCompile Include="RgbCameraCaptureCoordinator.cpp" />
|
||||
<ClCompile Include="RgbCameraOperation.cpp" />
|
||||
<ClCompile Include="rgbCameraWindow.cpp" />
|
||||
<ClCompile Include="RobotArmControl.cpp" />
|
||||
@ -177,8 +183,11 @@
|
||||
<QtUic Include="adjustTable.ui" />
|
||||
<QtUic Include="DepthCamera.ui" />
|
||||
<QtUic Include="FocusDialog.ui" />
|
||||
<QtUic Include="fodis.ui" />
|
||||
<QtUic Include="gonggashanCtl.ui" />
|
||||
<QtUic Include="HPPA.ui" />
|
||||
<QtMoc Include="HPPA.h" />
|
||||
<ClCompile Include="DepthValueLogger.cpp" />
|
||||
<ClCompile Include="fileOperation.cpp" />
|
||||
<ClCompile Include="focusWindow.cpp" />
|
||||
<ClCompile Include="HPPA.cpp" />
|
||||
@ -205,6 +214,7 @@
|
||||
<QtUic Include="twoMotorControl.ui" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="DepthValueLogger.h" />
|
||||
<QtMoc Include="fileOperation.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -231,6 +241,9 @@
|
||||
<QtMoc Include="DepthCameraWindow.h" />
|
||||
<QtMoc Include="CommunicationViaTCP.h" />
|
||||
<QtMoc Include="CommunicationInterfaceBase.h" />
|
||||
<QtMoc Include="FodisWindow.h" />
|
||||
<ClInclude Include="FiberSpectrometerOperationBase.h" />
|
||||
<QtMoc Include="GonggaShanRecordCtl.h" />
|
||||
<ClInclude Include="imager_base.h" />
|
||||
<ClInclude Include="irisximeaimager.h" />
|
||||
<QtMoc Include="OneMotorControl.h" />
|
||||
@ -245,6 +258,7 @@
|
||||
<QtMoc Include="RasterLayer.h" />
|
||||
<QtMoc Include="MapLayerStore.h" />
|
||||
<QtMoc Include="LayerTreeImageNode.h" />
|
||||
<QtMoc Include="JinspFiberImager.h" />
|
||||
<ClInclude Include="LayerTreeView.h" />
|
||||
<QtMoc Include="LayerTreeViewMenuProvider.h" />
|
||||
<QtMoc Include="MapTool.h" />
|
||||
@ -276,6 +290,7 @@
|
||||
<ClInclude Include="ResononNirImager.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<QtMoc Include="RgbCameraCaptureCoordinator.h" />
|
||||
<QtMoc Include="RgbCameraOperation.h" />
|
||||
<QtMoc Include="resononImager.h" />
|
||||
<QtMoc Include="QMotorDoubleSlider.h" />
|
||||
|
||||
@ -21,6 +21,24 @@
|
||||
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||
<Extensions>ts</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\TimedDataCollection">
|
||||
<UniqueIdentifier>{3777a3c2-8d8a-4414-b6c9-ac20640f7b2e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\TimedDataCollection">
|
||||
<UniqueIdentifier>{ea004f0d-34de-4b29-8ce2-57dd8aa01c03}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\LayerTree">
|
||||
<UniqueIdentifier>{25329ee3-f78c-4dd9-9170-e64ccb4ccd9e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\LayerTree">
|
||||
<UniqueIdentifier>{18072152-2a29-4ad8-be97-d097af97eeec}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\hyperImagerCtl">
|
||||
<UniqueIdentifier>{b3f08410-c140-42db-bcfd-24efba860cfb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\hyperImagerCtl">
|
||||
<UniqueIdentifier>{205ec088-0286-42ca-862c-2870928a46f5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="HPPA.qrc">
|
||||
@ -70,9 +88,6 @@
|
||||
<ClCompile Include="QMotorDoubleSlider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="resononImager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RgbCameraOperation.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -88,12 +103,6 @@
|
||||
<ClCompile Include="path_tc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ResononNirImager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImagerOperationBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utility_tc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -139,21 +148,6 @@
|
||||
<ClCompile Include="View3DModelManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeNode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeModel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTree.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeGroupNode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeLayerNode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapLayer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -175,12 +169,6 @@
|
||||
<ClCompile Include="MapLayerStore.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeView.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeViewMenuProvider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imageControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -226,18 +214,9 @@
|
||||
<ClCompile Include="SingleLensReflexCameraWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeImageNode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RasterRendererBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TimedDataCollection.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TimedDataCollectionDataStructures.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CommunicationViaTCP.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -247,10 +226,64 @@
|
||||
<ClCompile Include="PowerControl3D.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TaskTreeModel.cpp">
|
||||
<ClCompile Include="PathLine.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PathLine.cpp">
|
||||
<ClCompile Include="FodisWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JinspFiberImager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JinspFiberImagerConfig.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GonggaShanRecordCtl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TaskTreeModel.cpp">
|
||||
<Filter>Source Files\TimedDataCollection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TimedDataCollection.cpp">
|
||||
<Filter>Source Files\TimedDataCollection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TimedDataCollectionDataStructures.cpp">
|
||||
<Filter>Source Files\TimedDataCollection</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTree.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeGroupNode.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeImageNode.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeLayerNode.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeModel.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeNode.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeView.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayerTreeViewMenuProvider.cpp">
|
||||
<Filter>Source Files\LayerTree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImagerOperationBase.cpp">
|
||||
<Filter>Source Files\hyperImagerCtl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="resononImager.cpp">
|
||||
<Filter>Source Files\hyperImagerCtl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ResononNirImager.cpp">
|
||||
<Filter>Source Files\hyperImagerCtl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DepthValueLogger.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@ -279,18 +312,12 @@
|
||||
<QtMoc Include="QMotorDoubleSlider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="resononImager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="RgbCameraOperation.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="aboutWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="ImagerOperationBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="adjustTable.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -327,21 +354,6 @@
|
||||
<QtMoc Include="View3DModelManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeModel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTree.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeGroupNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeLayerNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapLayer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -351,9 +363,6 @@
|
||||
<QtMoc Include="MapLayerStore.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeViewMenuProvider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="imageControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -393,15 +402,6 @@
|
||||
<QtMoc Include="SingleLensReflexCameraWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeImageNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TimedDataCollection.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TimedDataCollectionDataStructures.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="CommunicationViaTCP.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -411,7 +411,52 @@
|
||||
<QtMoc Include="PowerControl3D.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="FodisWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="JinspFiberImager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="GonggaShanRecordCtl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TimedDataCollection.h">
|
||||
<Filter>Header Files\TimedDataCollection</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TaskTreeModel.h">
|
||||
<Filter>Header Files\TimedDataCollection</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TimedDataCollectionDataStructures.h">
|
||||
<Filter>Header Files\TimedDataCollection</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTree.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeGroupNode.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeImageNode.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeLayerNode.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeModel.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeNode.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="LayerTreeViewMenuProvider.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="ImagerOperationBase.h">
|
||||
<Filter>Header Files\hyperImagerCtl</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="resononImager.h">
|
||||
<Filter>Header Files\hyperImagerCtl</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="DepthValueLogger.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
@ -434,9 +479,6 @@
|
||||
<ClInclude Include="path_tc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ResononNirImager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="utility_tc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -461,9 +503,6 @@
|
||||
<ClInclude Include="SinglebandRasterRenderer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LayerTreeView.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AppSettings.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -473,6 +512,15 @@
|
||||
<ClInclude Include="PathLine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FiberSpectrometerOperationBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LayerTreeView.h">
|
||||
<Filter>Header Files\LayerTree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ResononNirImager.h">
|
||||
<Filter>Header Files\hyperImagerCtl</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="FocusDialog.ui">
|
||||
@ -529,6 +577,12 @@
|
||||
<QtUic Include="PowerControl3D.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="fodis.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="gonggashanCtl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
@ -36,7 +36,7 @@ Mapcavas::Mapcavas(QWidget* pParent) :QGraphicsView(pParent)
|
||||
ft.setPointSize(14);
|
||||
m_framNumberLabel->setFont(ft);
|
||||
m_framNumberLabel->setText("0");
|
||||
|
||||
m_framNumberLabel->setVisible(false);
|
||||
|
||||
m_GraphicsPixmapItemHandle = nullptr;
|
||||
|
||||
@ -48,6 +48,8 @@ Mapcavas::Mapcavas(QWidget* pParent) :QGraphicsView(pParent)
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
|
||||
m_displayMode = AppSettings::instance().hyperimgDisplayMode();
|
||||
}
|
||||
|
||||
Mapcavas::~Mapcavas()
|
||||
@ -55,6 +57,11 @@ Mapcavas::~Mapcavas()
|
||||
|
||||
}
|
||||
|
||||
void Mapcavas::updateDisplayMode()
|
||||
{
|
||||
m_displayMode = AppSettings::instance().hyperimgDisplayMode();
|
||||
}
|
||||
|
||||
void Mapcavas::DisplayFrameNumber(int frameNumber)
|
||||
{
|
||||
m_framNumberLabel->setText(QString::number(frameNumber));
|
||||
@ -71,7 +78,15 @@ void Mapcavas::SetImage(QPixmap *image)
|
||||
{
|
||||
m_GraphicsPixmapItemHandle->setPixmap(*image);
|
||||
}
|
||||
ensureSceneVisible();
|
||||
|
||||
if (m_displayMode == AppSettings::HyperimgDisplayMode::Full)
|
||||
{
|
||||
ensureSceneVisible();
|
||||
}
|
||||
else if (m_displayMode == AppSettings::HyperimgDisplayMode::Waterfall)
|
||||
{
|
||||
ensureWaterfallVisible();
|
||||
}
|
||||
}
|
||||
|
||||
void Mapcavas::ensureSceneVisible()
|
||||
@ -91,6 +106,44 @@ void Mapcavas::ensureSceneVisible()
|
||||
centerOn(scene_rect.center());
|
||||
}
|
||||
|
||||
void Mapcavas::ensureWaterfallVisible()
|
||||
{
|
||||
resetTransform();
|
||||
|
||||
auto items = this->scene()->items();
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
auto scene_rect = this->scene()->itemsBoundingRect();
|
||||
qreal view_width = viewport()->rect().width();
|
||||
qreal view_height = viewport()->rect().height();
|
||||
|
||||
double x_scale = view_width / scene_rect.width();
|
||||
double y_scale = view_height / scene_rect.height();
|
||||
|
||||
double scale_factor = qMin(x_scale, y_scale) * 0.9;
|
||||
|
||||
scale(x_scale, x_scale);
|
||||
m_scale *= x_scale;
|
||||
|
||||
// 计算缩放后的图片可见高度
|
||||
qreal scaled_height = scene_rect.height() * x_scale;
|
||||
|
||||
// 根据图片高度决定 Y 坐标
|
||||
qreal center_y;
|
||||
if (scaled_height <= view_height)
|
||||
{
|
||||
center_y = scene_rect.center().y();
|
||||
}
|
||||
else
|
||||
{
|
||||
qreal half_view_height = view_height / 2.0 / x_scale;
|
||||
center_y = scene_rect.bottom() - half_view_height;
|
||||
}
|
||||
|
||||
centerOn(scene_rect.center().x(), center_y);
|
||||
}
|
||||
|
||||
bool Mapcavas::HasImage()
|
||||
{
|
||||
if (m_GraphicsPixmapItemHandle == nullptr)
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "QGraphicsView"
|
||||
#include "qlabel.h"
|
||||
#include <QVector>
|
||||
#include "AppSettings.h"
|
||||
|
||||
class RasterImageLayer;
|
||||
|
||||
@ -19,7 +20,7 @@ public:
|
||||
|
||||
|
||||
void DisplayFrameNumber(int frameNumber);
|
||||
|
||||
void updateDisplayMode();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
@ -29,6 +30,7 @@ public:
|
||||
void SetImage(QPixmap *image);
|
||||
bool HasImage();
|
||||
void ensureSceneVisible();
|
||||
void ensureWaterfallVisible();
|
||||
|
||||
void updateCrosshair(double sceneX, double sceneY);
|
||||
void removeCrosshair();
|
||||
@ -78,6 +80,7 @@ private:
|
||||
QGraphicsLineItem* m_hLine = nullptr; // horizontal line
|
||||
QGraphicsLineItem* m_vLine = nullptr; // vertical line
|
||||
|
||||
AppSettings::HyperimgDisplayMode m_displayMode;
|
||||
|
||||
signals:
|
||||
void leftMouseButtonPressed(int, int, QVector<double>, QVector<double>);
|
||||
|
||||
@ -68,11 +68,12 @@ double ImagerOperationBase::auto_exposure()
|
||||
|
||||
imagerStopCollect();
|
||||
|
||||
emit autoExposureSignal();
|
||||
double exposureTime = getIntegrationTime();
|
||||
emit autoExposureSignal(exposureTime);
|
||||
|
||||
//std::cout << "自动曝光:" << getIntegrationTime() << std::endl;
|
||||
//std::cout << "自动曝光:" << exposureTime << std::endl;
|
||||
|
||||
return getIntegrationTime();
|
||||
return exposureTime;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::focus()
|
||||
@ -221,6 +222,16 @@ void ImagerOperationBase::record_white()
|
||||
|
||||
void ImagerOperationBase::start_record()
|
||||
{
|
||||
QObject* obj = sender();
|
||||
if (obj)
|
||||
{
|
||||
qDebug() << "ImagerOperationBase::start_record, sender name:" << obj->objectName();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "ImagerOperationBase::start_record, sender is null";
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
//std::cout << "------------------------------------------------------" << std::endl;
|
||||
@ -241,7 +252,7 @@ void ImagerOperationBase::start_record()
|
||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
||||
QString filePath = QString::fromStdString(m_FileName2Save2);
|
||||
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
|
||||
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter, "visibleLight");
|
||||
|
||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||
|
||||
@ -303,7 +314,7 @@ void ImagerOperationBase::start_record()
|
||||
fprintf(hTimesFile, "%ll\n", timeOs);
|
||||
|
||||
//将rgb波段提取出来,以便在界面中显示
|
||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
m_RgbImage->FillRgbImage(buffer, 121, 79, 40);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
|
||||
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
||||
|
||||
|
||||
@ -117,11 +117,11 @@ signals:
|
||||
|
||||
|
||||
void testImagerStatus();//表示可以测试相机连接状态:是否连接,并反映到界面上
|
||||
void autoExposureSignal();
|
||||
void autoExposureSignal(double exposureTime);
|
||||
|
||||
// 新增:当一组影像文件(.bil/.hdr)写入完成后发出(会从采集线程发出,Qt 会做 queued connection)
|
||||
void ImageFileSaved(const QString& path, int fileIndex);
|
||||
|
||||
// 修改:不再直接发送 MapLayer*,而是发送文件名与文件路径,UI 层负责创建 MapLayer 对象并管理生命周期
|
||||
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex);
|
||||
void LayerFileCreated(const QString& baseName, const QString& filePath, int fileIndex, const QString& hyperimagerTppe);
|
||||
};
|
||||
|
||||
359
HPPA/JinspFiberImager.cpp
Normal file
359
HPPA/JinspFiberImager.cpp
Normal file
@ -0,0 +1,359 @@
|
||||
//
|
||||
// Created by 73505 on 2023/5/7.
|
||||
//
|
||||
#include <algorithm>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include "JinspFiberImager.h"
|
||||
|
||||
JinspFiberImager::JinspFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
m_FiberSpectrometer = NULL;
|
||||
|
||||
mUcPortNumber=ucPortNumber;
|
||||
|
||||
m_record = false;
|
||||
|
||||
m_captureIntervalMilliseconds = 1 * 1000;
|
||||
|
||||
qRegisterMetaType<DeviceAttribute>("DeviceAttribute");
|
||||
qRegisterMetaType<DataFrame>("DataFrame");
|
||||
}
|
||||
|
||||
JinspFiberImager::~JinspFiberImager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void JinspFiberImager::connectFiberSpectrometer(QString& SN, QString& pixelCount, QString& wavelengthInfo)
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
m_FiberSpectrometer = new JinspSpectralmeterControl();
|
||||
|
||||
m_FiberSpectrometer->Initialize(false, mUcPortNumber, "OPTOSKY");
|
||||
|
||||
DeviceInfo deviceInfo;//
|
||||
DeviceAttribute deviceAttribute;
|
||||
|
||||
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
||||
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);//?????
|
||||
|
||||
SN = QString::fromStdString(deviceInfo.strSN);
|
||||
pixelCount = QString::number(deviceAttribute.iPixels);
|
||||
wavelengthInfo = QString::number(deviceAttribute.fWaveLengthInNM[0]) + "--" + QString::number(deviceAttribute.fWaveLengthInNM[deviceAttribute.iPixels - 1]);
|
||||
|
||||
m_FiberSpectrometer->SetDeviceTemperature(-10);
|
||||
|
||||
|
||||
//设置dn值的最大值(和位深相关)
|
||||
string qepro = "QEP";//?????????????????????????????????????????????????????????????????????????????????????????
|
||||
string flame = "FLMS";//?????????????????????????????????????????????????????????????????????????????????????????
|
||||
if (deviceInfo.strSN.find(qepro) != string::npos)
|
||||
{
|
||||
m_MaxValueOfFiberSpectrometer = 200000;
|
||||
}
|
||||
else if (deviceInfo.strSN.find(flame) != string::npos)
|
||||
{
|
||||
m_MaxValueOfFiberSpectrometer = 65535;
|
||||
}
|
||||
else//没有找到匹配的仪器来设置 dn值的最大值
|
||||
{
|
||||
m_MaxValueOfFiberSpectrometer = 65535;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void JinspFiberImager::disconnectFiberSpectrometer()
|
||||
{
|
||||
m_record = false;
|
||||
}
|
||||
|
||||
void JinspFiberImager::getDeviceAttribute(DeviceAttribute& deviceAttribute)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);
|
||||
}
|
||||
|
||||
void JinspFiberImager::getDeviceInfo(DeviceInfo& deviceInfo)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
||||
}
|
||||
|
||||
void JinspFiberImager::setExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
m_FiberSpectrometer->SetExposureTime(iExposureTimeInMS);
|
||||
}
|
||||
|
||||
void JinspFiberImager::getExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
m_FiberSpectrometer->GetExposureTime(iExposureTimeInMS);
|
||||
}
|
||||
|
||||
void JinspFiberImager::getDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceTemperature(fTemperature);
|
||||
}
|
||||
|
||||
void JinspFiberImager::singleShot(DataFrame &dfData)
|
||||
{
|
||||
m_FiberSpectrometer->SingleShot(dfData);
|
||||
}
|
||||
|
||||
void JinspFiberImager::getNonlinearityCoeffs(coeffsFrame &coeffs)
|
||||
{
|
||||
printf("This is JinspFiberImager.\n");
|
||||
}
|
||||
|
||||
void JinspFiberImager::recordDark(QString path)
|
||||
{
|
||||
//获取设备信息
|
||||
DeviceAttribute attribute;
|
||||
DeviceInfo deviceInfo;
|
||||
getDeviceAttribute(attribute);
|
||||
getDeviceInfo(deviceInfo);
|
||||
|
||||
//采集暗帧
|
||||
singleShot(m_DarkData);
|
||||
|
||||
//输出到csv
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_darkSpectral_dn.csv";
|
||||
std::ofstream outfile(fileName.toStdString().c_str());
|
||||
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
if (i==0)
|
||||
{
|
||||
outfile << m_DarkData.usExposureTimeInMS << std::endl;
|
||||
}
|
||||
outfile << attribute.fWaveLengthInNM[i] << "," << m_DarkData.lData[i] << std::endl;
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
void JinspFiberImager::recordTarget2csv(int recordTimes, QString path)
|
||||
{
|
||||
//获取设备信息
|
||||
DeviceAttribute attribute;
|
||||
DeviceInfo deviceInfo;
|
||||
getDeviceAttribute(attribute);
|
||||
getDeviceInfo(deviceInfo);
|
||||
|
||||
|
||||
DataFrame integratingSphereData_tmp;
|
||||
|
||||
for (int i = 0; i < recordTimes; i++)
|
||||
{
|
||||
singleShot(integratingSphereData_tmp);
|
||||
|
||||
if (i == 0)//将integratingSphereData_tmp中的曝光时间、温度等信息传给m_IntegratingSphereData
|
||||
{
|
||||
m_IntegratingSphereData = integratingSphereData_tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
m_IntegratingSphereData.lData[i] += integratingSphereData_tmp.lData[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
m_IntegratingSphereData.lData[i] = m_IntegratingSphereData.lData[i] / recordTimes;
|
||||
}
|
||||
|
||||
//将m_IntegratingSphereData通过信号发送
|
||||
emit spectalCaptured(attribute, m_IntegratingSphereData);
|
||||
|
||||
//输出到csv
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString fileName = path + "/" + currentTime + "_" + m_posInfo + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral_dn.csv";
|
||||
std::ofstream outfile(fileName.toStdString().c_str());
|
||||
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
if (i==0)
|
||||
{
|
||||
outfile << m_IntegratingSphereData.usExposureTimeInMS << "," << getNanosecondsSinceMidnight() << std::endl;
|
||||
}
|
||||
outfile << attribute.fWaveLengthInNM[i] << "," << m_IntegratingSphereData.lData[i] << std::endl;
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
void JinspFiberImager::autoExpose()
|
||||
{
|
||||
int allowMaxExposure = 6000;
|
||||
|
||||
DeviceAttribute attribute;
|
||||
getDeviceAttribute(attribute);
|
||||
|
||||
const ZZ_U32 maxPixelValue = m_MaxValueOfFiberSpectrometer;
|
||||
const double targetMinRatio = 0.80;
|
||||
const double targetMaxRatio = 0.90;
|
||||
const ZZ_U32 targetMin = maxPixelValue * targetMinRatio;
|
||||
const ZZ_U32 targetMax = maxPixelValue * targetMaxRatio;
|
||||
|
||||
ZZ_U32 thresholdLow = targetMin;
|
||||
ZZ_U32 thresholdHigh = targetMax;
|
||||
|
||||
// 自适应初始曝光时间:先快速探测亮度水平
|
||||
int exposureTime = 10;
|
||||
setExposureTime(exposureTime);
|
||||
DataFrame dataFrame;
|
||||
singleShot(dataFrame);
|
||||
ZZ_S32 maxValue = GetMaxValue(dataFrame.lData, attribute.iPixels);
|
||||
|
||||
// 探测阶段:快速逼近目标区间
|
||||
if (maxValue > 0)
|
||||
{
|
||||
// 预测达到目标区间所需的曝光时间
|
||||
ZZ_U32 targetValue = (targetMin + targetMax) / 2;
|
||||
double predictedRatio = static_cast<double>(targetValue) / maxValue;
|
||||
// 曝光时间与亮度为对数关系,使用对数预测更准确
|
||||
double logRatio = log(static_cast<double>(targetValue) / maxValue + 0.001);
|
||||
int predictedExposure = static_cast<int>(exposureTime * pow(predictedRatio, 0.7));
|
||||
|
||||
if (predictedExposure < 1)
|
||||
predictedExposure = 1;
|
||||
if (predictedExposure > allowMaxExposure)
|
||||
predictedExposure = allowMaxExposure;
|
||||
//predictedExposure = std::clamp(predictedExposure, 1, allowMaxExposure);
|
||||
|
||||
exposureTime = predictedExposure;
|
||||
setExposureTime(exposureTime);
|
||||
singleShot(dataFrame);
|
||||
maxValue = GetMaxValue(dataFrame.lData, attribute.iPixels);
|
||||
}
|
||||
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
// 二分查找阶段:在目标区间内精确查找
|
||||
int lowExposure = 1;
|
||||
int highExposure = allowMaxExposure;
|
||||
int iterations = 0;
|
||||
const int maxIterations = 10;
|
||||
|
||||
while (iterations < maxIterations)
|
||||
{
|
||||
// 检查是否已在目标区间内
|
||||
if (maxValue >= thresholdLow && maxValue <= thresholdHigh)
|
||||
{
|
||||
std::cout << "自动曝光完成 - 曝光时间:" << exposureTime
|
||||
<< "ms, 最大值:" << maxValue << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// 获取当前曝光时间
|
||||
m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
|
||||
if (maxValue < thresholdLow)
|
||||
{
|
||||
// 曝光不足,增大曝光时间 - 使用二分策略
|
||||
lowExposure = exposureTime;
|
||||
int newExposure = (exposureTime + highExposure) / 2;
|
||||
if (newExposure <= exposureTime)
|
||||
{
|
||||
newExposure = exposureTime * 2;
|
||||
}
|
||||
exposureTime = std::min(newExposure, allowMaxExposure);
|
||||
std::cout << "自动曝光 +++ (" << iterations << ") 曝光时间:"
|
||||
<< exposureTime << "ms, 最大值:" << maxValue << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 曝光过度,减小曝光时间 - 使用二分策略
|
||||
highExposure = exposureTime;
|
||||
int newExposure = (lowExposure + exposureTime) / 2;
|
||||
if (newExposure >= exposureTime) {
|
||||
newExposure = exposureTime / 2;
|
||||
}
|
||||
exposureTime = std::max(newExposure, 1);
|
||||
std::cout << "自动曝光 --- (" << iterations << ") 曝光时间:"
|
||||
<< exposureTime << "ms, 最大值:" << maxValue << std::endl;
|
||||
}
|
||||
|
||||
setExposureTime(exposureTime);
|
||||
singleShot(dataFrame);
|
||||
maxValue = GetMaxValue(dataFrame.lData, attribute.iPixels);
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
iterations++;
|
||||
}
|
||||
|
||||
if (iterations >= maxIterations) {
|
||||
std::cout << "自动曝光达到最大迭代次数,最终曝光时间:"
|
||||
<< exposureTime << "ms, 最大值:" << maxValue << std::endl;
|
||||
}
|
||||
|
||||
m_iExposureTime = exposureTime;
|
||||
}
|
||||
|
||||
ZZ_S32 JinspFiberImager::GetMaxValue(ZZ_S32 * dark, int number)
|
||||
{
|
||||
ZZ_S32 max = 0;
|
||||
//std::cout << "本帧最大值为" << max << std::endl;
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
// std::cout << dark[i] << std::endl;
|
||||
if(dark[i]>65535)
|
||||
continue;
|
||||
if (dark[i] > max)
|
||||
{
|
||||
max = dark[i];
|
||||
}
|
||||
}
|
||||
//std::cout << "本帧最大值为" << max << std::endl;
|
||||
return max;
|
||||
}
|
||||
|
||||
void JinspFiberImager::setCaptureInterval(int captureIntervalSeconds)
|
||||
{
|
||||
m_captureIntervalMilliseconds = captureIntervalSeconds * 1000;
|
||||
}
|
||||
|
||||
void JinspFiberImager::OpenFiberImagerAndRecord(QString filePath)
|
||||
{
|
||||
//连接光谱仪
|
||||
QString SN;
|
||||
QString pixelCount;
|
||||
QString wavelengthInfo;
|
||||
|
||||
connectFiberSpectrometer(SN, pixelCount, wavelengthInfo);
|
||||
|
||||
//曝光
|
||||
emit startExposureSignal();
|
||||
autoExpose();
|
||||
emit exposureCompleteSignal(m_iExposureTime);
|
||||
|
||||
//采集
|
||||
QFile qfData(filePath);
|
||||
bool bRes = qfData.open(QFile::WriteOnly | QIODevice::Append);
|
||||
if (!bRes)
|
||||
{
|
||||
printf("WriteData QFile open Failed");
|
||||
return;
|
||||
}
|
||||
|
||||
m_record = true;
|
||||
DataFrame data;
|
||||
while (m_record)
|
||||
{
|
||||
singleShot(data);
|
||||
qfData.write((char*)&data, sizeof(DataFrame));
|
||||
qfData.flush();
|
||||
|
||||
QThread::msleep(m_captureIntervalMilliseconds);
|
||||
}
|
||||
qfData.close();
|
||||
|
||||
std::cout << "close.........." << std::endl;
|
||||
m_FiberSpectrometer->Close();
|
||||
}
|
||||
75
HPPA/JinspFiberImager.h
Normal file
75
HPPA/JinspFiberImager.h
Normal file
@ -0,0 +1,75 @@
|
||||
//
|
||||
// Created by 73505 on 2023/5/7.
|
||||
//
|
||||
#pragma once
|
||||
#include <qthread.h>
|
||||
//#include <QFileDialog>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "JinspSpectralmeterControl.h"
|
||||
#include "FiberSpectrometerOperationBase.h"
|
||||
#include "utility_tc.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
class JinspFiberImager :public QObject,public FiberSpectrometerOperationBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
JinspFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
|
||||
~JinspFiberImager();
|
||||
|
||||
JinspSpectralmeterControl* m_FiberSpectrometer;
|
||||
|
||||
void connectFiberSpectrometer(QString& sn, QString& pixelCount, QString& wavelengthInfo);
|
||||
void disconnectFiberSpectrometer();
|
||||
void getDeviceAttribute(DeviceAttribute& deviceAttribute);
|
||||
void getDeviceInfo(DeviceInfo& deviceInfo);
|
||||
|
||||
void setExposureTime(int iExposureTimeInMS);
|
||||
|
||||
void getExposureTime(int &iExposureTimeInMS);//ok
|
||||
void getDeviceTemperature(float &fTemperature);//ok
|
||||
|
||||
void singleShot(DataFrame &dfData);
|
||||
|
||||
void getNonlinearityCoeffs(coeffsFrame &coeffs);
|
||||
|
||||
ZZ_S32 GetMaxValue(ZZ_S32 * dark, int number);
|
||||
|
||||
bool getRecordStatus() const { return m_record; }
|
||||
void setCaptureInterval(int captureIntervalSeconds);
|
||||
|
||||
|
||||
// DataFrame m_IntegratingSphereData;
|
||||
// DataFrame m_DarkData;
|
||||
protected:
|
||||
private:
|
||||
std::string mUcPortNumber;
|
||||
|
||||
bool m_record;
|
||||
int m_captureIntervalMilliseconds;
|
||||
|
||||
int m_iExposureTime;
|
||||
|
||||
QString m_posInfo;
|
||||
|
||||
// ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
|
||||
public slots:
|
||||
void recordDark(QString path);
|
||||
void recordTarget2csv(int recordTimes, QString path);
|
||||
void autoExpose();
|
||||
|
||||
void OpenFiberImagerAndRecord(QString filePath);
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
void spectalCaptured(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void exposureCompleteSignal(int exposureTime);
|
||||
void startExposureSignal();
|
||||
};
|
||||
85
HPPA/JinspFiberImagerConfig.cpp
Normal file
85
HPPA/JinspFiberImagerConfig.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
#include "JinspFiberImagerConfig.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QDebug>
|
||||
|
||||
const QString JinspFiberImagerConfig::kDefaultPortName = QStringLiteral("COM9");
|
||||
const QString JinspFiberImagerConfig::kConfigFileName = QStringLiteral("jinsp_fiber_imager_config.json");
|
||||
|
||||
JinspFiberImagerConfig::JinspFiberImagerConfig()
|
||||
: m_configFilePath(QCoreApplication::applicationDirPath() + "/" + kConfigFileName)
|
||||
, m_portName(kDefaultPortName)
|
||||
{
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
JinspFiberImagerConfig& JinspFiberImagerConfig::instance()
|
||||
{
|
||||
static JinspFiberImagerConfig s;
|
||||
return s;
|
||||
}
|
||||
|
||||
QString JinspFiberImagerConfig::portName() const
|
||||
{
|
||||
return m_portName;
|
||||
}
|
||||
|
||||
void JinspFiberImagerConfig::setPortName(const QString& port)
|
||||
{
|
||||
if (m_portName != port)
|
||||
{
|
||||
m_portName = port;
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
void JinspFiberImagerConfig::loadConfig()
|
||||
{
|
||||
QFile file(m_configFilePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug() << "JinspFiberImagerConfig: No config file found, using default port:" << kDefaultPortName;
|
||||
saveConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray jsonData = file.readAll();
|
||||
file.close();
|
||||
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonData, &parseError);
|
||||
if (parseError.error != QJsonParseError::NoError)
|
||||
{
|
||||
qWarning() << "JinspFiberImagerConfig: JSON parse error:" << parseError.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject obj = doc.object();
|
||||
if (obj.contains("portName"))
|
||||
{
|
||||
m_portName = obj["portName"].toString(kDefaultPortName);
|
||||
}
|
||||
}
|
||||
|
||||
void JinspFiberImagerConfig::saveConfig()
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj["portName"] = m_portName;
|
||||
|
||||
QJsonDocument doc(obj);
|
||||
|
||||
QFile file(m_configFilePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
qWarning() << "JinspFiberImagerConfig: Failed to open config file for writing:" << m_configFilePath;
|
||||
return;
|
||||
}
|
||||
|
||||
file.write(doc.toJson(QJsonDocument::Indented));
|
||||
file.close();
|
||||
|
||||
qDebug() << "JinspFiberImagerConfig: Config saved to" << m_configFilePath;
|
||||
}
|
||||
26
HPPA/JinspFiberImagerConfig.h
Normal file
26
HPPA/JinspFiberImagerConfig.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
class JinspFiberImagerConfig
|
||||
{
|
||||
public:
|
||||
static JinspFiberImagerConfig& instance();
|
||||
|
||||
QString portName() const;
|
||||
void setPortName(const QString& port);
|
||||
|
||||
static const QString kDefaultPortName;
|
||||
static const QString kConfigFileName;
|
||||
|
||||
private:
|
||||
JinspFiberImagerConfig();
|
||||
JinspFiberImagerConfig(const JinspFiberImagerConfig&) = delete;
|
||||
JinspFiberImagerConfig& operator=(const JinspFiberImagerConfig&) = delete;
|
||||
|
||||
QString m_configFilePath;
|
||||
QString m_portName;
|
||||
|
||||
void loadConfig();
|
||||
void saveConfig();
|
||||
};
|
||||
@ -16,6 +16,19 @@ OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
|
||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
|
||||
// 从 AppSettings 读取速度参数
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
ui.speed_lineEdit->setText(QString::number(settings.scanSpeed()));
|
||||
ui.return_speed_lineEdit->setText(QString::number(settings.returnSpeed()));
|
||||
|
||||
// 连接信号,当控件数值变化时保存到 AppSettings
|
||||
connect(ui.speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setScanSpeed(ui.speed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.return_speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setReturnSpeed(ui.return_speed_lineEdit->text().toDouble());
|
||||
});
|
||||
}
|
||||
|
||||
OneMotorControl::~OneMotorControl()
|
||||
@ -25,13 +38,26 @@ OneMotorControl::~OneMotorControl()
|
||||
}
|
||||
|
||||
void OneMotorControl::onConnectMotor()
|
||||
{
|
||||
connectMotor(true);
|
||||
}
|
||||
|
||||
void OneMotorControl::setScanSpeed(double speed)
|
||||
{
|
||||
ui.speed_lineEdit->setText(QString::number(speed));
|
||||
}
|
||||
|
||||
void OneMotorControl::connectMotor(bool isNotification)
|
||||
{
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||
msgBox.exec();
|
||||
if (isNotification)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||
msgBox.exec();
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -202,12 +228,22 @@ void OneMotorControl::record_white()
|
||||
|
||||
void OneMotorControl::run()
|
||||
{
|
||||
if (m_coordinator)//当高光谱相机停止采集后,马达还未回到原点时,上次任务的m_coordinator还没有被销毁
|
||||
{
|
||||
onSequenceComplete_motorBack2Origin(0);
|
||||
}
|
||||
|
||||
qRegisterMetaType<OneMotionCapturePathLine>("OneMotionCapturePathLine");
|
||||
m_coordinator = new OneMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
connect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
|
||||
connect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
|
||||
m_coordinator->setObjectName("testOneMotionCaptureCoordinator");
|
||||
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int)));
|
||||
connect(this, &OneMotorControl::start, m_coordinator, &OneMotionCaptureCoordinator::startStepMotion);
|
||||
connect(this, &OneMotorControl::stopStepMotionSignal, m_coordinator, &OneMotionCaptureCoordinator::stopStepMotion);
|
||||
|
||||
connect(m_coordinator, &OneMotionCaptureCoordinator::sequenceCompleteSignal_hyperImagerStopRecord,
|
||||
this, &OneMotorControl::sequenceCompleteSignal_hyperImagerStopRecord);
|
||||
connect(m_coordinator, &OneMotionCaptureCoordinator::sequenceCompleteSignal_motorBack2Origin,
|
||||
this, &OneMotorControl::onSequenceComplete_motorBack2Origin);
|
||||
|
||||
OneMotionCapturePathLine tmp;
|
||||
tmp.speedRecord = ui.speed_lineEdit->text().toDouble();
|
||||
@ -221,13 +257,37 @@ void OneMotorControl::stop()
|
||||
emit stopStepMotionSignal();
|
||||
}
|
||||
|
||||
void OneMotorControl::onSequenceComplete(int state)
|
||||
void OneMotorControl::multiPosHyperAutoExposure()
|
||||
{
|
||||
emit sequenceComplete();
|
||||
//所有该自动曝光的位置
|
||||
std::vector<double> maxRangeLocations = m_multiAxisController->getMaxPos();
|
||||
double maxPos = maxRangeLocations[0];
|
||||
|
||||
disconnect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
|
||||
disconnect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
|
||||
disconnect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int)));
|
||||
std::vector<double> locations;
|
||||
locations.push_back(maxPos * 0.2);
|
||||
locations.push_back(maxPos * 0.5);
|
||||
locations.push_back(maxPos * 0.8);
|
||||
|
||||
//创建协调器,并连接信号槽
|
||||
m_coordinator_gonggashan_autoexpose = new OneMotorMultiPosCoordinator(m_multiAxisController, m_Imager);
|
||||
|
||||
//connect(this, SIGNAL(stopStepMotionSignal()), m_coordinator_gonggashan_autoexpose, SLOT(stopStepMotion()));
|
||||
connect(m_coordinator_gonggashan_autoexpose, &OneMotorMultiPosCoordinator::sequenceComplete, this, &OneMotorControl::onSequenceComplete_gonggashan_autoexpose);
|
||||
connect(m_coordinator_gonggashan_autoexpose, &OneMotorMultiPosCoordinator::hyperAutoExposureDoneSignal, this, &OneMotorControl::hyperAutoExposureDoneSignal_gonggashan);
|
||||
|
||||
m_coordinator_gonggashan_autoexpose->startStepMotion(ui.speed_lineEdit->text().toDouble(), locations);
|
||||
}
|
||||
|
||||
void OneMotorControl::onSequenceComplete_gonggashan_autoexpose(int state)
|
||||
{
|
||||
emit multiPosAutoexposeSequenceCompleteSignal();
|
||||
|
||||
m_coordinator_gonggashan_autoexpose->deleteLater();
|
||||
}
|
||||
|
||||
void OneMotorControl::onSequenceComplete_motorBack2Origin(int state)
|
||||
{
|
||||
emit sequenceComplete_motorBack2Origin();
|
||||
|
||||
// Use deleteLater() instead of delete: this slot may have been called directly
|
||||
// from OneMotionCaptureCoordinator's call stack (direct connection), so deleting
|
||||
@ -240,3 +300,278 @@ bool OneMotorControl::getMotorsConnectionStatus()
|
||||
{
|
||||
return m_xMotorConnectionStatus;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
OneMotorControl_LiftingPlatform::OneMotorControl_LiftingPlatform(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
|
||||
|
||||
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||
connect(this->ui.left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
||||
connect(this->ui.left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||
|
||||
connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||
|
||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
|
||||
// 从 AppSettings 读取速度参数
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
ui.speed_lineEdit->setText(QString::number(settings.scanSpeed()));
|
||||
ui.return_speed_lineEdit->setText(QString::number(settings.returnSpeed()));
|
||||
|
||||
// 连接信号,当控件数值变化时保存到 AppSettings
|
||||
connect(ui.speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setScanSpeed(ui.speed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.return_speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setReturnSpeed(ui.return_speed_lineEdit->text().toDouble());
|
||||
});
|
||||
}
|
||||
|
||||
OneMotorControl_LiftingPlatform::~OneMotorControl_LiftingPlatform()
|
||||
{
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onConnectMotor()
|
||||
{
|
||||
connectMotor(true);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::connectMotor(bool isNotification)
|
||||
{
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
if (isNotification)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||
msgBox.exec();
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_multiAxisController != nullptr)
|
||||
{
|
||||
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
disconnect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
disconnect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
disconnect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
disconnect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
m_multiAxisController = nullptr;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_LiftingPlatform.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
|
||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
|
||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
this->ui.realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
|
||||
emit broadcastLocationSignal(loc);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::display_motors_connectivity(std::vector<int> connectivity)
|
||||
{
|
||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||
if (connectivity[0])
|
||||
{
|
||||
m_xMotorConnectionStatus = true;
|
||||
|
||||
this->ui.motor_state_label->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: #08FACE;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xMotorConnectionStatus = false;
|
||||
|
||||
this->ui.motor_state_label->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
this->ui.connect_btn->setText(QString::fromLocal8Bit("已连接"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.connect_btn->setText(QString::fromLocal8Bit("重新连接"));
|
||||
}
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::zeroStart()
|
||||
{
|
||||
zeroStartSignal(0);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onx_rangeMeasurement()
|
||||
{
|
||||
double s0 = ui.speed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(0, s0, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onxMove2Loc()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(0, l, s, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onxMotorRight()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, false, s, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onxMotorLeft()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, true, s, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onxMotorStop()
|
||||
{
|
||||
emit stopSignal(0);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::run()
|
||||
{
|
||||
m_coordinator = new OneMotionCoordinator(m_multiAxisController,this);
|
||||
connect(m_coordinator, &OneMotionCoordinator::sequenceComplete, this, &OneMotorControl_LiftingPlatform::sequenceComplete);
|
||||
connect(m_coordinator, &OneMotionCoordinator::ArrivalSignal, this, &OneMotorControl_LiftingPlatform::onBack2Origin);
|
||||
|
||||
double plantDepthValue = DepthValueLogger::instance().readLatestPlantDepthValue();
|
||||
double liftingPlatformDepthValue = DepthValueLogger::instance().readLatestLiftingPlatformDepthValue();
|
||||
double targetDepth = liftingPlatformDepthValue - plantDepthValue;
|
||||
|
||||
if (targetDepth < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_coordinator->moveToTarget(targetDepth, ui.speed_lineEdit->text().toDouble());
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::stop()
|
||||
{
|
||||
emit stopStepMotionSignal();
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onBack2Origin(double pos)
|
||||
{
|
||||
emit back2OriginSignal_TimedDataCollection();
|
||||
|
||||
m_coordinator->deleteLater();
|
||||
m_coordinator = nullptr;
|
||||
}
|
||||
|
||||
bool OneMotorControl_LiftingPlatform::getMotorsConnectionStatus()
|
||||
{
|
||||
return m_xMotorConnectionStatus;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
|
||||
#include "ui_oneMotorControl.h"
|
||||
|
||||
@ -8,6 +9,9 @@
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
#include "MotorWindowBase.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
#include "DepthValueLogger.h"
|
||||
|
||||
class OneMotorControl : public QDialog, public MotorWindowBase
|
||||
{
|
||||
@ -22,11 +26,17 @@ public:
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
void multiPosHyperAutoExposure();
|
||||
|
||||
void record_dark();
|
||||
void record_white();
|
||||
|
||||
bool getMotorsConnectionStatus();
|
||||
|
||||
void connectMotor(bool isNotification);
|
||||
|
||||
void setScanSpeed(double speed);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
|
||||
@ -40,7 +50,8 @@ public Q_SLOTS:
|
||||
void onxMotorLeft();
|
||||
void onxMotorStop();
|
||||
|
||||
void onSequenceComplete(int state);
|
||||
void onSequenceComplete_motorBack2Origin(int state);
|
||||
void onSequenceComplete_gonggashan_autoexpose(int state);
|
||||
|
||||
signals:
|
||||
void moveSignal(int, bool, double, int);
|
||||
@ -56,20 +67,89 @@ signals:
|
||||
void stopStepMotionSignal();
|
||||
|
||||
void sequenceComplete();
|
||||
void sequenceComplete_motorBack2Origin();
|
||||
|
||||
void broadcastLocationSignal(std::vector<double>);
|
||||
|
||||
void hyperAutoExposureDoneSignal_gonggashan(double exposureTime, double frameRate);
|
||||
|
||||
void multiPosAutoexposeSequenceCompleteSignal();
|
||||
|
||||
void sequenceCompleteSignal_hyperImagerStopRecord(int);
|
||||
|
||||
private:
|
||||
Ui::OneMotorControl_UI ui;
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController = nullptr;
|
||||
|
||||
OneMotionCaptureCoordinator* m_coordinator = nullptr;
|
||||
QPointer<OneMotionCaptureCoordinator> m_coordinator;
|
||||
ImagerOperationBase* m_Imager;
|
||||
|
||||
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||
|
||||
bool m_xMotorConnectionStatus = false;
|
||||
|
||||
QPointer<OneMotorMultiPosCoordinator> m_coordinator_gonggashan_autoexpose;
|
||||
};
|
||||
|
||||
class OneMotorControl_LiftingPlatform : public QDialog, public MotorWindowBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OneMotorControl_LiftingPlatform(QWidget* parent = nullptr);
|
||||
~OneMotorControl_LiftingPlatform();
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
bool getMotorsConnectionStatus();
|
||||
|
||||
void connectMotor(bool isNotification);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
|
||||
void display_x_loc(std::vector<double> loc);
|
||||
void display_motors_connectivity(std::vector<int> connectivity);
|
||||
void onxMove2Loc();
|
||||
void zeroStart();
|
||||
void onx_rangeMeasurement();
|
||||
|
||||
void onxMotorRight();
|
||||
void onxMotorLeft();
|
||||
void onxMotorStop();
|
||||
|
||||
void onBack2Origin(double pos);
|
||||
|
||||
signals:
|
||||
void moveSignal(int, bool, double, int);
|
||||
void move2LocSignal(int, double, double, int);
|
||||
void move2LocSignal(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopSignal(int);
|
||||
|
||||
void rangeMeasurement(int, double, int);
|
||||
void zeroStartSignal(int);
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void start(OneMotionCapturePathLine);
|
||||
void stopStepMotionSignal();
|
||||
|
||||
void sequenceComplete(int status);
|
||||
void back2OriginSignal_TimedDataCollection();
|
||||
|
||||
void broadcastLocationSignal(std::vector<double>);
|
||||
|
||||
|
||||
private:
|
||||
Ui::OneMotorControl_UI ui;
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController = nullptr;
|
||||
|
||||
QPointer<OneMotionCoordinator> m_coordinator;
|
||||
|
||||
bool m_xMotorConnectionStatus = false;
|
||||
};
|
||||
|
||||
@ -5,11 +5,39 @@
|
||||
#include "MultibandRasterRenderer.h"
|
||||
#include "SinglebandRasterRenderer.h"
|
||||
|
||||
RasterImageLayer::RasterImageLayer(RasterLayer* layer, RendererType type)
|
||||
RasterImageLayer::RasterImageLayer(RasterLayer* layer, RendererType type, bool initRenderParamsFromFile)
|
||||
: m_layer(layer)
|
||||
, m_rendererType(type)
|
||||
, m_rendererInitialized(false)
|
||||
{
|
||||
if (initRenderParamsFromFile)
|
||||
{
|
||||
// 此处根据头文件(打开影像文件)修改默认渲染波段,只对打开文件的情况下有效;
|
||||
// 当边采集边显示时(initRenderParamsFromFile设置为false),应该在实例化RasterImageLayer后调用setMultibandParams设置默认渲染波段
|
||||
try
|
||||
{
|
||||
if (!m_layer) return;
|
||||
|
||||
std::vector<double> wavelengths = m_layer->bandWavelengths();
|
||||
if (wavelengths.empty()) return;
|
||||
|
||||
std::sort(wavelengths.begin(), wavelengths.end());
|
||||
double m_minWave = wavelengths.front();
|
||||
double m_maxWave = wavelengths.back();
|
||||
|
||||
if (m_minWave > 800 && m_maxWave > 1600)
|
||||
{
|
||||
m_multibandParams.rWave = 1500;
|
||||
m_multibandParams.gWave = 1300;
|
||||
m_multibandParams.bWave = 1100;
|
||||
}
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RasterImageLayer::ensureRenderer()
|
||||
|
||||
@ -19,7 +19,7 @@ public:
|
||||
Singleband
|
||||
};
|
||||
|
||||
RasterImageLayer(RasterLayer* layer, RendererType type);
|
||||
RasterImageLayer(RasterLayer* layer, RendererType type, bool initRenderParamsFromFile);
|
||||
~RasterImageLayer();
|
||||
|
||||
void ensureRenderer();
|
||||
|
||||
@ -104,20 +104,25 @@ void ResononNirImager::setSpectraBin(int new_spectral_bin)
|
||||
double ResononNirImager::auto_exposure()
|
||||
{
|
||||
//第一步:先设置曝光时间为在当前帧率情况下最大
|
||||
double x = 1 / getFramerate() * 1000;//获取最大毫秒曝光时间
|
||||
double f = getFramerate();
|
||||
double x = 1 / f * 1000;//获取最大毫秒曝光时间
|
||||
std::cout << f << "hz帧率下,最大曝光时间为" << x << std::endl;
|
||||
|
||||
reConnectImage();
|
||||
setIntegrationTime(x);
|
||||
|
||||
//第二步:通过循环寻找最佳曝光时间
|
||||
imagerStartCollect();
|
||||
|
||||
double tmpTime;
|
||||
while (true)
|
||||
{
|
||||
getFrame(buffer);
|
||||
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
|
||||
if (GetMaxValue(buffer, m_FrameSize) >= 16383)
|
||||
{
|
||||
setIntegrationTime(getIntegrationTime() * 0.8);
|
||||
std::cout << "自动曝光-----------" << std::endl;
|
||||
tmpTime = getIntegrationTime() * 0.8;
|
||||
setIntegrationTime(tmpTime);
|
||||
std::cout << "自动曝光-----------:" << tmpTime << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -128,9 +133,28 @@ double ResononNirImager::auto_exposure()
|
||||
reConnectImage();
|
||||
//imagerStopCollect();
|
||||
|
||||
//std::cout << "自动曝光:" << getIntegrationTime() << std::endl;
|
||||
double exposureTime = getIntegrationTime();
|
||||
emit autoExposureSignal(exposureTime);
|
||||
|
||||
return getIntegrationTime();
|
||||
//std::cout << "自动曝光:" << exposureTime << std::endl;
|
||||
|
||||
return exposureTime;
|
||||
}
|
||||
|
||||
unsigned short ResononNirImager::GetMaxValue(unsigned short* dark, int number)
|
||||
{
|
||||
unsigned int max = 0;
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
if (dark[i] > 16383) continue;//IR L为14位
|
||||
|
||||
if (dark[i] > max)
|
||||
{
|
||||
max = dark[i];
|
||||
}
|
||||
}
|
||||
std::cout << "本帧最大值为" << max << std::endl;
|
||||
return max;
|
||||
}
|
||||
|
||||
double ResononNirImager::getWavelengthAtBand(int band)
|
||||
@ -290,7 +314,7 @@ void ResononNirImager::start_record()
|
||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||
QString baseName = QString::fromStdString(getFileNameFromPath(m_FileName2Save2));
|
||||
QString filePath = QString::fromStdString(m_FileName2Save2);
|
||||
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter);
|
||||
emit LayerFileCreated(baseName, filePath, m_FileSavedCounter, "nearInfrared");
|
||||
|
||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||
|
||||
@ -352,7 +376,8 @@ void ResononNirImager::start_record()
|
||||
fprintf(hTimesFile, "%ll\n", timeOs);
|
||||
|
||||
//将rgb波段提取出来,以便在界面中显示
|
||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
//需要修改函数m_RgbImage->FillRgbImage,接收参数:提取rgb的偏移,参数由相机类型、单帧大小、波长范围等确定
|
||||
m_RgbImage->FillRgbImage(buffer, 172, 112, 52);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
|
||||
//std::cout << "第" << m_iFrameCounter << "帧写了" << x << "个unsigned short。" << std::endl;
|
||||
|
||||
@ -408,7 +433,7 @@ void ResononNirImager::WriteHdr()
|
||||
outfile << "ENVI\n";
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "bit depth = 14\n";
|
||||
outfile << "byte order = 0\n";
|
||||
outfile << "samples = " << getSampleCount() << "\n";
|
||||
outfile << "bands = " << getBandCount() << "\n";
|
||||
|
||||
@ -38,6 +38,8 @@ public:
|
||||
void WriteHdr();
|
||||
|
||||
protected:
|
||||
unsigned short GetMaxValue(unsigned short* dark, int number);
|
||||
|
||||
private:
|
||||
void reConnectImage();
|
||||
|
||||
|
||||
246
HPPA/RgbCameraCaptureCoordinator.cpp
Normal file
246
HPPA/RgbCameraCaptureCoordinator.cpp
Normal file
@ -0,0 +1,246 @@
|
||||
#include "stdafx.h"
|
||||
#include "RgbCameraCaptureCoordinator.h"
|
||||
#include "RgbCameraOperation.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
RgbCameraCaptureCoordinator::RgbCameraCaptureCoordinator(RgbCameraOperation* rgbCamera, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_rgbCamera(rgbCamera)
|
||||
, m_captureMode(None)
|
||||
, m_isCapturing(false)
|
||||
, m_isCameraOpened(false)
|
||||
, m_pendingOpenCamera(false)
|
||||
, m_pendingMode(None)
|
||||
{
|
||||
if (m_rgbCamera)
|
||||
{
|
||||
connect(m_rgbCamera, &RgbCameraOperation::CamOpenedSignal,
|
||||
this, &RgbCameraCaptureCoordinator::onCameraOpened);
|
||||
connect(m_rgbCamera, &RgbCameraOperation::CamClosedSignal,
|
||||
this, &RgbCameraCaptureCoordinator::onCameraClosed);
|
||||
connect(m_rgbCamera, &RgbCameraOperation::VideoRecordingStartedSignal,
|
||||
this, &RgbCameraCaptureCoordinator::onVideoRecordingStarted);
|
||||
connect(m_rgbCamera, &RgbCameraOperation::VideoRecordingStoppedSignal,
|
||||
this, &RgbCameraCaptureCoordinator::onVideoRecordingStopped);
|
||||
|
||||
connect(this, &RgbCameraCaptureCoordinator::openCameraSignal,
|
||||
m_rgbCamera, &RgbCameraOperation::OpenCamera, Qt::QueuedConnection);
|
||||
connect(this, &RgbCameraCaptureCoordinator::closeCameraSignal,
|
||||
m_rgbCamera, &RgbCameraOperation::CloseCamera, Qt::QueuedConnection);
|
||||
connect(this, &RgbCameraCaptureCoordinator::startVideoRecordingSignal,
|
||||
m_rgbCamera, &RgbCameraOperation::startVideoRecording, Qt::QueuedConnection);
|
||||
connect(this, &RgbCameraCaptureCoordinator::stopVideoRecordingSignal,
|
||||
m_rgbCamera, &RgbCameraOperation::stopVideoRecording, Qt::QueuedConnection);
|
||||
connect(this, &RgbCameraCaptureCoordinator::startPhotoSaveTimerSignal,
|
||||
m_rgbCamera, &RgbCameraOperation::startPhotoSaveTimer, Qt::QueuedConnection);
|
||||
connect(this, &RgbCameraCaptureCoordinator::stopPhotoSaveTimerSignal,
|
||||
m_rgbCamera, &RgbCameraOperation::stopPhotoSaveTimer, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
RgbCameraCaptureCoordinator::~RgbCameraCaptureCoordinator()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::startVideoCapture()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isCapturing)
|
||||
{
|
||||
if (m_captureMode == Video)
|
||||
{
|
||||
//emit errorOccurred(QStringLiteral("视频正在采集中"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//emit errorOccurred(QStringLiteral("正在执行其他采集操作"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_pendingOpenCamera = true;
|
||||
m_pendingMode = Video;
|
||||
|
||||
openCamera();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::stopVideoCapture()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_captureMode != Video || !m_isCapturing)
|
||||
{
|
||||
//emit errorOccurred(QStringLiteral("视频未在采集中"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_rgbCamera)
|
||||
{
|
||||
emit stopVideoRecordingSignal();
|
||||
closeCamera();
|
||||
}
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::startPhotoCapture()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isCapturing)
|
||||
{
|
||||
if (m_captureMode == Photo)
|
||||
{
|
||||
//emit errorOccurred(QStringLiteral("照片正在采集中"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//emit errorOccurred(QStringLiteral("正在执行其他采集操作"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_pendingOpenCamera = true;
|
||||
m_pendingMode = Photo;
|
||||
|
||||
openCamera();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::stopPhotoCapture()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_captureMode != Photo || !m_isCapturing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
emit stopPhotoSaveTimerSignal();
|
||||
emit captureStopped(Photo);
|
||||
closeCamera();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::openCamera()
|
||||
{
|
||||
if (!m_rgbCamera)
|
||||
{
|
||||
emit cameraOpenFailed(QStringLiteral("RGB相机对象未初始化"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isCameraOpened)
|
||||
{
|
||||
onCameraOpened();
|
||||
return;
|
||||
}
|
||||
|
||||
emit openCameraSignal();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::closeCamera()
|
||||
{
|
||||
if (!m_rgbCamera)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isCameraOpened)
|
||||
{
|
||||
emit closeCameraSignal();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isCameraOpened = false;
|
||||
m_isCapturing = false;
|
||||
m_captureMode = None;
|
||||
}
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::cleanup()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_rgbCamera && m_isCapturing)
|
||||
{
|
||||
if (m_captureMode == Video)
|
||||
{
|
||||
emit stopVideoRecordingSignal();
|
||||
}
|
||||
}
|
||||
|
||||
closeCamera();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::onCameraOpened()
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
m_isCameraOpened = true;
|
||||
emit cameraOpened();
|
||||
|
||||
qDebug() << "Camera opened. Pending open camera: " << m_pendingOpenCamera << ", Pending mode: " << m_pendingMode;
|
||||
if (!m_pendingOpenCamera)
|
||||
{
|
||||
return;
|
||||
}
|
||||
qDebug() << "Camera opened. Pending open camera: --------------------------------------------";
|
||||
|
||||
m_pendingOpenCamera = false;
|
||||
CaptureMode mode = m_pendingMode;
|
||||
m_pendingMode = None;
|
||||
|
||||
m_captureMode = mode;
|
||||
m_isCapturing = true;
|
||||
|
||||
if (mode == Video)
|
||||
{
|
||||
emit startVideoRecordingSignal();
|
||||
}
|
||||
else if (mode == Photo)
|
||||
{
|
||||
emit captureStarted(Photo);
|
||||
emit startPhotoSaveTimerSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::onCameraClosed()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
m_isCameraOpened = false;
|
||||
|
||||
CaptureMode previousMode = m_captureMode;
|
||||
|
||||
if (m_isCapturing)
|
||||
{
|
||||
emit captureStopped(previousMode);
|
||||
}
|
||||
|
||||
m_isCapturing = false;
|
||||
m_captureMode = None;
|
||||
|
||||
emit cameraClosed();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::onVideoRecordingStarted()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
emit captureStarted(Video);
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::onVideoRecordingStopped()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
emit captureStopped(Video);
|
||||
|
||||
emit stopVideoRecordingSignal();
|
||||
closeCamera();
|
||||
}
|
||||
|
||||
void RgbCameraCaptureCoordinator::onPhotoCaptured()
|
||||
{
|
||||
}
|
||||
69
HPPA/RgbCameraCaptureCoordinator.h
Normal file
69
HPPA/RgbCameraCaptureCoordinator.h
Normal file
@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
|
||||
class RgbCameraOperation;
|
||||
|
||||
class RgbCameraCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum CaptureMode { None = 0, Video, Photo };
|
||||
Q_ENUM(CaptureMode)
|
||||
|
||||
explicit RgbCameraCaptureCoordinator(RgbCameraOperation* rgbCamera, QObject* parent = nullptr);
|
||||
~RgbCameraCaptureCoordinator();
|
||||
|
||||
// 视频采集控制
|
||||
Q_INVOKABLE void startVideoCapture();
|
||||
Q_INVOKABLE void stopVideoCapture();
|
||||
|
||||
// 照片采集控制
|
||||
Q_INVOKABLE void startPhotoCapture();
|
||||
Q_INVOKABLE void stopPhotoCapture();
|
||||
|
||||
// 状态查询
|
||||
CaptureMode getCurrentMode() const { return m_captureMode; }
|
||||
bool isCapturing() const { return m_isCapturing; }
|
||||
bool isCameraOpened() const { return m_isCameraOpened; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void captureStarted(CaptureMode mode);
|
||||
void captureStopped(CaptureMode mode);
|
||||
void cameraOpened();
|
||||
void cameraClosed();
|
||||
void cameraOpenFailed(const QString& error);
|
||||
void errorOccurred(const QString& error);
|
||||
void photoCaptured(const QString& filePath);
|
||||
|
||||
void openCameraSignal();
|
||||
void closeCameraSignal();
|
||||
void startVideoRecordingSignal();
|
||||
void stopVideoRecordingSignal();
|
||||
void startPhotoSaveTimerSignal();
|
||||
void stopPhotoSaveTimerSignal();
|
||||
|
||||
public Q_SLOTS:
|
||||
void openCamera();
|
||||
void closeCamera();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCameraOpened();
|
||||
void onCameraClosed();
|
||||
void onVideoRecordingStarted();
|
||||
void onVideoRecordingStopped();
|
||||
void onPhotoCaptured();
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
RgbCameraOperation* m_rgbCamera;
|
||||
CaptureMode m_captureMode;
|
||||
bool m_isCapturing;
|
||||
bool m_isCameraOpened;
|
||||
bool m_pendingOpenCamera;//指示相机是否是带目的的打开:带目的打开true(打开就要录像+m_pendingMode),还是手动打开(false,不带目的)
|
||||
CaptureMode m_pendingMode;
|
||||
mutable QMutex m_dataMutex;
|
||||
};
|
||||
@ -1,15 +1,55 @@
|
||||
#include "stdafx.h"
|
||||
#include "RgbCameraOperation.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
RgbCameraOperation::RgbCameraOperation()
|
||||
{
|
||||
cam = nullptr;
|
||||
m_ImageProcessor = new ImageProcessor();
|
||||
m_func = nullptr;
|
||||
m_videoWriter = nullptr;
|
||||
m_isRecording = false;
|
||||
|
||||
m_captureTimer = new QTimer(this);
|
||||
connect(m_captureTimer, &QTimer::timeout, this, &RgbCameraOperation::onCaptureFrame);
|
||||
|
||||
m_photoSaveTimer = new QTimer(this);
|
||||
m_photoSaveTimer->setSingleShot(false);
|
||||
connect(m_photoSaveTimer, &QTimer::timeout, this, &RgbCameraOperation::onPhotoSaveTimeout);
|
||||
}
|
||||
|
||||
RgbCameraOperation::~RgbCameraOperation()
|
||||
{
|
||||
if (m_photoSaveTimer != nullptr)
|
||||
{
|
||||
m_photoSaveTimer->stop();
|
||||
//delete m_photoSaveTimer;
|
||||
m_photoSaveTimer = nullptr;
|
||||
}
|
||||
|
||||
if (m_captureTimer != nullptr)
|
||||
{
|
||||
m_captureTimer->stop();
|
||||
//delete m_captureTimer;
|
||||
m_captureTimer = nullptr;
|
||||
}
|
||||
|
||||
if (m_videoWriter != nullptr)
|
||||
{
|
||||
if (m_isRecording)
|
||||
{
|
||||
m_videoWriter->release();
|
||||
}
|
||||
delete m_videoWriter;
|
||||
m_videoWriter = nullptr;
|
||||
}
|
||||
|
||||
if (cam != nullptr)
|
||||
{
|
||||
cam->release();
|
||||
delete cam;
|
||||
cam = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void RgbCameraOperation::OpenCamera()
|
||||
@ -17,21 +57,80 @@ void RgbCameraOperation::OpenCamera()
|
||||
std::cout << "打开摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||
cam = new cv::VideoCapture(0);
|
||||
|
||||
// 设置摄像头分辨率为最高可用分辨率
|
||||
int width = 640;//1920
|
||||
int height = 480;//1080
|
||||
cam->set(cv::CAP_PROP_FRAME_WIDTH, width);
|
||||
cam->set(cv::CAP_PROP_FRAME_HEIGHT, height);
|
||||
|
||||
// 验证实际设置的分辨率
|
||||
double actualWidth = cam->get(cv::CAP_PROP_FRAME_WIDTH);
|
||||
double actualHeight = cam->get(cv::CAP_PROP_FRAME_HEIGHT);
|
||||
std::cout << "摄像头分辨率设置为: " << actualWidth << "x" << actualHeight << std::endl;
|
||||
|
||||
record = true;
|
||||
|
||||
while (record)
|
||||
{
|
||||
//std::cout << "采集影像+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||
cam->read(frame);
|
||||
m_qImage = m_ImageProcessor->Mat2QImage(frame);
|
||||
// 使用定时器定期获取图像,不再阻塞线程
|
||||
m_captureTimer->start(33); // ~30fps
|
||||
m_frameCounter = 0;
|
||||
}
|
||||
|
||||
emit PlotSignal();
|
||||
void RgbCameraOperation::onCaptureFrame()
|
||||
{
|
||||
if (!record || cam == nullptr || !cam->isOpened())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cam->release();
|
||||
cam->read(frame);
|
||||
m_frameCounter++;
|
||||
if (m_frameCounter == 1)
|
||||
{
|
||||
emit CamOpenedSignal();
|
||||
}
|
||||
|
||||
emit CamOpenedSignal();
|
||||
// 保存视频逻辑:如果正在录制,将当前帧写入视频
|
||||
if (m_isRecording && m_videoWriter != nullptr && !frame.empty())
|
||||
{
|
||||
m_videoWriter->write(frame);
|
||||
}
|
||||
|
||||
m_qImage = m_ImageProcessor->Mat2QImage(frame.clone());
|
||||
emit PlotSignal();
|
||||
}
|
||||
|
||||
void RgbCameraOperation::onPhotoSaveTimeout()
|
||||
{
|
||||
if (m_qImage.isNull())
|
||||
{
|
||||
std::cerr << "保存图片失败:当前没有可用的图像数据" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss_zzz");
|
||||
QString prefix = AppSettings::instance().rgbCameraFileName();
|
||||
QString fileName = QString("%1_rgb_%2.jpg").arg(prefix).arg(timestamp);
|
||||
QString fullPath = AppSettings::instance().rgbCameraDataFolder() + QDir::separator() + fileName;
|
||||
|
||||
if (m_qImage.save(fullPath, "JPG", 95))
|
||||
{
|
||||
std::cout << "图片已保存: " << fullPath.toStdString() << std::endl;
|
||||
emit photoSavedSignal(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "保存图片失败: " << fullPath.toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void RgbCameraOperation::startPhotoSaveTimer()
|
||||
{
|
||||
m_photoSaveTimer->start(2000); // 每2秒保存一张照片
|
||||
}
|
||||
|
||||
void RgbCameraOperation::stopPhotoSaveTimer()
|
||||
{
|
||||
m_photoSaveTimer->stop();
|
||||
}
|
||||
|
||||
void RgbCameraOperation::OpenCamera_callback()
|
||||
@ -66,5 +165,117 @@ void RgbCameraOperation::CloseCamera()
|
||||
|
||||
record = false;
|
||||
|
||||
// 停止定时器
|
||||
m_captureTimer->stop();
|
||||
m_photoSaveTimer->stop();
|
||||
|
||||
// 停止视频录制
|
||||
if (m_isRecording)
|
||||
{
|
||||
stopVideoRecording();
|
||||
}
|
||||
|
||||
// 释放摄像头
|
||||
if (cam != nullptr)
|
||||
{
|
||||
cam->release();
|
||||
//delete cam;
|
||||
cam = nullptr;
|
||||
}
|
||||
|
||||
emit CamClosedSignal();
|
||||
}
|
||||
|
||||
void RgbCameraOperation::saveImage()
|
||||
{
|
||||
if (m_qImage.isNull())
|
||||
{
|
||||
std::cerr << "保存图片失败:当前没有可用的图像数据" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// 生成带时间戳的文件名
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss_zzz");
|
||||
QString prefix = AppSettings::instance().rgbCameraFileName();
|
||||
QString fileName = QString("%1_rgb_%2.jpg").arg(prefix).arg(timestamp);
|
||||
QString fullPath = AppSettings::instance().rgbCameraDataFolder() + QDir::separator() + fileName;
|
||||
|
||||
// 保存为 JPG 格式
|
||||
if (m_qImage.save(fullPath, "JPG", 95))
|
||||
{
|
||||
std::cout << "图片已保存: " << fullPath.toStdString() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "保存图片失败: " << fullPath.toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void RgbCameraOperation::startVideoRecording()
|
||||
{
|
||||
if (m_isRecording)
|
||||
{
|
||||
std::cout << "视频已经在录制中" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (frame.empty())
|
||||
{
|
||||
std::cerr << "开始录制失败:当前没有可用的帧数据" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// 释放旧的 VideoWriter
|
||||
if (m_videoWriter != nullptr)
|
||||
{
|
||||
delete m_videoWriter;
|
||||
m_videoWriter = nullptr;
|
||||
}
|
||||
|
||||
// 生成带时间戳的视频文件名
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss");
|
||||
QString prefix = AppSettings::instance().rgbCameraFileName();
|
||||
QString fileName = QString("%1_video_%2.avi").arg(prefix).arg(timestamp);
|
||||
QString fullPath = AppSettings::instance().rgbCameraDataFolder() + QDir::separator() + fileName;
|
||||
|
||||
// 获取视频编码器和帧大小
|
||||
int fourcc = cv::VideoWriter::fourcc('M', 'J', 'P', 'G'); // Motion-JPEG 编码器
|
||||
cv::Size frameSize = frame.size();
|
||||
|
||||
// 创建 VideoWriter
|
||||
m_videoWriter = new cv::VideoWriter(fullPath.toStdString(), fourcc, 30.0, frameSize);
|
||||
|
||||
if (!m_videoWriter->isOpened())
|
||||
{
|
||||
std::cerr << "创建视频写入器失败: " << fullPath.toStdString() << std::endl;
|
||||
delete m_videoWriter;
|
||||
m_videoWriter = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
m_isRecording = true;
|
||||
std::cout << "开始录制视频: " << fullPath.toStdString() << std::endl;
|
||||
|
||||
emit VideoRecordingStartedSignal();
|
||||
}
|
||||
|
||||
void RgbCameraOperation::stopVideoRecording()
|
||||
{
|
||||
if (!m_isRecording)
|
||||
{
|
||||
std::cout << "视频没有在录制" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_videoWriter != nullptr)
|
||||
{
|
||||
m_videoWriter->release();
|
||||
//delete m_videoWriter;
|
||||
m_videoWriter = nullptr;
|
||||
}
|
||||
|
||||
m_isRecording = false;
|
||||
std::cout << "停止录制视频" << std::endl;
|
||||
|
||||
emit VideoRecordingStoppedSignal();
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QDir>
|
||||
#include <QDateTime>
|
||||
#include <QCoreApplication>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <QImage>
|
||||
|
||||
@ -24,6 +27,12 @@ public:
|
||||
QImage m_qImage;
|
||||
void setCallback(void(*func)());
|
||||
|
||||
// 保存图片和视频的公共接口
|
||||
void saveImage(); // 保存当前帧为图片
|
||||
void startVideoRecording(); // 开始视频录制
|
||||
void stopVideoRecording(); // 停止视频录制
|
||||
bool isRecording() const { return m_isRecording; } // 获取录制状态
|
||||
|
||||
private:
|
||||
cv::Mat frame;
|
||||
cv::VideoCapture *cam;
|
||||
@ -34,15 +43,33 @@ private:
|
||||
|
||||
bool record;
|
||||
|
||||
// 保存图片和视频相关
|
||||
cv::VideoWriter* m_videoWriter;
|
||||
bool m_isRecording;
|
||||
int m_frameCounter;
|
||||
|
||||
// 定时器获取图像
|
||||
QTimer* m_captureTimer;
|
||||
// 定时器保存照片
|
||||
QTimer* m_photoSaveTimer;
|
||||
|
||||
private slots:
|
||||
void onCaptureFrame();
|
||||
void onPhotoSaveTimeout();
|
||||
|
||||
Q_SIGNALS:
|
||||
void PlotSignal();
|
||||
void CamOpenedSignal();
|
||||
void CamClosedSignal();
|
||||
void VideoRecordingStartedSignal(); // 录制开始信号
|
||||
void VideoRecordingStoppedSignal(); // 录制停止信号
|
||||
void photoSavedSignal(const QString& filePath); // 照片保存成功信号
|
||||
|
||||
public slots:
|
||||
void OpenCamera();
|
||||
void OpenCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
||||
void CloseCamera();
|
||||
|
||||
signals:
|
||||
void PlotSignal();
|
||||
|
||||
void CamOpenedSignal();
|
||||
void CamClosedSignal();
|
||||
void startPhotoSaveTimer();
|
||||
void stopPhotoSaveTimer();
|
||||
};
|
||||
#endif // !RGBCAMERAOPERATION_H
|
||||
|
||||
@ -131,70 +131,70 @@ QVariant TaskTreeModel::data(const QModelIndex& index, int role) const
|
||||
if (node->nodeType == TreeNodeType::Task && node->taskData) {
|
||||
const TimedTask& task = *node->taskData;
|
||||
switch (index.column()) {
|
||||
case ColName:
|
||||
return QString::fromLocal8Bit("定时任务 %1").arg(task.id);
|
||||
case ColScheduledTime:
|
||||
return task.scheduledTime.toString("yyyy-MM-dd HH:mm:ss");
|
||||
case ColCountdown: {
|
||||
if (task.status == TaskStatus::Finished || task.status == TaskStatus::Running)
|
||||
{
|
||||
return QString::fromLocal8Bit("0");
|
||||
case ColName:
|
||||
return QString::fromLocal8Bit("定时任务 %1").arg(task.id);
|
||||
case ColScheduledTime:
|
||||
return task.scheduledTime.toString("yyyy-MM-dd HH:mm:ss");
|
||||
case ColCountdown: {
|
||||
if (task.status == TaskStatus::Finished || task.status == TaskStatus::Running)
|
||||
{
|
||||
return QString::fromLocal8Bit("0");
|
||||
}
|
||||
qint64 seconds = QDateTime::currentDateTime().secsTo(task.scheduledTime);
|
||||
if (seconds < 0)
|
||||
{
|
||||
return QString::fromLocal8Bit("已超时");
|
||||
}
|
||||
return formatCountdown(seconds);
|
||||
}
|
||||
qint64 seconds = QDateTime::currentDateTime().secsTo(task.scheduledTime);
|
||||
if (seconds < 0)
|
||||
{
|
||||
return QString::fromLocal8Bit("已超时");
|
||||
case ColStartTime:
|
||||
return task.startTime.isValid() ?
|
||||
task.startTime.toString("HH:mm:ss") : "-";
|
||||
case ColEndTime:
|
||||
return task.endTime.isValid() ?
|
||||
task.endTime.toString("HH:mm:ss") : "-";
|
||||
case ColDuration:
|
||||
return formatDuration(task.durationMinutes);
|
||||
case ColEstimatedDuration:
|
||||
return formatDuration(task.estimatedDurationMinutes);
|
||||
case ColStatus:
|
||||
return statusToString(task.status);
|
||||
case ColProgress: {
|
||||
int finished = 0;
|
||||
for (const auto& sub : task.subTasks) {
|
||||
if (sub.status == TaskStatus::Finished) finished++;
|
||||
}
|
||||
return QString("%1/%2").arg(finished).arg(task.subTasks.size());
|
||||
}
|
||||
return formatCountdown(seconds);
|
||||
}
|
||||
case ColStartTime:
|
||||
return task.startTime.isValid() ?
|
||||
task.startTime.toString("HH:mm:ss") : "-";
|
||||
case ColEndTime:
|
||||
return task.endTime.isValid() ?
|
||||
task.endTime.toString("HH:mm:ss") : "-";
|
||||
case ColDuration:
|
||||
return formatDuration(task.durationMinutes);
|
||||
case ColEstimatedDuration:
|
||||
return formatDuration(task.estimatedDurationMinutes);
|
||||
case ColStatus:
|
||||
return statusToString(task.status);
|
||||
case ColProgress: {
|
||||
int finished = 0;
|
||||
for (const auto& sub : task.subTasks) {
|
||||
if (sub.status == TaskStatus::Finished) finished++;
|
||||
}
|
||||
return QString("%1/%2").arg(finished).arg(task.subTasks.size());
|
||||
}
|
||||
case ColPath:
|
||||
return task.savePath;
|
||||
case ColPath:
|
||||
return task.savePath;
|
||||
}
|
||||
}
|
||||
else if (node->nodeType == TreeNodeType::SubTask && node->subTaskData) {
|
||||
const SubTask& subTask = *node->subTaskData;
|
||||
switch (index.column()) {
|
||||
case ColName:
|
||||
return subTaskTypeToString(subTask.type);
|
||||
case ColScheduledTime:
|
||||
return "-";
|
||||
case ColCountdown:
|
||||
return "-";
|
||||
case ColStartTime:
|
||||
return subTask.startTime.isValid() ?
|
||||
subTask.startTime.toString("HH:mm:ss") : "-";
|
||||
case ColEndTime:
|
||||
return subTask.endTime.isValid() ?
|
||||
subTask.endTime.toString("HH:mm:ss") : "-";
|
||||
case ColDuration:
|
||||
return formatDuration(subTask.durationMinutes);
|
||||
case ColEstimatedDuration:
|
||||
return formatDuration(subTask.estimatedDurationMinutes);
|
||||
case ColStatus:
|
||||
return statusToString(subTask.status);
|
||||
case ColProgress:
|
||||
return "-";
|
||||
case ColPath:
|
||||
return "-";
|
||||
case ColName:
|
||||
return subTaskTypeToString(subTask.type);
|
||||
case ColScheduledTime:
|
||||
return "-";
|
||||
case ColCountdown:
|
||||
return "-";
|
||||
case ColStartTime:
|
||||
return subTask.startTime.isValid() ?
|
||||
subTask.startTime.toString("HH:mm:ss") : "-";
|
||||
case ColEndTime:
|
||||
return subTask.endTime.isValid() ?
|
||||
subTask.endTime.toString("HH:mm:ss") : "-";
|
||||
case ColDuration:
|
||||
return formatDuration(subTask.durationMinutes);
|
||||
case ColEstimatedDuration:
|
||||
return formatDuration(subTask.estimatedDurationMinutes);
|
||||
case ColStatus:
|
||||
return statusToString(subTask.status);
|
||||
case ColProgress:
|
||||
return "-";
|
||||
case ColPath:
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -587,13 +587,17 @@ QString TaskTreeModel::statusToString(TaskStatus status) const
|
||||
|
||||
QString TaskTreeModel::subTaskTypeToString(SubTaskType type) const
|
||||
{
|
||||
switch (type) {
|
||||
case SubTaskType::HyperSpectual400_1000nm: return QString::fromLocal8Bit("高光谱 400-1000nm");
|
||||
case SubTaskType::HyperSpectual1000_1700nm: return QString::fromLocal8Bit("高光谱 1000-1700nm");
|
||||
case SubTaskType::SingleLensReflex: return QString::fromLocal8Bit("单反相机");
|
||||
case SubTaskType::DepthCamera: return QString::fromLocal8Bit("深度相机");
|
||||
switch (type)
|
||||
{
|
||||
case SubTaskType::HyperSpectual400_1000nm: return QString::fromLocal8Bit("高光谱 400-1000nm");
|
||||
case SubTaskType::HyperSpectual1000_1700nm: return QString::fromLocal8Bit("高光谱 1000-1700nm");
|
||||
case SubTaskType::SingleLensReflex: return QString::fromLocal8Bit("单反相机");
|
||||
case SubTaskType::DepthCamera: return QString::fromLocal8Bit("深度相机");
|
||||
case SubTaskType::ObtainingDepthInformation: return QString::fromLocal8Bit("探测深度信息");
|
||||
case SubTaskType::AutoFocus: return QString::fromLocal8Bit("自动调焦");
|
||||
case SubTaskType::LiftingPlatform: return QString::fromLocal8Bit("升降平台");
|
||||
}
|
||||
return "未知类型";
|
||||
return QString::fromLocal8Bit("未知类型");
|
||||
}
|
||||
|
||||
QString TaskTreeModel::formatDuration(double minutes) const
|
||||
|
||||
@ -112,6 +112,10 @@ void TimedDataCollection::setupConnections()
|
||||
connect(m_scheduler, &TaskScheduler::startRecordSignal,
|
||||
this, &TimedDataCollection::startRecordSignal);
|
||||
|
||||
connect(m_scheduler, &TaskScheduler::ObtainingDepthInformationSignals, this, &TimedDataCollection::ObtainingDepthInformationSignals);
|
||||
connect(m_scheduler, &TaskScheduler::LiftingPlatformSignals, this, &TimedDataCollection::LiftingPlatformSignals);
|
||||
connect(m_scheduler, &TaskScheduler::AutoFocusSignals, this, &TimedDataCollection::AutoFocusSignals);
|
||||
|
||||
connect(m_scheduler, &TaskScheduler::switchHalogenLampSignal,
|
||||
this, &TimedDataCollection::switchHalogenLampSignal);
|
||||
connect(m_scheduler, &TaskScheduler::switchD65LampSignal,
|
||||
@ -416,6 +420,7 @@ void TimedDataCollection::readTimedTaskFromFile(const QString& filePath)
|
||||
double totalEstimatedMinutes = 0.0;
|
||||
for (int j = 0; j < loadedTasks[i].subTasks.size(); ++j)
|
||||
{
|
||||
loadedTasks[i].subTasks[j].durationMinutes = 0.0; // 初始化实际耗时为0
|
||||
QString pathLineFilePath = loadedTasks[i].subTasks[j].pathLineFilePath;
|
||||
if (!pathLineFilePath.isEmpty())
|
||||
{
|
||||
@ -426,6 +431,7 @@ void TimedDataCollection::readTimedTaskFromFile(const QString& filePath)
|
||||
}
|
||||
double slrTimeMinute = 135 / 60;
|
||||
loadedTasks[i].estimatedDurationMinutes = totalEstimatedMinutes + loadedTasks[i].HalogenLampPreheatingTime_Minute + slrTimeMinute;
|
||||
loadedTasks[i].durationMinutes = 0.0; // 初始化实际耗时为0
|
||||
}
|
||||
|
||||
m_taskModel->setTasks(loadedTasks);
|
||||
|
||||
@ -52,6 +52,10 @@ Q_SIGNALS:
|
||||
void motorParm(QString pathLineFilePath);
|
||||
void startRecordSignal(int camType);
|
||||
|
||||
void ObtainingDepthInformationSignals(SubTask info);
|
||||
void LiftingPlatformSignals(SubTask info);
|
||||
void AutoFocusSignals(SubTask info);
|
||||
|
||||
void switchHalogenLampSignal(int state);
|
||||
void switchD65LampSignal(int state);
|
||||
void switchSlrSignal(int state);
|
||||
|
||||
@ -113,9 +113,31 @@ SubTaskType TimedDataCollectionDataStructuresReaderWriter::stringToSubTaskType(c
|
||||
if (str == "HyperSpectual1000_1700nm") return SubTaskType::HyperSpectual1000_1700nm;
|
||||
if (str == "SingleLensReflex") return SubTaskType::SingleLensReflex;
|
||||
if (str == "DepthCamera") return SubTaskType::DepthCamera;
|
||||
|
||||
if (str == "ObtainingDepthInformation") return SubTaskType::ObtainingDepthInformation;
|
||||
if (str == "AutoFocus") return SubTaskType::AutoFocus;
|
||||
if (str == "LiftingPlatform") return SubTaskType::LiftingPlatform;
|
||||
|
||||
return SubTaskType::SingleLensReflex;
|
||||
}
|
||||
|
||||
QString TimedDataCollectionDataStructuresReaderWriter::hyperImagerTypeToString(HyperImagerType type)
|
||||
{
|
||||
switch (type) {
|
||||
case HyperImagerType::Pika_L: return "Pika_L";
|
||||
case HyperImagerType::Pika_NIR: return "Pika_NIR";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
HyperImagerType TimedDataCollectionDataStructuresReaderWriter::stringToHyperImagerType(const QString& str)
|
||||
{
|
||||
if (str == "Pika_L") return HyperImagerType::Pika_L;
|
||||
if (str == "Pika_NIR") return HyperImagerType::Pika_NIR;
|
||||
|
||||
return HyperImagerType::Pika_L;
|
||||
}
|
||||
|
||||
// ==================== SubTask序列化 ====================
|
||||
|
||||
QJsonObject TimedDataCollectionDataStructuresReaderWriter::subTaskToJson(const SubTask& subTask)
|
||||
@ -132,6 +154,19 @@ QJsonObject TimedDataCollectionDataStructuresReaderWriter::subTaskToJson(const S
|
||||
obj["exposureTime"] = subTask.exposureTime;
|
||||
obj["defaultRenderBand"] = subTask.defaultRenderBand;
|
||||
obj["captureIntervalSeconds"] = subTask.captureIntervalSeconds;
|
||||
|
||||
obj["autoFocusHyperImagerType"] = hyperImagerTypeToString(subTask.autoFocusHyperImagerType);
|
||||
obj["autoFocusMotorConfigFilePath"] = subTask.autoFocusMotorConfigFilePath;
|
||||
obj["autoFocusX"] = subTask.autoFocusX;
|
||||
obj["autoFocusY"] = subTask.autoFocusY;
|
||||
|
||||
obj["depthAlgorithm"] = subTask.depthAlgorithm;
|
||||
obj["depthInfoX"] = subTask.depthInfoX;
|
||||
obj["depthInfoY"] = subTask.depthInfoY;
|
||||
obj["averageNumberOfTimes"] = subTask.averageNumberOfTimes;
|
||||
obj["percentageOfEffectiveArea"] = subTask.percentageOfEffectiveArea;
|
||||
obj["depthType"] = subTask.depthType;
|
||||
obj["depthRangePercentage"] = subTask.depthRangePercentage;
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -148,6 +183,19 @@ bool TimedDataCollectionDataStructuresReaderWriter::jsonToSubTask(const QJsonObj
|
||||
subTask.exposureTime = json["exposureTime"].toDouble();
|
||||
subTask.defaultRenderBand = json["defaultRenderBand"].toInt();
|
||||
subTask.captureIntervalSeconds = json["captureIntervalSeconds"].toDouble();
|
||||
|
||||
subTask.autoFocusHyperImagerType = stringToHyperImagerType(json["autoFocusHyperImagerType"].toString());
|
||||
subTask.autoFocusMotorConfigFilePath = json["autoFocusMotorConfigFilePath"].toString();
|
||||
subTask.autoFocusX = json["autoFocusX"].toDouble();
|
||||
subTask.autoFocusY = json["autoFocusY"].toDouble();
|
||||
|
||||
subTask.depthAlgorithm = json["depthAlgorithm"].toInt();
|
||||
subTask.depthInfoX = json["depthInfoX"].toDouble();
|
||||
subTask.depthInfoY = json["depthInfoY"].toDouble();
|
||||
subTask.averageNumberOfTimes = json["averageNumberOfTimes"].toInt();
|
||||
subTask.percentageOfEffectiveArea = json["percentageOfEffectiveArea"].toDouble();
|
||||
subTask.depthType = json["depthType"].toInt();
|
||||
subTask.depthRangePercentage = json["depthRangePercentage"].toDouble();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -229,21 +277,16 @@ void TaskExecutor::execute(const TimedTask& task)
|
||||
|
||||
emit taskUpdated(m_task);
|
||||
|
||||
|
||||
|
||||
m_currentSubTaskIndex = -1;
|
||||
m_isRunning = true;
|
||||
|
||||
qDebug() << "TaskExecutor: Starting task" << task.id;
|
||||
|
||||
// 打开卤素灯预热
|
||||
emit switchHalogenLampSignal(1);
|
||||
printMsgAndTime("open HalogenLamp");
|
||||
|
||||
makeFolder(m_task.savePath);
|
||||
|
||||
// 开始执行第一个子任务
|
||||
double sleepTimeSecond = m_task.HalogenLampPreheatingTime_Minute * 60;
|
||||
QTimer::singleShot(sleepTimeSecond *1000, this, &TaskExecutor::executeNextSubTask);
|
||||
double sleepTimeSecond = 1;
|
||||
QTimer::singleShot(sleepTimeSecond * 1000, this, &TaskExecutor::executeNextSubTask);
|
||||
}
|
||||
|
||||
void TaskExecutor::printMsgAndTime(QString msg)
|
||||
@ -269,10 +312,12 @@ void TaskExecutor::makeFolder(QString savePath)
|
||||
if (!dir.exists()) {
|
||||
if (dir.mkpath(".")) {
|
||||
qDebug() << "TaskExecutor: Created data folder:" << savePath;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qWarning() << "TaskExecutor: Failed to create data folder:" << savePath;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qDebug() << "TaskExecutor: Data folder already exists:" << savePath;
|
||||
}
|
||||
}
|
||||
@ -299,7 +344,7 @@ void TaskExecutor::onSequenceComplete(int status)
|
||||
|
||||
subTask.endTime = QDateTime::currentDateTime();
|
||||
subTask.durationMinutes = (double)subTask.startTime.secsTo(subTask.endTime) / 60;
|
||||
qDebug() << "TaskExecutor: subtask "<< m_currentSubTaskIndex<< " time consuming(Minutes): "<< subTask.durationMinutes;
|
||||
qDebug() << "TaskExecutor: subtask " << m_currentSubTaskIndex << " time consuming(Minutes): " << subTask.durationMinutes;
|
||||
|
||||
// 拷贝subTask.pathLineFilePath到m_currentFolder
|
||||
if (!subTask.pathLineFilePath.isEmpty() && QFile::exists(subTask.pathLineFilePath)) {
|
||||
@ -307,7 +352,8 @@ void TaskExecutor::onSequenceComplete(int status)
|
||||
QString destPath = m_currentFolder + QDir::separator() + fileInfo.fileName();
|
||||
if (QFile::copy(subTask.pathLineFilePath, destPath)) {
|
||||
qDebug() << "TaskExecutor: Copied path line file to" << destPath;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qDebug() << "TaskExecutor: Failed to copy path line file from" << subTask.pathLineFilePath << "to" << destPath;
|
||||
}
|
||||
}
|
||||
@ -315,23 +361,38 @@ void TaskExecutor::onSequenceComplete(int status)
|
||||
emit subTaskFinished(m_currentSubTaskIndex, subTask.type, (status == 0));
|
||||
emit taskUpdated(m_task);
|
||||
}
|
||||
//当前任务已经完成,正确关闭灯光或者电源
|
||||
ensurePostTaskLighting();
|
||||
|
||||
//
|
||||
switch (m_task.subTasks[m_currentSubTaskIndex].type)
|
||||
emit taskUpdated(m_task);
|
||||
}
|
||||
|
||||
void TaskExecutor::ensurePreTaskLighting()
|
||||
{
|
||||
SubTaskType currentTaskType = m_task.subTasks[m_currentSubTaskIndex].type;
|
||||
if (currentTaskType != SubTaskType::HyperSpectual400_1000nm &&
|
||||
currentTaskType != SubTaskType::HyperSpectual1000_1700nm)
|
||||
{
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
emit switchD65LampSignal(0);
|
||||
break;
|
||||
}
|
||||
case SubTaskType::DepthCamera:
|
||||
{
|
||||
emit switchD65LampSignal(0);
|
||||
break;
|
||||
}
|
||||
emit switchHalogenLampSignal(0);
|
||||
}
|
||||
if (currentTaskType != SubTaskType::SingleLensReflex &&
|
||||
currentTaskType != SubTaskType::DepthCamera &&
|
||||
currentTaskType != SubTaskType::ObtainingDepthInformation)
|
||||
{
|
||||
emit switchD65LampSignal(0);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskExecutor::ensurePostTaskLighting()
|
||||
{
|
||||
SubTaskType currentTaskType = m_task.subTasks[m_currentSubTaskIndex].type;
|
||||
if (currentTaskType == SubTaskType::SingleLensReflex ||
|
||||
currentTaskType == SubTaskType::DepthCamera ||
|
||||
currentTaskType == SubTaskType::ObtainingDepthInformation)
|
||||
{
|
||||
emit switchD65LampSignal(0);
|
||||
}
|
||||
|
||||
// 判断下一次的任务是否为高光谱任务,如果不是关闭卤素灯
|
||||
int nestSubTaskIndex = m_currentSubTaskIndex + 1;
|
||||
if (nestSubTaskIndex >= m_task.subTasks.size())
|
||||
{
|
||||
@ -340,21 +401,13 @@ void TaskExecutor::onSequenceComplete(int status)
|
||||
emit switchHalogenLampSignal(0);
|
||||
return;
|
||||
}
|
||||
switch (m_task.subTasks[nestSubTaskIndex].type)
|
||||
// 判断下一次的任务是否为高光谱任务,如果不是就关闭卤素灯
|
||||
SubTaskType nestTaskType = m_task.subTasks[nestSubTaskIndex].type;
|
||||
if (nestTaskType != SubTaskType::HyperSpectual400_1000nm &&
|
||||
nestTaskType != SubTaskType::HyperSpectual1000_1700nm)
|
||||
{
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
emit switchHalogenLampSignal(0);
|
||||
break;
|
||||
}
|
||||
case SubTaskType::DepthCamera:
|
||||
{
|
||||
emit switchHalogenLampSignal(0);
|
||||
break;
|
||||
}
|
||||
emit switchHalogenLampSignal(0);
|
||||
}
|
||||
|
||||
emit taskUpdated(m_task);
|
||||
}
|
||||
|
||||
void TaskExecutor::onBack2Origin()
|
||||
@ -362,23 +415,23 @@ void TaskExecutor::onBack2Origin()
|
||||
// 关闭单反电源
|
||||
switch (m_task.subTasks[m_currentSubTaskIndex].type)
|
||||
{
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
emit switchSlrSignal(0);
|
||||
break;
|
||||
}
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
emit switchSlrSignal(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否还有更多子任务
|
||||
int nestSubTaskIndex = m_currentSubTaskIndex + 1;
|
||||
if (nestSubTaskIndex < m_task.subTasks.size()) {
|
||||
// 执行下一个子任务
|
||||
if(m_task.subTasks[nestSubTaskIndex].type== SubTaskType::SingleLensReflex)
|
||||
if (m_task.subTasks[nestSubTaskIndex].type == SubTaskType::SingleLensReflex)
|
||||
{
|
||||
printMsgAndTime("Slr task,for weak up,please wait 135 seconds!");
|
||||
emit switchSlrSignal(0);
|
||||
|
||||
QTimer::singleShot(135*1000, this, &TaskExecutor::executeNextSubTask);
|
||||
QTimer::singleShot(135 * 1000, this, &TaskExecutor::executeNextSubTask);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -433,54 +486,118 @@ void TaskExecutor::executeNextSubTask()
|
||||
// << "type:" << static_cast<int>(subTask.type);
|
||||
|
||||
emit subTaskStarted(m_currentSubTaskIndex, subTask.type);
|
||||
|
||||
emit motorParm(subTask.pathLineFilePath);
|
||||
|
||||
int camType;
|
||||
switch (subTask.type)
|
||||
{
|
||||
case SubTaskType::ObtainingDepthInformation:
|
||||
{
|
||||
//(1)移动到指定位置并通过深度相机获取深度信息(2)调整升降板高度(白板+调焦板)(3)回到零位(0,0)
|
||||
emit switchD65LampSignal(1);
|
||||
emit ObtainingDepthInformationSignals(subTask);
|
||||
break;
|
||||
}
|
||||
case SubTaskType::AutoFocus:
|
||||
{
|
||||
switch (subTask.autoFocusHyperImagerType)
|
||||
{
|
||||
case HyperImagerType::Pika_L:
|
||||
m_camType = 0;
|
||||
m_currentFolder = makeSubTaskDataFolder("L");
|
||||
emit hyperCamParm(m_camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "L");
|
||||
|
||||
break;
|
||||
case HyperImagerType::Pika_NIR:
|
||||
m_camType = 1;
|
||||
m_currentFolder = makeSubTaskDataFolder("NIR");
|
||||
emit hyperCamParm(m_camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "NIR");
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
emit switchHalogenLampSignal(1);
|
||||
|
||||
//执行自动调焦任务
|
||||
QTimer::singleShot(3 * 1000, this, &TaskExecutor::emitAutoFocusSignal);
|
||||
break;
|
||||
}
|
||||
case SubTaskType::LiftingPlatform:
|
||||
{
|
||||
//执行升降平台任务
|
||||
emit LiftingPlatformSignals(subTask);
|
||||
break;
|
||||
}
|
||||
case SubTaskType::HyperSpectual400_1000nm:
|
||||
{
|
||||
camType = 0;
|
||||
m_camType = 0;
|
||||
m_currentFolder = makeSubTaskDataFolder("L");
|
||||
emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "L");
|
||||
|
||||
emit hyperCamParm(m_camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "L");
|
||||
|
||||
emit motorParm(subTask.pathLineFilePath);
|
||||
|
||||
// 打开卤素灯预热
|
||||
emit switchHalogenLampSignal(1);
|
||||
printMsgAndTime("open HalogenLamp");
|
||||
double sleepTimeSecond = m_task.HalogenLampPreheatingTime_Minute * 60;
|
||||
QTimer::singleShot(sleepTimeSecond * 1000, this, &TaskExecutor::emitRecordSignal);
|
||||
|
||||
break;
|
||||
}
|
||||
case SubTaskType::HyperSpectual1000_1700nm:
|
||||
{
|
||||
camType = 1;
|
||||
m_camType = 1;
|
||||
m_currentFolder = makeSubTaskDataFolder("NIR");
|
||||
emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "NIR");
|
||||
emit hyperCamParm(m_camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "NIR");
|
||||
|
||||
emit motorParm(subTask.pathLineFilePath);
|
||||
|
||||
QTimer::singleShot(3 * 1000, this, &TaskExecutor::emitRecordSignal);
|
||||
|
||||
break;
|
||||
}
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
camType = 2;
|
||||
m_camType = 2;
|
||||
m_currentFolder = makeSubTaskDataFolder("SLR");
|
||||
emit camParm(camType, 3, m_currentFolder);
|
||||
emit camParm(m_camType, 3, m_currentFolder);
|
||||
|
||||
emit motorParm(subTask.pathLineFilePath);
|
||||
|
||||
emit switchD65LampSignal(1);
|
||||
|
||||
|
||||
emit switchSlrSignal(1);
|
||||
|
||||
QTimer::singleShot(3 * 1000, this, &TaskExecutor::emitRecordSignal);
|
||||
|
||||
break;
|
||||
}
|
||||
case SubTaskType::DepthCamera:
|
||||
{
|
||||
camType = 3;
|
||||
m_camType = 3;
|
||||
m_currentFolder = makeSubTaskDataFolder("DepthCamera");
|
||||
emit camParm(camType, 3, m_currentFolder);
|
||||
emit camParm(m_camType, 3, m_currentFolder);
|
||||
|
||||
emit motorParm(subTask.pathLineFilePath);
|
||||
|
||||
emit switchD65LampSignal(1);
|
||||
|
||||
QTimer::singleShot(3 * 1000, this, &TaskExecutor::emitRecordSignal);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
ensurePreTaskLighting();
|
||||
}
|
||||
|
||||
emit startRecordSignal(camType);
|
||||
void TaskExecutor::emitRecordSignal()
|
||||
{
|
||||
emit startRecordSignal(m_camType);
|
||||
}
|
||||
|
||||
void TaskExecutor::emitAutoFocusSignal()
|
||||
{
|
||||
SubTask& subTask = m_task.subTasks[m_currentSubTaskIndex];
|
||||
emit AutoFocusSignals(subTask);
|
||||
}
|
||||
|
||||
// ==================== TaskScheduler 实现 ====================
|
||||
@ -581,7 +698,7 @@ void TaskScheduler::checkTasks()
|
||||
if (task.scheduledTime > now) continue;
|
||||
|
||||
qint64 fireThreSecs = 5;
|
||||
if (task.scheduledTime.addSecs(-1*fireThreSecs) < now && task.scheduledTime.addSecs(fireThreSecs) > now)// 到达计划时间,启动任务
|
||||
if (task.scheduledTime.addSecs(-1 * fireThreSecs) < now && task.scheduledTime.addSecs(fireThreSecs) > now)// 到达计划时间,启动任务
|
||||
{
|
||||
std::cerr << "TaskScheduler::checkTasks,到达计划时间,启动任务" << std::endl;
|
||||
executeTask(task);
|
||||
@ -639,23 +756,27 @@ void TaskScheduler::executeTask(TimedTask& task)
|
||||
|
||||
// 连接信号
|
||||
connect(m_currentExecutor, &TaskExecutor::finished,
|
||||
this, &TaskScheduler::onTaskFinished);
|
||||
this, &TaskScheduler::onTaskFinished);
|
||||
connect(m_currentExecutor, &TaskExecutor::subTaskStarted,
|
||||
this, &TaskScheduler::onSubTaskStarted);
|
||||
this, &TaskScheduler::onSubTaskStarted);
|
||||
connect(m_currentExecutor, &TaskExecutor::subTaskFinished,
|
||||
this, &TaskScheduler::onSubTaskFinished);
|
||||
this, &TaskScheduler::onSubTaskFinished);
|
||||
connect(m_currentExecutor, &TaskExecutor::errorOccurred,
|
||||
this, &TaskScheduler::onExecutorError);
|
||||
this, &TaskScheduler::onExecutorError);
|
||||
|
||||
// 采集相关信号透传
|
||||
connect(m_currentExecutor, &TaskExecutor::hyperCamParm,
|
||||
this, &TaskScheduler::hyperCamParm);
|
||||
this, &TaskScheduler::hyperCamParm);
|
||||
connect(m_currentExecutor, &TaskExecutor::camParm,
|
||||
this, &TaskScheduler::camParm);
|
||||
this, &TaskScheduler::camParm);
|
||||
connect(m_currentExecutor, &TaskExecutor::motorParm,
|
||||
this, &TaskScheduler::motorParm);
|
||||
this, &TaskScheduler::motorParm);
|
||||
connect(m_currentExecutor, &TaskExecutor::startRecordSignal,
|
||||
this, &TaskScheduler::startRecordSignal);
|
||||
this, &TaskScheduler::startRecordSignal);
|
||||
|
||||
connect(m_currentExecutor, &TaskExecutor::ObtainingDepthInformationSignals, this, &TaskScheduler::ObtainingDepthInformationSignals);
|
||||
connect(m_currentExecutor, &TaskExecutor::LiftingPlatformSignals, this, &TaskScheduler::LiftingPlatformSignals);
|
||||
connect(m_currentExecutor, &TaskExecutor::AutoFocusSignals, this, &TaskScheduler::AutoFocusSignals);
|
||||
|
||||
connect(m_currentExecutor, &TaskExecutor::switchHalogenLampSignal, this, &TaskScheduler::switchHalogenLampSignal);
|
||||
connect(m_currentExecutor, &TaskExecutor::switchD65LampSignal, this, &TaskScheduler::switchD65LampSignal);
|
||||
@ -687,7 +808,8 @@ void TaskScheduler::updateTaskStatus(int taskId, TaskStatus status)
|
||||
task.status = status;
|
||||
if (status == TaskStatus::Running) {
|
||||
task.startTime = QDateTime::currentDateTime();
|
||||
} else if (status == TaskStatus::Finished) {
|
||||
}
|
||||
else if (status == TaskStatus::Finished) {
|
||||
task.endTime = QDateTime::currentDateTime();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -25,7 +25,14 @@ enum class SubTaskType {
|
||||
HyperSpectual400_1000nm, // 400nm-1000nm高光谱相机
|
||||
HyperSpectual1000_1700nm, // 1000nm-1700nm高光谱相机
|
||||
SingleLensReflex, // 单反相机
|
||||
DepthCamera // 深度相机
|
||||
DepthCamera, // 深度相机采集任务
|
||||
ObtainingDepthInformation, //通过深度相机获取被测物体的深度信息
|
||||
AutoFocus, // 自动对焦
|
||||
LiftingPlatform // 升降平台
|
||||
};
|
||||
enum class HyperImagerType {
|
||||
Pika_L,
|
||||
Pika_NIR
|
||||
};
|
||||
|
||||
// ==================== 统一子任务封装 ====================
|
||||
@ -46,6 +53,21 @@ struct SubTask {
|
||||
double exposureTime = 0.0; // 高光谱相机用
|
||||
int defaultRenderBand = 550; // 1000-1700nm高光谱用
|
||||
int captureIntervalSeconds = 5; // 单反/深度相机用
|
||||
|
||||
//任务ObtainingDepthInformation所需的x和y坐标
|
||||
int depthAlgorithm = 0;//0:深度图像的范围(percentageOfEffectiveArea)平均,1:深度范围(depthRangePercentage)的百分比,2:通过彩色图像分割植被区域的深度图像,然后平均
|
||||
int depthType = 0;//0表示植被深度,1表示白板/调焦版深度
|
||||
double depthInfoX = 0.0;
|
||||
double depthInfoY = 0.0;
|
||||
int averageNumberOfTimes = 1; //任务ObtainingDepthInformation所需的平均次数
|
||||
double percentageOfEffectiveArea = 50.0; //深度图像的有效范围百分比
|
||||
double depthRangePercentage = 80.0; //深度范围的百分比
|
||||
|
||||
//高光谱自动调焦
|
||||
HyperImagerType autoFocusHyperImagerType;//取值范围:L、NIR
|
||||
QString autoFocusMotorConfigFilePath;//马达配置文件
|
||||
double autoFocusX = 0.0;
|
||||
double autoFocusY = 0.0;
|
||||
};
|
||||
|
||||
// ==================== 定时任务 ====================
|
||||
@ -109,6 +131,9 @@ private:
|
||||
|
||||
static QString subTaskTypeToString(SubTaskType type);
|
||||
static SubTaskType stringToSubTaskType(const QString& str);
|
||||
|
||||
static QString hyperImagerTypeToString(HyperImagerType type);
|
||||
static HyperImagerType stringToHyperImagerType(const QString& str);
|
||||
};
|
||||
|
||||
// ==================== 任务执行器 ====================
|
||||
@ -151,6 +176,10 @@ signals:
|
||||
void motorParm(QString pathLineFilePath);
|
||||
void startRecordSignal(int camType);
|
||||
|
||||
void ObtainingDepthInformationSignals(SubTask info);
|
||||
void LiftingPlatformSignals(SubTask info);
|
||||
void AutoFocusSignals(SubTask info);
|
||||
|
||||
void switchHalogenLampSignal(int state);
|
||||
void switchD65LampSignal(int state);
|
||||
void switchSlrSignal(int state);
|
||||
@ -160,15 +189,22 @@ public slots:
|
||||
void onBack2Origin();
|
||||
void onError(const QString& error);
|
||||
|
||||
void emitRecordSignal();
|
||||
void emitAutoFocusSignal();
|
||||
|
||||
private:
|
||||
QString m_currentFolder;
|
||||
void executeNextSubTask();
|
||||
void ensurePreTaskLighting();
|
||||
void ensurePostTaskLighting();
|
||||
|
||||
void printMsgAndTime(QString msg);
|
||||
|
||||
TimedTask m_task;
|
||||
int m_currentSubTaskIndex;
|
||||
bool m_isRunning;
|
||||
|
||||
int m_camType;
|
||||
};
|
||||
|
||||
// ==================== 任务调度器 ====================
|
||||
@ -214,6 +250,10 @@ signals:
|
||||
void motorParm(QString pathLineFilePath);
|
||||
void startRecordSignal(int camType);
|
||||
|
||||
void ObtainingDepthInformationSignals(SubTask info);
|
||||
void LiftingPlatformSignals(SubTask info);
|
||||
void AutoFocusSignals(SubTask info);
|
||||
|
||||
void switchHalogenLampSignal(int state);
|
||||
void switchD65LampSignal(int state);
|
||||
void switchSlrSignal(int state);
|
||||
|
||||
@ -210,6 +210,79 @@ void TwoMotorControl::onBack2Origin2()
|
||||
emit back2OriginSignal_TimedDataCollection();
|
||||
}
|
||||
|
||||
void TwoMotorControl::run4_ObtainTargetDepthInfo(DepthCameraWindow* window, double depthAlgorithm,int depthType, double depthInfoX, double depthInfoY, int averageNumberOfTimes, double percentageOfEffectiveArea, double depthRangePercentage)
|
||||
{
|
||||
m_depthType = depthType;
|
||||
|
||||
window->m_DepthCameraOperation->setDepthAlgorithm(depthAlgorithm);
|
||||
window->m_DepthCameraOperation->setAverageNumberOfTimes(averageNumberOfTimes);
|
||||
window->m_DepthCameraOperation->setPercentageOfEffectiveArea(percentageOfEffectiveArea);
|
||||
window->m_DepthCameraOperation->setDepthRangePercentage(depthRangePercentage);
|
||||
|
||||
m_ObtainTargetDepthInfoCoordinator = new TwoMotor1PosCoordinator(m_multiAxisController);
|
||||
connect(m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::ArrivalSignal, window, &DepthCameraWindow::OpenDepthCamera_getDepthValue);
|
||||
|
||||
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::back2origin);
|
||||
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, this, &TwoMotorControl::sequenceComplete, Qt::UniqueConnection);//关灯
|
||||
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, this, &TwoMotorControl::saveDepthValue, Qt::UniqueConnection);
|
||||
|
||||
connect(m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::back2OriginSignal, this, &TwoMotorControl::onBack2Origin3);
|
||||
|
||||
double xmotor_move_speed = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
double ymotor_move_speed = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
m_ObtainTargetDepthInfoCoordinator->moveToTarget(depthInfoX, depthInfoY, xmotor_move_speed, ymotor_move_speed);
|
||||
}
|
||||
|
||||
void TwoMotorControl::run5_AutoFocus(double autoFocusX, double autoFocusY)
|
||||
{
|
||||
m_focusWindow = new focusWindow(this, m_Imager);
|
||||
m_focusWindow->setIsDisplaysAutofocusResultViaPopup(false);
|
||||
m_focusWindow->onConnectMotor();
|
||||
m_focusWindow->show();
|
||||
|
||||
//自动调焦的协调器添加功能:先归零
|
||||
m_autoFocusCoordinator = new TwoMotor1PosCoordinator(m_multiAxisController);
|
||||
connect(m_autoFocusCoordinator, &TwoMotor1PosCoordinator::ArrivalSignal, m_focusWindow, &focusWindow::onAutoFocus);
|
||||
connect(m_focusWindow, &focusWindow::AutoFocusFinishedSignal, m_autoFocusCoordinator, &TwoMotor1PosCoordinator::back2origin);
|
||||
connect(m_focusWindow, &focusWindow::AutoFocusFinishedSignal, this, &TwoMotorControl::sequenceComplete, Qt::UniqueConnection);
|
||||
connect(m_autoFocusCoordinator, &TwoMotor1PosCoordinator::back2OriginSignal, this, &TwoMotorControl::onBack2Origin4);
|
||||
|
||||
|
||||
double xmotor_move_speed = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
double ymotor_move_speed = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
m_autoFocusCoordinator->moveToTarget(autoFocusX, autoFocusY, xmotor_move_speed, ymotor_move_speed);
|
||||
}
|
||||
|
||||
void TwoMotorControl::saveDepthValue(double depthValue)
|
||||
{
|
||||
if (m_depthType == 0)//0表示植被深度,1表示白板/调焦版深度
|
||||
{
|
||||
DepthValueLogger::instance().appendPlantDepthValue(depthValue);
|
||||
}
|
||||
else if (m_depthType == 1)
|
||||
{
|
||||
DepthValueLogger::instance().appendLiftingPlatformDepthValue(depthValue);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onBack2Origin3()
|
||||
{
|
||||
m_ObtainTargetDepthInfoCoordinator->deleteLater();
|
||||
m_ObtainTargetDepthInfoCoordinator = nullptr;
|
||||
emit back2OriginSignal_TimedDataCollection();
|
||||
}
|
||||
|
||||
void TwoMotorControl::onBack2Origin4()
|
||||
{
|
||||
m_focusWindow->deleteLater();
|
||||
m_focusWindow = nullptr;
|
||||
|
||||
m_autoFocusCoordinator->deleteLater();
|
||||
m_autoFocusCoordinator = nullptr;
|
||||
emit back2OriginSignal_TimedDataCollection();
|
||||
}
|
||||
|
||||
void TwoMotorControl::run()
|
||||
{
|
||||
if (getState())
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
|
||||
#include "PathLine.h"
|
||||
|
||||
#include "DepthValueLogger.h"
|
||||
|
||||
#include "focusWindow.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
class TwoMotorControl : public QDialog, public MotorWindowBase
|
||||
@ -82,7 +86,12 @@ public Q_SLOTS:
|
||||
|
||||
void run2(SingleLensReflexCameraWindow* w);
|
||||
void run3(DepthCameraWindow* window);
|
||||
void run4_ObtainTargetDepthInfo(DepthCameraWindow* window, double depthAlgorithm, int depthType, double depthInfoX, double depthInfoY, int averageNumberOfTimes, double percentageOfEffectiveArea, double depthRangePercentage);
|
||||
void run5_AutoFocus(double autoFocusX, double autoFocusY);
|
||||
void onBack2Origin2();
|
||||
void saveDepthValue(double depthValue);
|
||||
void onBack2Origin3();
|
||||
void onBack2Origin4();
|
||||
|
||||
void stop_record();
|
||||
|
||||
@ -111,10 +120,16 @@ private:
|
||||
QThread m_coordinatorThread;
|
||||
TwoMotionCaptureCoordinator* m_coordinator = nullptr;
|
||||
TwoMotionCaptureCoordinator* m_coordinator_TimedDataCollection = nullptr;
|
||||
TwoMotor1PosCoordinator* m_ObtainTargetDepthInfoCoordinator = nullptr;
|
||||
TwoMotor1PosCoordinator* m_autoFocusCoordinator = nullptr;
|
||||
|
||||
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController = nullptr;
|
||||
|
||||
int m_depthType;
|
||||
|
||||
focusWindow* m_focusWindow = nullptr;
|
||||
};
|
||||
|
||||
@ -288,7 +288,7 @@ QPushButton:pressed
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:3.1.0</string>
|
||||
<string>版本:3.1.4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -53,6 +53,10 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
connect(this->ui.closeBtn, SIGNAL(released()), this, SLOT(onExit()));
|
||||
|
||||
connect(this->ui.is_new_version_radioButton, &QRadioButton::toggled, this, [this](bool checked) {
|
||||
ui.stackedWidget_connetcParm->setCurrentIndex(checked ? 0 : 1);
|
||||
});
|
||||
|
||||
//查找可用串口,并显示
|
||||
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
@ -72,7 +76,40 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
|
||||
m_dSpeed = 1.0;
|
||||
}
|
||||
|
||||
void focusWindow::showMessageBox(QString msg, QString title)
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(title);
|
||||
msgBox.setText(msg);
|
||||
msgBox.setStyleSheet(R"(
|
||||
QMessageBox {
|
||||
background-color: #0D1233;
|
||||
}
|
||||
QMessageBox QLabel {
|
||||
color: #ACCDFF;
|
||||
font-size: 14px;
|
||||
}
|
||||
QPushButton {
|
||||
background-color: #142D7F;
|
||||
color: #e6eeff;
|
||||
border: 1px solid #2f6bff;
|
||||
border-radius: 6px;
|
||||
padding: 6px 20px;
|
||||
min-width: 60px;
|
||||
font-size: 13px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
border: 1px solid #4d8dff;
|
||||
background-color: red;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #23345c;
|
||||
}
|
||||
)");
|
||||
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
focusWindow::~focusWindow()
|
||||
@ -160,33 +197,7 @@ void focusWindow::onConnectMotor()
|
||||
{
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_focus.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
connect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
m_motorThread.start();
|
||||
|
||||
//归零
|
||||
//emit zeroStartSignal(0);
|
||||
|
||||
//自动调焦逻辑
|
||||
m_coordinator = new MotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_MotionCaptureCoordinatorThread);
|
||||
connect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(startStepMotion(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
connect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
m_MotionCaptureCoordinatorThread.start();
|
||||
connectMotor(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -257,6 +268,131 @@ void focusWindow::onConnectMotor()
|
||||
disableBeforeConnect(false);
|
||||
}
|
||||
|
||||
void focusWindow::connectMotor(bool isNotification)//需要修改这个函数
|
||||
{
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
if (isNotification)
|
||||
{
|
||||
showMessageBox(QString::fromLocal8Bit("马达已连接!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_multiAxisController)
|
||||
{
|
||||
disconnect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
disconnect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
disconnect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
disconnect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
disconnect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
m_multiAxisController->deleteLater();
|
||||
}
|
||||
|
||||
if (m_coordinator)
|
||||
{
|
||||
disconnect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
disconnect(this, SIGNAL(startStepMotionSignal(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
disconnect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
disconnect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
|
||||
m_MotionCaptureCoordinatorThread.quit();
|
||||
m_MotionCaptureCoordinatorThread.wait();
|
||||
m_coordinator->deleteLater();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_focus.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
showMessageBox(QString::fromLocal8Bit("请连接马达!"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
connect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
|
||||
//归零
|
||||
//emit zeroStartSignal(0);
|
||||
|
||||
//自动调焦逻辑
|
||||
m_coordinator = new MotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_MotionCaptureCoordinatorThread);
|
||||
connect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(startStepMotionSignal(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
connect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
m_MotionCaptureCoordinatorThread.start();
|
||||
|
||||
}
|
||||
|
||||
void focusWindow::display_motors_connectivity(std::vector<int> connectivity)
|
||||
{
|
||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||
if (connectivity[0])
|
||||
{
|
||||
m_xMotorConnectionStatus = true;
|
||||
|
||||
this->ui.motor_state_label->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: #08FACE;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xMotorConnectionStatus = false;
|
||||
|
||||
this->ui.motor_state_label->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
this->ui.connectMotor_btn->setText(QString::fromLocal8Bit("已连接"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.connectMotor_btn->setText(QString::fromLocal8Bit("重新连接"));
|
||||
}
|
||||
}
|
||||
|
||||
bool focusWindow::getMotorsConnectionStatus()
|
||||
{
|
||||
return m_xMotorConnectionStatus;
|
||||
}
|
||||
|
||||
void focusWindow::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
@ -339,7 +475,7 @@ void focusWindow::onAutoFocus()
|
||||
//获取马达最大位置
|
||||
std::vector<double> maxRangeLocations = m_multiAxisController->getMaxPos();
|
||||
double maxPos = maxRangeLocations[0];
|
||||
emit startStepMotion(m_dSpeed, m_iStepSize, 0, maxPos);
|
||||
emit startStepMotionSignal(m_dSpeed, m_iStepSize, 0, maxPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -498,33 +634,76 @@ void focusWindow::onAutoFocusFinished()
|
||||
|
||||
void focusWindow::moveAfterAutoFocus(int motorID, double location)
|
||||
{
|
||||
//QObject* obj = sender();
|
||||
|
||||
//if (obj == m_multiAxisController)
|
||||
//{
|
||||
// qDebug() << "sender is m_multiAxisController.";
|
||||
//}
|
||||
|
||||
if (!m_isMoveAfterAutoFocus)
|
||||
{
|
||||
//std::cout << "focusWindow::moveAfterAutoFocus" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "\n已经到达位置:" << location << std::endl;
|
||||
|
||||
//移动马达到最佳位置
|
||||
emit move2LocSignal(0, (double)m_goodPos, m_dSpeed, 1000);
|
||||
|
||||
double tmp = abs(location - m_goodPos) / m_goodPos * 100;
|
||||
if (tmp<5)
|
||||
double errorRate = getErrorRate(m_goodPos, location);
|
||||
if (errorRate < 5|| m_moveRetryCount > MAX_MOVE_RETRY)
|
||||
{
|
||||
m_isMoveAfterAutoFocus = false;
|
||||
m_moveRetryCount = 0;
|
||||
if (!m_isAutoFocusSuccess)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
||||
msgBox.exec();
|
||||
qDebug() << "纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!";
|
||||
|
||||
if (m_isDisplaysAutofocusResultViaPopup)
|
||||
{
|
||||
showMessageBox(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("自动调焦成功!"));
|
||||
msgBox.exec();
|
||||
qDebug() << "自动调焦成功!";
|
||||
|
||||
if (m_isDisplaysAutofocusResultViaPopup)
|
||||
{
|
||||
showMessageBox(QString::fromLocal8Bit("自动调焦成功!"));
|
||||
}
|
||||
}
|
||||
m_isMoveAfterAutoFocus = false;
|
||||
emit AutoFocusFinishedSignal(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_moveRetryCount++;
|
||||
qDebug() << "自动调焦后目标马达位置,重试次数:" << m_moveRetryCount;
|
||||
//移动马达到最佳位置
|
||||
emit move2LocSignal(0, (double)m_goodPos, m_dSpeed, 1000);
|
||||
}
|
||||
|
||||
m_isDisplaysAutofocusResultViaPopup = true;
|
||||
}
|
||||
|
||||
void focusWindow::setIsDisplaysAutofocusResultViaPopup(bool isDisplaysAutofocusResultViaPopup)
|
||||
{
|
||||
m_isDisplaysAutofocusResultViaPopup = isDisplaysAutofocusResultViaPopup;
|
||||
}
|
||||
|
||||
double focusWindow::getErrorRate(double targetLoc, double actualLoc)
|
||||
{
|
||||
double targetLocTmp;
|
||||
if (targetLoc == 0)
|
||||
{
|
||||
targetLocTmp = 0.001;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetLocTmp = targetLoc;
|
||||
}
|
||||
double errorRate = abs(targetLoc - actualLoc) / targetLocTmp * 100;
|
||||
|
||||
return errorRate;
|
||||
}
|
||||
|
||||
void focusWindow::getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init)
|
||||
@ -677,11 +856,15 @@ MotionCaptureCoordinator::MotionCaptureCoordinator(
|
||||
, m_currentPos(0)
|
||||
, m_endPos(0)
|
||||
, m_isRunning(false)
|
||||
, m_isZeroing(false)
|
||||
{
|
||||
//这些信号槽是按照逻辑顺序的
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
|
||||
connect(this, &MotionCaptureCoordinator::zeroStart,
|
||||
m_motorCtrl, &IrisMultiMotorController::zeroStart);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &MotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
@ -718,15 +901,37 @@ void MotionCaptureCoordinator::startStepMotion(double speed, int stepInterval, d
|
||||
m_speed = speed;
|
||||
m_iStepInterval = stepInterval;
|
||||
m_iStepIntervalRealTime = 1;
|
||||
m_currentPos = startPos;
|
||||
m_startPos = startPos;
|
||||
m_endPos = endPos;
|
||||
m_posInternal = (endPos - startPos) / stepInterval;
|
||||
|
||||
m_isRunning = true;
|
||||
m_isZeroing = true;
|
||||
|
||||
// 先执行归零操作
|
||||
emit zeroStart(0);
|
||||
qDebug() << "MotionCaptureCoordinator::startStepMotion: Zeroing started.";
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::startMotionSequence()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
m_currentPos = m_startPos;
|
||||
m_isZeroing = false;
|
||||
qDebug() << "MotionCaptureCoordinator::startMotionSequence: Zeroing complete. Starting motion sequence.";
|
||||
|
||||
processNextPosition();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::handleZeroComplete(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning || !m_isZeroing) return;
|
||||
|
||||
// 归零完成,开始分步运动
|
||||
startMotionSequence();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::stopStepMotion()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
@ -769,6 +974,13 @@ void MotionCaptureCoordinator::handlePositionReached(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
// 如果正在等待归零完成,调用归零完成处理
|
||||
if (m_isZeroing)
|
||||
{
|
||||
handleZeroComplete(motorID, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
//验证马达运动位置是否到达指定位置
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
#include <QPointer>
|
||||
|
||||
#include "ui_FocusDialog.h"
|
||||
#include "AbstractPortMiscDefines.h"
|
||||
@ -69,14 +70,17 @@ signals:
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void getFocusIndexSobel();
|
||||
void zeroStart(int motorID);
|
||||
|
||||
private slots:
|
||||
void handlePositionReached(int motorID, double pos);
|
||||
void handleCaptureComplete(double index);
|
||||
void handleError(const QString& error);
|
||||
void handleZeroComplete(int motorID, double pos);
|
||||
|
||||
private:
|
||||
void processNextPosition();
|
||||
void startMotionSequence();
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
@ -85,6 +89,7 @@ private:
|
||||
|
||||
double m_posInternal;
|
||||
double m_currentPos;
|
||||
double m_startPos;
|
||||
double m_endPos;
|
||||
bool m_isRunning;
|
||||
double m_speed;
|
||||
@ -92,6 +97,7 @@ private:
|
||||
int m_iStepInterval;
|
||||
int m_iStepIntervalRealTime;
|
||||
int m_counter;
|
||||
bool m_isZeroing;
|
||||
};
|
||||
|
||||
class focusWindow:public QDialog
|
||||
@ -105,6 +111,8 @@ public:
|
||||
|
||||
ImagerOperationBase* m_Imager;
|
||||
|
||||
void setIsDisplaysAutofocusResultViaPopup(bool isDisplaysAutofocusResultViaPopup);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
@ -123,19 +131,30 @@ private:
|
||||
void disableBeforeConnect(bool disable);
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
QPointer<IrisMultiMotorController> m_multiAxisController;
|
||||
double m_dSpeed;
|
||||
|
||||
QThread m_MotionCaptureCoordinatorThread;
|
||||
MotionCaptureCoordinator* m_coordinator;
|
||||
QPointer<MotionCaptureCoordinator> m_coordinator;
|
||||
|
||||
int m_iStepSize;
|
||||
double m_goodPos;
|
||||
bool m_isAutoFocusSuccess;
|
||||
bool m_isMoveAfterAutoFocus = false;
|
||||
int m_moveRetryCount = 0;
|
||||
static constexpr int MAX_MOVE_RETRY = 3;
|
||||
void getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init);
|
||||
void gaussian_fit(const std::vector<double>& x_data, const std::vector<double>& y_data, double& a, double& mu, double& sigma, double& c);
|
||||
|
||||
bool m_xMotorConnectionStatus = false;
|
||||
bool getMotorsConnectionStatus();
|
||||
void connectMotor(bool isNotification);
|
||||
|
||||
void showMessageBox(QString msg, QString title = QString::fromLocal8Bit("提示"));
|
||||
|
||||
double getErrorRate(double targetLoc, double actualLoc);
|
||||
|
||||
bool m_isDisplaysAutofocusResultViaPopup = true;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
@ -158,6 +177,8 @@ public Q_SLOTS:
|
||||
|
||||
void onExit();
|
||||
|
||||
void display_motors_connectivity(std::vector<int> connectivity);
|
||||
|
||||
signals:
|
||||
void StartManualFocusSignal(int);//1:开始调焦;0:停止调焦;
|
||||
|
||||
@ -166,9 +187,12 @@ signals:
|
||||
void rmoveSignal(int, double, double, int);
|
||||
void rangeMeasurementSignal(int, double, int);
|
||||
void zeroStartSignal(int);
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);
|
||||
void startStepMotionSignal(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);
|
||||
void closeSignal();
|
||||
|
||||
void AutoFocusFinishedSignal(int status);
|
||||
};
|
||||
|
||||
class WorkerThread2 : public QThread
|
||||
|
||||
243
HPPA/fodis.ui
Normal file
243
HPPA/fodis.ui
Normal file
@ -0,0 +1,243 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FodisWindow</class>
|
||||
<widget class="QDialog" name="FodisWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>438</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FodisWindow</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 "新宋体";
|
||||
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="1" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="close_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="open_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="2" column="1" colspan="2">
|
||||
<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="3" 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="3" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<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="fileNameLineEdit">
|
||||
<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>test</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<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="4" column="2">
|
||||
<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>
|
||||
262
HPPA/gonggashanCtl.ui
Normal file
262
HPPA/gonggashanCtl.ui
Normal file
@ -0,0 +1,262 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>gongga_control</class>
|
||||
<widget class="QWidget" name="gongga_control">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>572</width>
|
||||
<height>384</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>贡嘎山触发采集</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;
|
||||
}
|
||||
|
||||
QSpinBox
|
||||
{
|
||||
font: 10pt "新宋体";
|
||||
background-color: #142D7F;
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 10pt "新宋体";
|
||||
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 8px;
|
||||
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;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupAdjustments">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel
|
||||
{
|
||||
color: #ACCDFF;
|
||||
font-size: 14px;
|
||||
font: 9pt "Adobe Devanagari";
|
||||
}</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>通讯参数</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="spinbox_Port">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>666</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelPort">
|
||||
<property name="text">
|
||||
<string>端口</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupPresets">
|
||||
<property name="title">
|
||||
<string>采集</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="btnListen">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>开始监听</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="btnDisListen">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>停止监听</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>系统状态</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="status_textEdit">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTextEdit
|
||||
{
|
||||
font: 10pt "新宋体";
|
||||
background-color: #142D7F;
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
QScrollBar:vertical {
|
||||
background: #0E1C4C;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical {
|
||||
background: #4B60A6;
|
||||
border-radius: 6px;
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
QScrollBar:horizontal {
|
||||
background: #0E1C4C;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:horizontal {
|
||||
background: #4B60A6;
|
||||
border-radius: 6px;
|
||||
min-width: 20px;
|
||||
}
|
||||
|
||||
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {
|
||||
width: 0px;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'新宋体'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -64,7 +64,7 @@ void CImage::SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumbe
|
||||
//std::cout << "rgb影像内存地址为:" << m_QRgbImage << std::endl;
|
||||
}
|
||||
|
||||
void CImage::FillRgbImage(unsigned short *datacube)
|
||||
void CImage::FillRgbImage(unsigned short *datacube, int rBandNumber, int gBandNumber, int bBandNumber)
|
||||
{
|
||||
//uchar==unsigned char,内存大小:1个字节,范围为0-255
|
||||
//uchar * imagebits24 = m_QRgbImage->bits();
|
||||
@ -78,9 +78,9 @@ void CImage::FillRgbImage(unsigned short *datacube)
|
||||
//std::cout << "rgb图像写入数据帧数:" << j << std::endl;
|
||||
|
||||
//取值:一帧影像中,从左到右的rgb像元值
|
||||
r = *(datacube + 121 * m_iSampleNumber + j);
|
||||
g = *(datacube + 79 * m_iSampleNumber + j);
|
||||
b = *(datacube + 40 * m_iSampleNumber + j);
|
||||
r = *(datacube + rBandNumber * m_iSampleNumber + j);
|
||||
g = *(datacube + gBandNumber * m_iSampleNumber + j);
|
||||
b = *(datacube + bBandNumber * m_iSampleNumber + j);
|
||||
|
||||
//将像元值赋值到cv::Mat中,操作像元值:https://zhuanlan.zhihu.com/p/51842288
|
||||
//int dataType = m_matRgbImage->type();//当数据类型为CV_16UC3时,返回18
|
||||
|
||||
@ -21,7 +21,7 @@ public:
|
||||
CImage(QWidget* pParent = NULL);
|
||||
//~CImage();
|
||||
void SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber);
|
||||
void FillRgbImage(unsigned short *datacube);
|
||||
void FillRgbImage(unsigned short *datacube, int rBandNumber, int gBandNumber, int bBandNumber);
|
||||
void FillFocusGrayImage(unsigned short *datacube);
|
||||
void FillFocusGrayQImage(unsigned short * datacube);
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ QImage ImageProcessor::Mat2QImage(cv::Mat cvImg)//https://www.cnblogs.com/annt/p
|
||||
QImage::Format_RGB888);
|
||||
}
|
||||
|
||||
return qImg;
|
||||
return qImg.copy(); // 返回独立数据副本,避免cvImg被覆盖导致QImage数据失效
|
||||
}
|
||||
|
||||
cv::Mat ImageProcessor::CStretchDeal(const cv::Mat img, const uint minnum, const uint maxnum)
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>219</height>
|
||||
<width>489</width>
|
||||
<height>329</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -70,18 +70,50 @@ QPushButton:pressed
|
||||
}</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 row="2" 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>D:\</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="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
@ -96,6 +128,19 @@ QPushButton:pressed
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<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="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
@ -165,7 +210,7 @@ QPushButton:pressed
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="4" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -178,6 +223,44 @@ QPushButton:pressed
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<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="fileNameLineEdit">
|
||||
<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>test</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
#include "rgbCameraWindow.h"
|
||||
#include <Qthread>
|
||||
#include "rgbCameraWindow.h"
|
||||
#include <QThread>
|
||||
#include <QFileDialog>
|
||||
#include "AppSettings.h"
|
||||
|
||||
rgbCameraWindow::rgbCameraWindow(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_captureCoordinator(nullptr)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
@ -11,22 +14,190 @@ rgbCameraWindow::rgbCameraWindow(QWidget* parent)
|
||||
m_RgbCamera->moveToThread(m_RgbCameraThread);
|
||||
m_RgbCameraThread->start();
|
||||
|
||||
connect(ui.open_rgb_camera_btn, SIGNAL(clicked()), m_RgbCamera, SLOT(OpenCamera()));//ʹ<><CAB9><EFBFBD>ź<EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD>̣߳<DFB3>ui<75>̣߳<DFB3>ˢ<EFBFBD><CBA2><EFBFBD><EFBFBD>Ƶ <20><> <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD>濨<EFBFBD><E6BFA8>
|
||||
connect(m_RgbCamera, SIGNAL(PlotSignal()), this, SIGNAL(PlotRgbImageSignal()));
|
||||
|
||||
//m_RgbCamera->setCallback(onPlotRgbImage);
|
||||
//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(ui.open_rgb_camera_btn, &QPushButton::clicked,
|
||||
this, [this]() { if (m_captureCoordinator) m_captureCoordinator->openCamera(); });
|
||||
connect(m_RgbCamera, SIGNAL(CamClosedSignal()), this, SIGNAL(CamClosedSignal()));
|
||||
|
||||
connect(ui.close_rgb_camera_btn, &QPushButton::clicked,
|
||||
this, [this]() { if (m_captureCoordinator) m_captureCoordinator->closeCamera(); });
|
||||
|
||||
connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
|
||||
|
||||
connect(this->ui.take_video_btn, &QPushButton::clicked,
|
||||
this, [this]() {
|
||||
if (m_captureCoordinator)
|
||||
{
|
||||
if (!m_captureCoordinator->isCapturing())
|
||||
m_captureCoordinator->startVideoCapture();
|
||||
else if (m_captureCoordinator->getCurrentMode() == RgbCameraCaptureCoordinator::Video)
|
||||
m_captureCoordinator->stopVideoCapture();
|
||||
}
|
||||
});
|
||||
connect(this->ui.take_photo_btn, &QPushButton::clicked,
|
||||
this, [this]() {
|
||||
if (m_captureCoordinator)
|
||||
{
|
||||
if (!m_captureCoordinator->isCapturing())
|
||||
m_captureCoordinator->startPhotoCapture();
|
||||
else if (m_captureCoordinator->getCurrentMode() == RgbCameraCaptureCoordinator::Photo)
|
||||
m_captureCoordinator->stopPhotoCapture();
|
||||
}
|
||||
});
|
||||
|
||||
connect(ui.fileNameLineEdit, &QLineEdit::textChanged, this, &rgbCameraWindow::onFileNameChanged);
|
||||
|
||||
setupCaptureCoordinator();
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
rgbCameraWindow::~rgbCameraWindow()
|
||||
{
|
||||
delete m_captureCoordinator;
|
||||
m_captureCoordinator = nullptr;
|
||||
|
||||
m_RgbCameraThread->quit();
|
||||
m_RgbCameraThread->wait();
|
||||
delete m_RgbCamera;
|
||||
delete m_RgbCameraThread;
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onCloseRgbCamera()
|
||||
void rgbCameraWindow::toggleTakePhoto()
|
||||
{
|
||||
//std::cout << "<22>ر<EFBFBD><D8B1><EFBFBD>Ƶ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
|
||||
m_RgbCamera->CloseCamera();
|
||||
emit ui.take_photo_btn->clicked();
|
||||
}
|
||||
|
||||
void rgbCameraWindow::setupCaptureCoordinator()
|
||||
{
|
||||
m_captureCoordinator = new RgbCameraCaptureCoordinator(m_RgbCamera, this);
|
||||
|
||||
connect(m_captureCoordinator, &RgbCameraCaptureCoordinator::captureStarted,
|
||||
this, &rgbCameraWindow::onCaptureStarted);
|
||||
connect(m_captureCoordinator, &RgbCameraCaptureCoordinator::captureStopped,
|
||||
this, &rgbCameraWindow::onCaptureStopped);
|
||||
connect(m_captureCoordinator, &RgbCameraCaptureCoordinator::cameraOpened,
|
||||
this, &rgbCameraWindow::onCameraOpened);
|
||||
connect(m_captureCoordinator, &RgbCameraCaptureCoordinator::cameraClosed,
|
||||
this, &rgbCameraWindow::onCameraClosed);
|
||||
connect(m_captureCoordinator, &RgbCameraCaptureCoordinator::cameraOpenFailed,
|
||||
this, &rgbCameraWindow::onCameraOpenFailed);
|
||||
connect(m_captureCoordinator, &RgbCameraCaptureCoordinator::photoCaptured,
|
||||
this, &rgbCameraWindow::onPhotoCaptured);
|
||||
connect(m_RgbCamera, &RgbCameraOperation::photoSavedSignal,
|
||||
this, &rgbCameraWindow::onPhotoSaved);
|
||||
}
|
||||
|
||||
void rgbCameraWindow::startVideoCapture()
|
||||
{
|
||||
if (m_captureCoordinator)
|
||||
{
|
||||
m_captureCoordinator->startVideoCapture();
|
||||
}
|
||||
}
|
||||
|
||||
void rgbCameraWindow::stopVideoCapture()
|
||||
{
|
||||
if (m_captureCoordinator)
|
||||
{
|
||||
m_captureCoordinator->stopVideoCapture();
|
||||
}
|
||||
}
|
||||
|
||||
void rgbCameraWindow::startPhotoCapture()
|
||||
{
|
||||
if (m_captureCoordinator)
|
||||
{
|
||||
m_captureCoordinator->startPhotoCapture();
|
||||
}
|
||||
}
|
||||
|
||||
void rgbCameraWindow::stopPhotoCapture()
|
||||
{
|
||||
if (m_captureCoordinator)
|
||||
{
|
||||
m_captureCoordinator->stopPhotoCapture();
|
||||
}
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onCaptureStarted(RgbCameraCaptureCoordinator::CaptureMode mode)
|
||||
{
|
||||
if (mode == RgbCameraCaptureCoordinator::Video)
|
||||
{
|
||||
ui.take_video_btn->setText(QString::fromLocal8Bit("停止录制"));
|
||||
}
|
||||
else if (mode == RgbCameraCaptureCoordinator::Photo)
|
||||
{
|
||||
ui.take_photo_btn->setText(QString::fromLocal8Bit("采集中..."));
|
||||
}
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onCaptureStopped(RgbCameraCaptureCoordinator::CaptureMode mode)
|
||||
{
|
||||
if (mode == RgbCameraCaptureCoordinator::Video)
|
||||
{
|
||||
ui.take_video_btn->setText(QString::fromLocal8Bit("录制视频"));
|
||||
}
|
||||
else if (mode == RgbCameraCaptureCoordinator::Photo)
|
||||
{
|
||||
ui.take_photo_btn->setText(QString::fromLocal8Bit("拍照"));
|
||||
}
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onCameraOpened()
|
||||
{
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onCameraClosed()
|
||||
{
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onCameraOpenFailed(const QString& error)
|
||||
{
|
||||
//QMessageBox::warning(this, QString::fromLocal8Bit("相机打开失败"), error);
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onPhotoCaptured(const QString& filePath)
|
||||
{
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onPhotoSaved(const QString& filePath)
|
||||
{
|
||||
// 可在此更新界面,例如显示已保存的照片数量
|
||||
std::cout << "照片已保存: " << filePath.toStdString() << std::endl;
|
||||
}
|
||||
|
||||
void rgbCameraWindow::loadSettings()
|
||||
{
|
||||
QString folder = AppSettings::instance().rgbCameraDataFolder();
|
||||
setDataFolder(folder);
|
||||
setFileName(AppSettings::instance().rgbCameraFileName());
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onSelectDataFolder()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
QString::fromLocal8Bit("选择数据保存路径"),
|
||||
ui.dataFolderLineEdit->text());
|
||||
|
||||
setDataFolder(dir);
|
||||
}
|
||||
|
||||
void rgbCameraWindow::setDataFolder(QString dir)
|
||||
{
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
ui.dataFolderLineEdit->setText(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void rgbCameraWindow::setFileName(QString name)
|
||||
{
|
||||
ui.fileNameLineEdit->setText(name);
|
||||
}
|
||||
|
||||
void rgbCameraWindow::onFileNameChanged(const QString& text)
|
||||
{
|
||||
AppSettings::instance().setRgbCameraFileName(text);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
@ -8,6 +8,7 @@
|
||||
#include "ui_rgbCamera.h"
|
||||
|
||||
#include "RgbCameraOperation.h"
|
||||
#include "RgbCameraCaptureCoordinator.h"
|
||||
|
||||
class rgbCameraWindow : public QDialog
|
||||
{
|
||||
@ -19,16 +20,43 @@ public:
|
||||
|
||||
RgbCameraOperation* m_RgbCamera;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onCloseRgbCamera();
|
||||
// 视频采集控制
|
||||
void startVideoCapture();
|
||||
void stopVideoCapture();
|
||||
|
||||
signals:
|
||||
// 照片采集控制
|
||||
void startPhotoCapture();
|
||||
void stopPhotoCapture();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onSelectDataFolder();
|
||||
void onFileNameChanged(const QString& text);
|
||||
|
||||
void toggleTakePhoto();
|
||||
|
||||
Q_SIGNALS:
|
||||
void PlotRgbImageSignal();
|
||||
void CamClosedSignal();
|
||||
|
||||
private Q_SLOTS:
|
||||
// 协调器信号处理
|
||||
void onCaptureStarted(RgbCameraCaptureCoordinator::CaptureMode mode);
|
||||
void onCaptureStopped(RgbCameraCaptureCoordinator::CaptureMode mode);
|
||||
void onCameraOpened();
|
||||
void onCameraClosed();
|
||||
void onCameraOpenFailed(const QString& error);
|
||||
void onPhotoCaptured(const QString& filePath);
|
||||
void onPhotoSaved(const QString& filePath);
|
||||
|
||||
private:
|
||||
Ui::rgbCameraClass ui;
|
||||
|
||||
|
||||
QThread* m_RgbCameraThread;//rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡͼ<C8A1><CDBC><EFBFBD>߳<EFBFBD>
|
||||
QThread* m_RgbCameraThread;//rgb相机获取图像线程
|
||||
RgbCameraCaptureCoordinator* m_captureCoordinator;
|
||||
|
||||
void setDataFolder(QString dir);
|
||||
void setFileName(QString name);
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void setupCaptureCoordinator();
|
||||
};
|
||||
|
||||
129
HPPA/set.ui
129
HPPA/set.ui
@ -9,8 +9,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>641</width>
|
||||
<height>320</height>
|
||||
<width>651</width>
|
||||
<height>319</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -52,6 +52,9 @@ QLineEdit {
|
||||
min-height: 20px;
|
||||
font-size: 13px;
|
||||
}
|
||||
QLineEdit:hover {
|
||||
border: 1px solid #409eff;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
@ -234,10 +237,44 @@ QPushButton:pressed
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2" rowstretch="3,2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<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;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>580</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="confirmBtn">
|
||||
<property name="text">
|
||||
<string>确认</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>保存</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@ -247,6 +284,9 @@ QPushButton:pressed
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="dataFolderLineEdit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -262,26 +302,73 @@ QPushButton:pressed
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="5,2">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>显示</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>图像显示</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>411</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="confirmBtn">
|
||||
<property name="text">
|
||||
<string>确认</string>
|
||||
<widget class="QComboBox" name="hyperimgDisplayMode_comboBox">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QComboBox {
|
||||
color: white;
|
||||
background-color: #142D7F;
|
||||
border: 1px solid #2f6bff;
|
||||
border-radius: 6px;
|
||||
padding: 4px 8px;
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
QComboBox:hover {
|
||||
border: 1px solid #409eff;
|
||||
}
|
||||
|
||||
QComboBox:focus {
|
||||
border: 1px solid #409eff;
|
||||
}
|
||||
|
||||
QComboBox::drop-down {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: top right;
|
||||
width: 25px;
|
||||
|
||||
border-left: 1px solid #2f6bff;
|
||||
}
|
||||
|
||||
QComboBox::down-arrow {
|
||||
image: url(:/images/arrow_down.png);
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView {
|
||||
color: white;
|
||||
background-color: #142D7F;
|
||||
border: 1px solid #2f6bff;
|
||||
selection-background-color: #409eff;
|
||||
selection-color: white;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView::item {
|
||||
min-height: 30px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView::item:hover {
|
||||
background-color: #e6f7ff;
|
||||
}</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -10,6 +10,10 @@ setWindow::setWindow(QWidget* parent)
|
||||
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
|
||||
//顺序不能更改,和AppSettings::HyperimgDisplayMode一致
|
||||
ui.hyperimgDisplayMode_comboBox->addItem("full");
|
||||
ui.hyperimgDisplayMode_comboBox->addItem("waterfall");
|
||||
|
||||
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()));
|
||||
@ -24,11 +28,18 @@ setWindow::~setWindow()
|
||||
void setWindow::loadSettings()
|
||||
{
|
||||
ui.dataFolderLineEdit->setText(AppSettings::instance().dataFolder());
|
||||
|
||||
ui.hyperimgDisplayMode_comboBox->setCurrentIndex(
|
||||
static_cast<int>(AppSettings::instance().hyperimgDisplayMode()));
|
||||
}
|
||||
|
||||
void setWindow::saveSettings()
|
||||
{
|
||||
AppSettings::instance().setDataFolder(ui.dataFolderLineEdit->text());
|
||||
AppSettings::instance().setHyperimgDisplayMode(
|
||||
ui.hyperimgDisplayMode_comboBox->currentIndex() == 0
|
||||
? AppSettings::HyperimgDisplayMode::Full
|
||||
: AppSettings::HyperimgDisplayMode::Waterfall);
|
||||
}
|
||||
|
||||
void setWindow::onSelectDataFolder()
|
||||
|
||||
43
JinspSpectralmeterControl/IrisFiberSpectrometerBase.h
Normal file
43
JinspSpectralmeterControl/IrisFiberSpectrometerBase.h
Normal file
@ -0,0 +1,43 @@
|
||||
#include "QObject"
|
||||
#include <string>
|
||||
#include "ZZ_Types.h"
|
||||
#pragma once
|
||||
using namespace ZZ_MISCDEF;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class CIrisFSBase:public QObject
|
||||
{
|
||||
public:
|
||||
//CIrisFSBase();
|
||||
//virtual ~CIrisFSBase()= 0;
|
||||
public:
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
//<2F>˴<EFBFBD>stringΪָ<CEAA><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ocean<61><6E><EFBFBD><EFBFBD><EFBFBD>ǵIJ<C7B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>c/c++<2B><><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
//0Ϊ<30><EFBFBD><DEB4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD>ز<EFBFBD>ֵͬ
|
||||
virtual int Initialize(bool bIsUSBMode,std::string ucPortNumber,std::string strDeviceName) = 0;
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
virtual void Close() = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
virtual int SingleShot(DataFrame &dfData) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
virtual int SetExposureTime(int iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetExposureTime(int &iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
virtual int SetDeviceTemperature(float fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceTemperature(float &fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
virtual int GetDeviceInfo(DeviceInfo &Info) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceAttribute(DeviceAttribute &Attr) = 0;
|
||||
|
||||
};
|
||||
578
JinspSpectralmeterControl/JinspSpectralmeterControl.cpp
Normal file
578
JinspSpectralmeterControl/JinspSpectralmeterControl.cpp
Normal file
@ -0,0 +1,578 @@
|
||||
#include "JinspSpectralmeterControl.h"
|
||||
|
||||
JinspSpectralmeterControl::JinspSpectralmeterControl(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_pSerialPort = new QSerialPort;
|
||||
m_iBaudRate = 921600;
|
||||
}
|
||||
|
||||
JinspSpectralmeterControl::~JinspSpectralmeterControl()
|
||||
{
|
||||
delete m_pSerialPort;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
QString qstrPortName = QString::fromStdString(ucPortNumber);
|
||||
m_pSerialPort->setPortName(qstrPortName);
|
||||
m_pSerialPort->setReadBufferSize(512);
|
||||
|
||||
bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate);
|
||||
if (!bRes)
|
||||
{
|
||||
//qDebug() << "Err:setBaudRate Failed.Exit Code:1";
|
||||
//std::cout << "Err.setBaudRate Failed" << std::endl;
|
||||
printf("Err:setBaudRate Failed.Exit Code:1");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bRes = m_pSerialPort->open(QIODevice::ReadWrite);
|
||||
if (!bRes)
|
||||
{
|
||||
//qDebug() << "Err:open Failed.Exit Code:2";
|
||||
//std::cout << "Err.open Failed" << std::endl;
|
||||
printf("Err:open Failed.Exit Code:2");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
// int testi;
|
||||
// GetDeviceAttribute(m_daDeviceAttr);
|
||||
// GetExposureTime(testi);
|
||||
// SetExposureTime(10000);
|
||||
// DataFrame test;
|
||||
// SingleShot(test);
|
||||
|
||||
GetDeviceInfo(m_diDeviceInfo);
|
||||
//GetExposureTime_Init();
|
||||
|
||||
std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName);
|
||||
if (szPostion == std::string::npos)
|
||||
{
|
||||
printf("Err:FS serial number not match.Exit Code:3");
|
||||
//qDebug() << "Err:FS serial number not match.Exit Code:3";
|
||||
//return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void JinspSpectralmeterControl::Close()
|
||||
{
|
||||
m_pSerialPort->close();
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::SingleShot(DataFrame& dfData)
|
||||
{
|
||||
SendData_CMD03((char*)GET_ALL_DN, sizeof(GET_ALL_DN));
|
||||
RecvData_CMD03(dfData);
|
||||
|
||||
GetExposureTime(m_iExposureTime);
|
||||
dfData.usExposureTimeInMS = (unsigned short)m_iExposureTime;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
QByteArray qbaRecv;
|
||||
qbaRecv.clear();
|
||||
|
||||
unsigned char pucExposureTime[2];
|
||||
pucExposureTime[0] = iExposureTimeInMS / 256;
|
||||
pucExposureTime[1] = iExposureTimeInMS % 256;
|
||||
SendData_CMD06((char*)SET_INTEGRAL_TIME, sizeof(SET_INTEGRAL_TIME), (char*)pucExposureTime, 2);
|
||||
//SendData_CMD03((char *)GET_INTEGRAL_TIME, sizeof(GET_INTEGRAL_TIME));
|
||||
int iRes = RecvData_CMD06(qbaRecv);
|
||||
return iRes;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::GetExposureTime(int& iExposureTimeInMS)
|
||||
{
|
||||
QByteArray qbaRecv;
|
||||
qbaRecv.clear();
|
||||
SendData_CMD03((char*)GET_INTEGRAL_TIME, sizeof(GET_INTEGRAL_TIME));
|
||||
int iRes = RecvData_CMD03(qbaRecv);
|
||||
|
||||
iExposureTimeInMS = qbaRecv[0] * 256 + static_cast<unsigned char>(qbaRecv[1]);
|
||||
return iRes;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::GetDeviceInfo(DeviceInfo& Info)
|
||||
{
|
||||
Info.strPN = "IS11";
|
||||
Info.strSN = "NULL";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::GetDeviceAttribute(DeviceAttribute& Attr)
|
||||
{
|
||||
QByteArray qbaRecv;
|
||||
qbaRecv.clear();
|
||||
float fCoef[4];
|
||||
unsigned short usTempCoef[8];
|
||||
|
||||
Attr.iPixels = 2048;
|
||||
Attr.iMinIntegrationTimeInMS = 1;
|
||||
Attr.iMaxIntegrationTimeInMS = 60000;
|
||||
|
||||
SendData_CMD03((char*)GET_WAVELENTH_COEFF, sizeof(GET_WAVELENTH_COEFF));
|
||||
RecvData_CMD03(qbaRecv);
|
||||
|
||||
//memcpy(fTempCoef,qbaRecv,16);
|
||||
memcpy(usTempCoef, qbaRecv, 16);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
usTempCoef[i] = qToBigEndian(usTempCoef[i]);
|
||||
}
|
||||
|
||||
//float *pfTemp = (float*)usTempCoef;
|
||||
memcpy(fCoef, usTempCoef, 16);
|
||||
|
||||
//Conv_LTB((char*)fTempCoef,16);
|
||||
|
||||
for (int i = 0; i <= 2048; i++)
|
||||
{
|
||||
Attr.fWaveLengthInNM[i] = fCoef[0] * i * i * i + fCoef[1] * i * i + fCoef[2] * i + fCoef[3];
|
||||
//setem.WavelenthStr = setem.WavelenthStr + String(setem.wavelenthlist[i - 1]).c_str() + ",";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::SetDeviceTemperature(float fTemperature)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::GetDeviceTemperature(float& fTemperature)
|
||||
{
|
||||
fTemperature = -1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float& fPredictedExposureTime)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// unsigned short JinspSpectralmeterControl::crc16(const uint8_t *pbdata, size_t sz)
|
||||
// {
|
||||
// uint16_t i, j, tmp, CRC16;
|
||||
//
|
||||
// CRC16 = 0xFFFF; // CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼֵ
|
||||
// for (i = 0; i < sz; i++)
|
||||
// {
|
||||
// CRC16 ^= pbdata[i];
|
||||
// for (j = 0; j < 8; j++)
|
||||
// {
|
||||
// tmp = (uint16_t)(CRC16 & 0x0001);
|
||||
// CRC16 >>= 1;
|
||||
// if (tmp == 1)
|
||||
// {
|
||||
// CRC16 ^= 0xa001; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return CRC16;
|
||||
// }
|
||||
|
||||
unsigned short JinspSpectralmeterControl::CalCRC16(const uint8_t* pbData, size_t szLength)
|
||||
{
|
||||
uint16_t usCRC16 = CRC16_INIT;
|
||||
for (size_t i = 0; i < szLength; i++)
|
||||
{
|
||||
usCRC16 ^= pbData[i];
|
||||
for (size_t j = 0; j < 8; j++)
|
||||
{
|
||||
if ((usCRC16 & 0x0001) != 0)
|
||||
{
|
||||
usCRC16 = (usCRC16 >> 1) ^ CRC16_POLYNOMIAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
usCRC16 = usCRC16 >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return usCRC16;
|
||||
}
|
||||
|
||||
void JinspSpectralmeterControl::Conv_LTB(char* pcData, int iLength)
|
||||
{
|
||||
char* TempData = new char[iLength];
|
||||
memcpy(TempData, pcData, iLength);
|
||||
|
||||
for (int i = 0; i < iLength / 2; i++)
|
||||
{
|
||||
pcData[2 * i] = TempData[2 * i + 1];
|
||||
pcData[2 * i + 1] = TempData[2 * i];
|
||||
/* code */
|
||||
}
|
||||
delete[] TempData;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::SendData_CMD03(char* pcCMD, size_t szCMDLength)
|
||||
{
|
||||
QString qstrSend, qstrCRC16;
|
||||
QByteArray qbaSend;
|
||||
qbaSend.clear();
|
||||
|
||||
//char *pctest=new char[szCMDLength+2];
|
||||
//memcpy(pctest, pcCMD, szCMDLength);
|
||||
//ushort ustest = crc16((unsigned char*)pcCMD,szCMDLength);
|
||||
//qstrCRC16= QString::fromLatin1((const char*)usCRC16, (int)sizeof(uint16_t));
|
||||
//memcpy(pctest+ szCMDLength,&usCRC16, 2);
|
||||
//int iReturn = m_pSerialPort->write(pctest,szCMDLength+2);
|
||||
//delete[] pctest;
|
||||
uint16_t usCRC16 = CalCRC16((unsigned char*)pcCMD, szCMDLength);
|
||||
qstrSend = QString::fromLatin1((const char*)pcCMD, (int)szCMDLength);
|
||||
const char* pucSend = (char*)&usCRC16;
|
||||
|
||||
qbaSend.append(qstrSend);
|
||||
qbaSend.append(pucSend, (int)sizeof(uint16_t));
|
||||
|
||||
int iReturn = m_pSerialPort->write(qbaSend);
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::RecvData_CMD03(QByteArray& qbaRecv)
|
||||
{
|
||||
int iRetryCount = 0;
|
||||
QByteArray qbaOriRecv, qbaTemp;
|
||||
qbaOriRecv.clear();
|
||||
qbaTemp.clear();
|
||||
|
||||
///read all once
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 3) == 1)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(1000);
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
iRetryCount++;
|
||||
if (iRetryCount > 100)
|
||||
{
|
||||
qDebug() << "Recv Hdr Err.out of retry time.RecvData_CMD03";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
iRetryCount = 0;
|
||||
while (qbaOriRecv.size() < qbaOriRecv[2] + 5)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(1000);
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
iRetryCount++;
|
||||
if (iRetryCount > 66)
|
||||
{
|
||||
qDebug() << "Recv Data Err.out of retry time";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (qbaOriRecv.size() != qbaOriRecv[2] + 5)
|
||||
{
|
||||
/// can be handled but dont want to
|
||||
qDebug() << "Wrong Recv data size.RecvData_CMD03_QBA";
|
||||
return 3;
|
||||
}
|
||||
|
||||
unsigned short usCRCC = CalCRC16((unsigned char*)qbaOriRecv.data(), qbaOriRecv.size() - 2);
|
||||
char* pc = (char*)&usCRCC;
|
||||
if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) ||
|
||||
(pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1]))
|
||||
{
|
||||
qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
///error crc
|
||||
qDebug() << "Recv data crc16 Err." << pc[1] << pc[0];
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
/*while (ParseHdr(qbaOriRecv, 3)==1)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(100);
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
}*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::RecvData_CMD03(DataFrame& dfData)
|
||||
{
|
||||
int iRecvDataLength = 0;
|
||||
int iRetryCount = 0;
|
||||
QByteArray qbaOriRecv, qbaTemp;
|
||||
qbaOriRecv.clear();
|
||||
qbaTemp.clear();
|
||||
|
||||
///read all once
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
while (qbaOriRecv.size() < 4 || ParseHdr(qbaOriRecv, 3) == 1)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(1000);
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
iRetryCount++;
|
||||
if (iRetryCount > 66)
|
||||
{
|
||||
qDebug() << "Recv Hdr Err.out of retry time";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int length = qbaOriRecv[2] * 256 + qbaOriRecv[3];
|
||||
iRetryCount = 0;
|
||||
while (qbaOriRecv.size() < length + 4)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(1000);
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
iRetryCount++;
|
||||
if (iRetryCount > 66)
|
||||
{
|
||||
qDebug() << "Recv Data Err.out of retry time";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (qbaOriRecv.size() != length + 4)
|
||||
{
|
||||
/// can be handled but dont want to
|
||||
qDebug() << "Wrong Recv data size.RecvData_CMD03_DF";
|
||||
return 3;
|
||||
}
|
||||
|
||||
QByteArray qbaData;
|
||||
qbaData = qbaOriRecv.right(length);
|
||||
|
||||
int iDataSizeInPixel = qbaData.size() / 2;
|
||||
unsigned short* pusData = new unsigned short[iDataSizeInPixel];
|
||||
|
||||
memcpy(pusData, qbaData, iDataSizeInPixel * 2);
|
||||
for (size_t i = 0; i < iDataSizeInPixel; i++)
|
||||
{
|
||||
dfData.lData[i] = qToBigEndian(pusData[i]);
|
||||
//qDebug() << dfData.lData[i];
|
||||
|
||||
}
|
||||
///it seems the manufacture not enable crc16 check for this function
|
||||
// unsigned short usCRCC = CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size() - 2);
|
||||
// char *pc = (char *)&usCRCC;
|
||||
// if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) ||
|
||||
// (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1]))
|
||||
// {
|
||||
// //qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5);
|
||||
// //dataframe process here
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ///error crc
|
||||
// qDebug() << "Recv data crc16 Err." << pc[1] << pc[0];
|
||||
// return 4;
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//int JinspSpectralmeterControl::RecvData_CMD03(float& fWavelength)
|
||||
//{
|
||||
// int iRetryCount = 0;
|
||||
// QByteArray qbaOriRecv, qbaTemp,qbaRecv;
|
||||
// qbaOriRecv.clear();
|
||||
// qbaTemp.clear();
|
||||
// qbaRecv.clear();
|
||||
//
|
||||
// ///read all once
|
||||
// Read_IS11(qbaTemp);
|
||||
// qbaOriRecv.append(qbaTemp);
|
||||
// while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 3) == 1)
|
||||
// {
|
||||
// m_pSerialPort->waitForReadyRead(100);
|
||||
// Read_IS11(qbaTemp);
|
||||
// qbaOriRecv.append(qbaTemp);
|
||||
// iRetryCount++;
|
||||
// if (iRetryCount > 20)
|
||||
// {
|
||||
// qDebug() << "Recv Hdr Err.out of retry time";
|
||||
// return 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// iRetryCount = 0;
|
||||
// while (qbaOriRecv.size() < qbaOriRecv[2] + 5)
|
||||
// {
|
||||
// m_pSerialPort->waitForReadyRead(100);
|
||||
// Read_IS11(qbaTemp);
|
||||
// qbaOriRecv.append(qbaTemp);
|
||||
// iRetryCount++;
|
||||
// if (iRetryCount > 20)
|
||||
// {
|
||||
// qDebug() << "Recv Data Err.out of retry time";
|
||||
// return 2;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (qbaOriRecv.size() != qbaOriRecv[2] + 5)
|
||||
// {
|
||||
// /// can be handled but dont want to
|
||||
// qDebug() << "Wrong Recv data size.";
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// unsigned short usCRCC = CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size() - 2);
|
||||
// char *pc = (char *)&usCRCC;
|
||||
// if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) ||
|
||||
// (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1]))
|
||||
// {
|
||||
// qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ///error crc
|
||||
// qDebug() << "Recv data crc16 Err." << pc[1] << pc[0];
|
||||
// return 4;
|
||||
// }
|
||||
//
|
||||
// fWavelength = qbaRecv.toFloat();
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
int JinspSpectralmeterControl::SendData_CMD06(char* pcCMD, size_t szCMDLength, char* pcValue, size_t szValueLenth)
|
||||
{
|
||||
// QString qstrSend, qstrSend1, qstrCRC16;///QByteArray append<6E><64><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
// QByteArray qbaSend;
|
||||
// qbaSend.clear();
|
||||
//
|
||||
// qstrSend = QString::fromLatin1(pcCMD, (int)szCMDLength);
|
||||
// qbaSend.append(qstrSend);
|
||||
//
|
||||
// qstrSend1.clear();
|
||||
// qstrSend1 = QString::fromLatin1(pcValue,(int)szValueLenth);
|
||||
// qbaSend.append(qstrSend1);
|
||||
|
||||
QByteArray qbaSend;
|
||||
qbaSend.append(pcCMD, szCMDLength);
|
||||
qbaSend.append(pcValue, szValueLenth);
|
||||
|
||||
unsigned short usCRC16 = CalCRC16((unsigned char*)qbaSend.data(), qbaSend.size());
|
||||
const char* pucSend = (char*)&usCRC16;
|
||||
qbaSend.append(pucSend, (int)sizeof(unsigned short));
|
||||
|
||||
int iReturn = m_pSerialPort->write(qbaSend);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::RecvData_CMD06(QByteArray& qbaRecv)
|
||||
{
|
||||
int iRetryCount = 0;
|
||||
QByteArray qbaOriRecv, qbaTemp;
|
||||
qbaOriRecv.clear();
|
||||
qbaTemp.clear();
|
||||
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 6) == 1)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(1000);
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
iRetryCount++;
|
||||
if (iRetryCount > 100)
|
||||
{
|
||||
qDebug() << "Recv Hdr Err.out of retry time.RecvData_CMD06";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
iRetryCount = 0;
|
||||
while (qbaOriRecv.size() < 8)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(1000);
|
||||
Read_IS11(qbaTemp);
|
||||
qbaOriRecv.append(qbaTemp);
|
||||
iRetryCount++;
|
||||
if (iRetryCount > 66)
|
||||
{
|
||||
qDebug() << "Recv Data Err.out of retry time";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (qbaOriRecv.size() != 8)
|
||||
{
|
||||
/// can be handled but dont want to
|
||||
qDebug() << "Wrong Recv data size.RecvData_CMD06";
|
||||
return 3;
|
||||
}
|
||||
|
||||
unsigned short usCRCC = CalCRC16((unsigned char*)qbaOriRecv.data(), qbaOriRecv.size() - 2);
|
||||
char* pc = (char*)&usCRCC;
|
||||
if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) ||
|
||||
(pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1]))
|
||||
{
|
||||
qbaRecv = qbaOriRecv.mid(2, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
///error crc
|
||||
qDebug() << "Recv data crc16 Err." << pc[1] << pc[0];
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::ParseHdr(QByteArray& qbaData, char cHdrType)
|
||||
{
|
||||
QByteArray qbaTemp(qbaData);
|
||||
while ((qbaTemp[0] != (char)0x01) && (qbaTemp[1] != cHdrType))
|
||||
{
|
||||
qbaTemp.remove(0, 1);
|
||||
if (qbaTemp.size() <= 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (qbaTemp != qbaData)
|
||||
{
|
||||
///warning some communication error may happened.
|
||||
qbaData = qbaTemp;
|
||||
return 1000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::Write_IS11(char* pcCMD, size_t szCMDLength)
|
||||
{
|
||||
QString qstrSend;
|
||||
QByteArray qbaSend;
|
||||
qbaSend.clear();
|
||||
|
||||
qstrSend = QString::fromLatin1((const char*)pcCMD, (int)szCMDLength);
|
||||
return (int)m_pSerialPort->write(qbaSend);
|
||||
}
|
||||
|
||||
int JinspSpectralmeterControl::Read_IS11(QByteArray& qbaRecv)
|
||||
{
|
||||
//m_pSerialPort->waitForReadyRead(100);
|
||||
qbaRecv = m_pSerialPort->readAll();
|
||||
return qbaRecv.size();
|
||||
}
|
||||
132
JinspSpectralmeterControl/JinspSpectralmeterControl.h
Normal file
132
JinspSpectralmeterControl/JinspSpectralmeterControl.h
Normal file
@ -0,0 +1,132 @@
|
||||
#pragma once
|
||||
|
||||
#include "jinspspectralmetercontrol_global.h"
|
||||
|
||||
#include "IrisFiberSpectrometerBase.h"
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtEndian>
|
||||
#include "ZZ_Math.h"
|
||||
|
||||
#define CRC16_INIT 0xFFFF
|
||||
#define CRC16_POLYNOMIAL 0xa001
|
||||
|
||||
const uint8_t GET_ADDRESS[] = { 0x01,0x03,0x00,0x01,0x00,0x01 };
|
||||
const uint8_t GET_BANDRATE[] = { 0x01,0x03,0x00,0x02,0x00,0x01 };
|
||||
const uint8_t GET_INTEGRAL_TIME[] = { 0x01,0x03,0x00,0x06,0x00,0x01 };
|
||||
const uint8_t GET_AVERAGE_NUMBER[] = { 0x01,0x03,0x00,0x07,0x00,0x01 };
|
||||
const uint8_t GET_WAVELENTH_AT_BAND[] = { 0x01,0x03,0x00,0x10,0x00,0x02 };
|
||||
const uint8_t GET_VALUE_AT_BAND[] = { 0x01,0x03,0x00,0x30,0x00,0x02 };
|
||||
const uint8_t GET_SETTING_OF_LAMP[] = { 0x01,0x03,0x00,0x04,0x00,0x01 };
|
||||
const uint8_t GET_WAVELENTH_COEFF[] = { 0x01,0x03,0x00,0x20,0x00,0x08 };
|
||||
const uint8_t GET_ALL_DN[] = { 0x01,0x03,0x01,0x00,0x10,0x00 };
|
||||
const uint8_t GET_SERIAL_NUMBER[] = { 0x01,0x03,0x00,0x40,0x00,0x00 };
|
||||
const uint8_t GET_PRODUCT_NAME[] = { 0x01,0x03,0x00,0x50,0x00,0x00 };
|
||||
|
||||
const uint8_t SET_ADDRESS[] = { 0x01,0x06,0x00,0x01 };
|
||||
const uint8_t SET_BandRATE[] = { 0x01,0x06,0x00,0x02 };
|
||||
const uint8_t SET_INTEGRAL_TIME[] = { 0x01,0x06,0x00,0x06 };
|
||||
const uint8_t SET_AVERAGE_NUMBER[] = { 0x01,0x06,0x00,0x07 };
|
||||
const uint8_t SET_WORK_MODE[] = { 0x01,0x06,0x00,0x01 };
|
||||
|
||||
const uint8_t SET_WAVELENTH_COEFF[] = { 0x01,0x10,0x00,0x20,0x00,0x08,0x16 };
|
||||
|
||||
class JINSPSPECTRALMETERCONTROL_EXPORT JinspSpectralmeterControl :public CIrisFSBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
JinspSpectralmeterControl(QObject* parent = nullptr);
|
||||
virtual ~JinspSpectralmeterControl();
|
||||
public:
|
||||
//do not call
|
||||
//int ReInit();
|
||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SetBaudRate(int iBaud);
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void Close();
|
||||
|
||||
//<2F><><EFBFBD>β<EFBFBD><CEB2>Բɼ<D4B2> <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SingleShot(int& iPixels);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
int SingleShot(DataFrame& dfData);
|
||||
|
||||
//<2F><><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>
|
||||
//int SingleShotDark(ATPDataFrame &dfData);
|
||||
|
||||
//int SingleShotDeducted(ATPDataFrame &dfData);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int SetExposureTime(int iExposureTimeInMS);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetExposureTime(int& iExposureTimeInMS);
|
||||
|
||||
//int GetWaveLength(float *pfWaveLength);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int GetDeviceInfo(DeviceInfo& Info);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetDeviceAttribute(DeviceAttribute& Attr);
|
||||
|
||||
//int GetDeviceListInfo(); //use type name to enum
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
int SetDeviceTemperature(float fTemperature);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD>
|
||||
int GetDeviceTemperature(float& fTemperature);
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6>ع<EFBFBD>
|
||||
int PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float& fPredictedExposureTime);
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
#else //
|
||||
private:
|
||||
#endif
|
||||
//port
|
||||
int m_iBaudRate;
|
||||
QSerialPort* m_pSerialPort;
|
||||
|
||||
//ATP
|
||||
DeviceInfo m_diDeviceInfo;
|
||||
DeviceAttribute m_daDeviceAttr;
|
||||
|
||||
//Attr
|
||||
int m_iExposureTime;
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
#else //
|
||||
private:
|
||||
#endif
|
||||
//unsigned short crc16(const uint8_t *pbdata, size_t sz);
|
||||
unsigned short CalCRC16(const uint8_t* pbData, size_t szLength);
|
||||
void Conv_LTB(char* pcData, int iLength);
|
||||
|
||||
int Write_IS11(char* pcCMD, size_t szCMDLength);
|
||||
int Read_IS11(QByteArray& qbaRecv);
|
||||
|
||||
|
||||
|
||||
int SendData_CMD03(char* pcCMD, size_t szCMDLength);
|
||||
int RecvData_CMD03(QByteArray& qbaRecv);
|
||||
int RecvData_CMD03(DataFrame& dfData);
|
||||
//int RecvData_CMD03(float& fWavelength);
|
||||
//int RecvData_CMD03(DeviceAttribute& Attr);
|
||||
|
||||
int SendData_CMD06(char* pcCMD, size_t szCMDLength, char* pcValue, size_t szValueLenth);
|
||||
int RecvData_CMD06(QByteArray& qbaRecv);
|
||||
|
||||
int SendData_CMD10(char* pcCMD, size_t szCMDLength);
|
||||
int RecvData_CMD10(QByteArray& qbaRecv);
|
||||
|
||||
int ParseHdr(QByteArray& qbaData, char cHdrType);
|
||||
|
||||
|
||||
};
|
||||
103
JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj
Normal file
103
JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}</ProjectGuid>
|
||||
<Keyword>QtVS_v304</Keyword>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0.26100.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.26100.0</WindowsTargetPlatformVersion>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;serialport</QtModules>
|
||||
<QtBuildConfig>debug</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;serialport</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||
</Target>
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Label="Shared" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<IncludePath>D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>JINSPSPECTRALMETERCONTROL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>JINSPSPECTRALMETERCONTROL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="IrisFiberSpectrometerBase.h" />
|
||||
<ClInclude Include="ZZ_Math.h" />
|
||||
<ClInclude Include="ZZ_Types.h" />
|
||||
<ClInclude Include="jinspspectralmetercontrol_global.h" />
|
||||
<QtMoc Include="JinspSpectralmeterControl.h" />
|
||||
<ClCompile Include="JinspSpectralmeterControl.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||
<Import Project="$(QtMsBuild)\qt.targets" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Form Files">
|
||||
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||
<Extensions>ui</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Translation Files">
|
||||
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||
<Extensions>ts</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="jinspspectralmetercontrol_global.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<QtMoc Include="JinspSpectralmeterControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<ClCompile Include="JinspSpectralmeterControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="IrisFiberSpectrometerBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZZ_Math.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZZ_Types.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
121
JinspSpectralmeterControl/ZZ_Math.h
Normal file
121
JinspSpectralmeterControl/ZZ_Math.h
Normal file
@ -0,0 +1,121 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#//#include "Dense"
|
||||
#include "Eigen/Dense"
|
||||
#include <unsupported/Eigen/Splines>
|
||||
#pragma once
|
||||
|
||||
namespace ZZ_MATH
|
||||
{
|
||||
template<typename T>
|
||||
void MinHeapify(T*arry, int size, int element)
|
||||
{
|
||||
int lchild = element * 2 + 1, rchild = lchild + 1;
|
||||
while (rchild < size)
|
||||
{
|
||||
if (arry[element] <= arry[lchild] && arry[element] <= arry[rchild])
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (arry[lchild] <= arry[rchild])
|
||||
{
|
||||
std::swap(arry[element], arry[lchild]);
|
||||
element = lchild;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::swap(arry[element], arry[rchild]);
|
||||
element = rchild;
|
||||
}
|
||||
lchild = element * 2 + 1;
|
||||
rchild = lchild + 1;
|
||||
}
|
||||
if (lchild < size&&arry[lchild] < arry[element])
|
||||
{
|
||||
std::swap(arry[lchild], arry[element]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void MaxHeapify(T*arry, int size, int element)
|
||||
{
|
||||
int lchild = element * 2 + 1, rchild = lchild + 1;
|
||||
while (rchild < size)
|
||||
{
|
||||
if (arry[element] >= arry[lchild] && arry[element] >= arry[rchild])
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (arry[lchild] >= arry[rchild])
|
||||
{
|
||||
std::swap(arry[element], arry[lchild]);
|
||||
element = lchild;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::swap(arry[element], arry[rchild]);
|
||||
element = rchild;
|
||||
}
|
||||
lchild = element * 2 + 1;
|
||||
rchild = lchild + 1;
|
||||
}
|
||||
if (lchild<size&&arry[lchild]>arry[element])
|
||||
{
|
||||
std::swap(arry[lchild], arry[element]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void HeapSort(T*arry, int size)
|
||||
{
|
||||
int i;
|
||||
for (i = size - 1; i >= 0; i--)
|
||||
{
|
||||
MinHeapify(arry, size, i);
|
||||
}
|
||||
while (size > 0)
|
||||
{
|
||||
std::swap(arry[size - 1], arry[0]);
|
||||
|
||||
size--;
|
||||
MinHeapify(arry, size, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
namespace PolyFit
|
||||
{
|
||||
void Eigen_Polyfit(const std::vector<double> &xv, const std::vector<double> &yv, std::vector<double> &coeff, int order);
|
||||
double Eigen_Polyeval(std::vector<double> coeffs, double x);
|
||||
};
|
||||
|
||||
namespace SplineFit
|
||||
{
|
||||
using namespace Eigen;
|
||||
VectorXd Eigen_Normalize(const VectorXd &x);
|
||||
void Test(std::vector<double> const &x_vec, std::vector<double> const &y_vec);// do not call
|
||||
|
||||
|
||||
class SplineInterpolation
|
||||
{
|
||||
public:
|
||||
SplineInterpolation(Eigen::VectorXd const &x_vec,Eigen::VectorXd const &y_vec);
|
||||
double operator()(double x) const;
|
||||
|
||||
private:
|
||||
double x_min;
|
||||
double x_max;
|
||||
|
||||
double scaled_value(double x) const;
|
||||
Eigen::RowVectorXd scaled_values(Eigen::VectorXd const &x_vec) const;
|
||||
|
||||
Eigen::Spline<double, 1> spline_;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
358
JinspSpectralmeterControl/ZZ_Types.h
Normal file
358
JinspSpectralmeterControl/ZZ_Types.h
Normal file
@ -0,0 +1,358 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <QTime>
|
||||
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
#define ZZ_Enum2String(x) #x
|
||||
|
||||
#pragma pack(1)//<2F>ṹ<EFBFBD>尴<EFBFBD><E5B0B4>1<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD><EFBFBD>洢
|
||||
|
||||
namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
typedef unsigned short int ZZ_U16;
|
||||
typedef unsigned int ZZ_U32;
|
||||
typedef int ZZ_S32;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
{
|
||||
//Fiber Spectrometer
|
||||
namespace FS
|
||||
{
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U32 usExposureTimeInMS;
|
||||
ZZ_S32 lData[4096];
|
||||
float fTemperature = 0;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
||||
typedef struct coeffs//tc<74><63><EFBFBD><EFBFBD>-----------------------
|
||||
{
|
||||
ZZ_U32 coeffsCounter;
|
||||
double coeffs[100];
|
||||
}coeffsFrame;
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}DeviceInfo;
|
||||
|
||||
typedef struct tagDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTimeInMS;
|
||||
int iMinIntegrationTimeInMS;
|
||||
float fWaveLengthInNM[4096];
|
||||
|
||||
}DeviceAttribute;
|
||||
|
||||
// inline DataFrame GetIndex(DataFrame dfDark, DataFrame dfSignal)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
enum DeviceModel
|
||||
{
|
||||
OSIFAlpha=0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
IS2
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline std::string GetDeviceModelName(int iModel)
|
||||
{
|
||||
switch (iModel)
|
||||
{
|
||||
case DeviceModel::OSIFAlpha: return "OSIFAlpha"; break;
|
||||
case DeviceModel::OSIFBeta: return "OSIFBeta"; break;
|
||||
case DeviceModel::ISIF: return "ISIF"; break;
|
||||
case DeviceModel::IS1: return "IS1"; break;
|
||||
case DeviceModel::IS2: return "IS2"; break;
|
||||
default: return "error"; break;
|
||||
}
|
||||
}
|
||||
|
||||
inline int GetIndex(std::string strDeviceModelName)
|
||||
{
|
||||
if (strDeviceModelName == "OSIFAlpha")
|
||||
{
|
||||
return DeviceModel::OSIFAlpha;
|
||||
}
|
||||
else if (strDeviceModelName == "OSIFBeta")
|
||||
{
|
||||
return DeviceModel::OSIFBeta;
|
||||
}
|
||||
else if (strDeviceModelName == "ISIF")
|
||||
{
|
||||
return DeviceModel::ISIF;
|
||||
}
|
||||
else if (strDeviceModelName == "IS1")
|
||||
{
|
||||
return DeviceModel::IS1;
|
||||
}
|
||||
else if (strDeviceModelName == "IS2")
|
||||
{
|
||||
return DeviceModel::IS2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//ATP????<3F><>???
|
||||
namespace ATP
|
||||
{
|
||||
const int MAX_SPECTRUM_SIZE = 4096;
|
||||
|
||||
const int GET_MODULECIRCUIT_TEMP = 0x01;
|
||||
const int GET_PN_NUMBER = 0x03;
|
||||
const int GET_SN_NUMBER = 0x04;
|
||||
const int GET_MANUFACTURE_DATA = 0x06;
|
||||
const int GET_MANUFACTURE_INFO = 0x09;
|
||||
const int GET_PIXEL_LENGTH = 0x0a;
|
||||
const int GET_TEC_TEMP = 0x13;
|
||||
const int SET_TEC_TEMP = 0x12;
|
||||
const int GET_OPTICS_TEMP = 0x35;
|
||||
const int GET_CIRCUITBOARD_TEMP = 0x36;
|
||||
const int SET_INTEGRATION_TIME = 0x14;
|
||||
const int GET_INTEGRATION_TIME = 0x41;
|
||||
const int GET_MAX_INTEGRATION_TIME = 0x42;
|
||||
const int GET_MIN_INTEGRATION_TIME = 0x43;
|
||||
const int ASYNC_COLLECT_DARK = 0x23;
|
||||
const int ASYNC_START_COLLECTION = 0x16;
|
||||
const int ASYNC_READ_DATA = 0x17;
|
||||
const int SET_AVERAGE_NUMBER = 0x28;
|
||||
const int SYNC_GET_DATA = 0x1e;
|
||||
const int SYNC_GET_DARK = 0x2f;
|
||||
const int EXTERNAL_TRIGGER_ENABLE = 0x1f;
|
||||
const int SET_XENON_LAMP_DELAY_TIME = 0x24;
|
||||
const int GET_WAVELENGTH_CALIBRATION_COEF = 0x55;
|
||||
const int GET_STAT_LAMPOUT = 0x60;
|
||||
const int SET_GPIO = 0x61;
|
||||
//const int SYNCHRONIZATION_GET_DARK = 0x23
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////device
|
||||
enum Model
|
||||
{
|
||||
ATP1010 = 0,
|
||||
ATP6500
|
||||
};
|
||||
|
||||
//???????<3F><>??
|
||||
typedef struct tagATPDataFrame
|
||||
{
|
||||
unsigned short usExposureTime;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}ATPDataFrame;
|
||||
|
||||
//?<3F><><EFBFBD><EFBFBD>??????<3F><>??
|
||||
typedef struct tagATPDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}ATPDeviceInfo;
|
||||
|
||||
//?<3F><><EFBFBD><EFBFBD>????<3F><>?<3F><>??
|
||||
typedef struct tagATPDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTime;
|
||||
int iMinIntegrationTime;
|
||||
float fWaveLength[4096];
|
||||
|
||||
}ATPDeviceAttribute;
|
||||
//////////////////////////////////////////////////////////////////////////config file
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//????????
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagErrorInfo
|
||||
{
|
||||
int iDataTransferErr = -1000;
|
||||
float fTecTempErr = -1000;
|
||||
int iShutterErr = -1000;
|
||||
float fChassisTempErr = -1000;
|
||||
}ErrInfo;
|
||||
|
||||
typedef struct tagFiberSpecContext
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
std::string strInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strSN[MAX_DEVICENUMBER_FS];
|
||||
long lDepth[MAX_DEVICENUMBER_FS];
|
||||
float fMinFactor[MAX_DEVICENUMBER_FS];
|
||||
float fMaxFactor[MAX_DEVICENUMBER_FS];
|
||||
ZZ_U16 usPixels[MAX_DEVICENUMBER_FS];
|
||||
float fWavelength[MAX_DEVICENUMBER_FS][4096];
|
||||
}FSContext;
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
{
|
||||
std::string strInterface;
|
||||
ZZ_U8 ucProtocolType;
|
||||
ZZ_U8 ucCmdID;
|
||||
}LSContext;
|
||||
|
||||
typedef struct tagAcquisitionTimeSettings
|
||||
{
|
||||
QTime qtStartTime;
|
||||
QTime qtStopTime;
|
||||
QTime qtInterval;
|
||||
}AcqTimeSettings;
|
||||
|
||||
typedef struct tagAcquisitionPositionSettings
|
||||
{
|
||||
int iTotalPosition;
|
||||
int iPosition[MAX_LINEARSHUTTER_POSITION];
|
||||
}AcqPosSettings;
|
||||
|
||||
typedef struct tagRunTimeGrabberParams
|
||||
{
|
||||
LSContext lscParam;
|
||||
FSContext fscParams;
|
||||
AcqTimeSettings atsParams;
|
||||
AcqPosSettings apsParams;
|
||||
}RunTimeGrabberParams;
|
||||
|
||||
typedef struct tagATPCalibrationSettings
|
||||
{
|
||||
//Up0 Down1,2,3
|
||||
QString qsISIF_CalibrationFilePath[4];
|
||||
QString qsIS1_CalibrationFilePath[4];
|
||||
}ATPCalibrationSettings;
|
||||
}
|
||||
|
||||
//?????????????<3F><>??
|
||||
namespace ZZ_DATAFILE
|
||||
{
|
||||
typedef struct tagEnvironmentalContext
|
||||
{
|
||||
QString qstrUTCDateTime;
|
||||
QString qstrLocation;
|
||||
QString qstrGPS_Longtitude;
|
||||
QString qstrGPS_Latitude;
|
||||
QString qstrGPS_Altitude;
|
||||
QString qstrGPS_North;
|
||||
QString qstrCaseTemperature;
|
||||
QString qstrCaseHumidity;
|
||||
QString qstrDEV_SN;
|
||||
}EContext;
|
||||
|
||||
typedef struct tagManmadeEnviromentalContext
|
||||
{
|
||||
QString qstrOriFileName;
|
||||
QString qstrInstallationTime;
|
||||
QString qstrISIFCalibrationTime;
|
||||
QString qstrIS1CalibrationTime;
|
||||
QString qstrNameOfMaintenanceStaff;
|
||||
QString qstrPhoneNumberOfMaintenanceStaff;
|
||||
QString qstrDownloadUserID;
|
||||
QString qstrDownlaodAddress;
|
||||
QString qstrHTTPServer;
|
||||
}MEContext;
|
||||
|
||||
|
||||
typedef struct tagIS1Information
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}IS1Info;
|
||||
|
||||
typedef struct tagISIFInformation
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}ISIFInfo;
|
||||
|
||||
typedef struct tagATPDataHeader
|
||||
{
|
||||
|
||||
|
||||
}ATPDataHeader;
|
||||
|
||||
typedef struct tagCalibrationFrame
|
||||
{
|
||||
ZZ_U32 uiExposureTimeInMS;
|
||||
float fTemperature;
|
||||
int iPixels;
|
||||
float fWaveLength[4096] = { 0 };
|
||||
double dCal_Gain[4096] = { 0 };
|
||||
double dCal_Offset[4096] = { 0 };
|
||||
}CalFrame;
|
||||
|
||||
typedef struct tagCalDataFrame
|
||||
{
|
||||
ZZ_U32 usExposureTimeInMS;
|
||||
float fTemperature = 0;
|
||||
int iPixels;
|
||||
float fData[4096];
|
||||
QString qstrGrabDate;
|
||||
}CalDataFrame;
|
||||
}
|
||||
|
||||
//misc detector
|
||||
namespace MISC_DETECTOR
|
||||
{
|
||||
typedef struct tagHumitureDeviceInfo
|
||||
{
|
||||
QString qstrInterfaceName;
|
||||
}HumitureDeviceInfo;
|
||||
}
|
||||
};
|
||||
#pragma pack()//<2F>ָ<EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>루<EFBFBD><EBA3A8><EFBFBD><EFBFBD>8<EFBFBD>ֽڣ<D6BD>
|
||||
13
JinspSpectralmeterControl/jinspspectralmetercontrol_global.h
Normal file
13
JinspSpectralmeterControl/jinspspectralmetercontrol_global.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef BUILD_STATIC
|
||||
# if defined(JINSPSPECTRALMETERCONTROL_LIB)
|
||||
# define JINSPSPECTRALMETERCONTROL_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define JINSPSPECTRALMETERCONTROL_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define JINSPSPECTRALMETERCONTROL_EXPORT
|
||||
#endif
|
||||
Reference in New Issue
Block a user