Compare commits
25 Commits
39578dc9fe
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 2747d5f967 | |||
| 83adaa8b8b | |||
| b8febdf8ff | |||
| 08dee5bbec | |||
| 0562e8592c | |||
| 9bc2133e24 | |||
| e552dc2ed5 | |||
| 2e7bf50737 | |||
| 1a64fb32e3 | |||
| ebc39f9f9d | |||
| 9307947ed0 | |||
| 7452748324 | |||
| 6557916b7b | |||
| 392bc98ebf | |||
| 0866b9cd56 | |||
| 33e34aa125 | |||
| abdb27b228 | |||
| 64cdc7591d | |||
| f00fc6fdea | |||
| 10beb03843 | |||
| 64bc8a9d27 | |||
| 6b63d28d2c | |||
| 3feefe45c1 | |||
| 245fc7f4ef | |||
| a49f416551 |
@ -8,6 +8,13 @@ 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;
|
||||
const bool AppSettings::kDefaultImageHorizontalMirror = true;
|
||||
const bool AppSettings::kDefaultImageVerticalMirror = true;
|
||||
const int AppSettings::kDefaultImageRotation = 0;
|
||||
|
||||
AppSettings::AppSettings()
|
||||
: m_settings(QSettings::IniFormat, QSettings::UserScope,
|
||||
@ -115,3 +122,130 @@ 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);
|
||||
}
|
||||
|
||||
double AppSettings::manualMovementSpeed() const
|
||||
{
|
||||
return m_settings.value("OneMotorControl/ManualMovementSpeed", 1).toDouble();
|
||||
}
|
||||
|
||||
void AppSettings::setManualMovementSpeed(double value)
|
||||
{
|
||||
m_settings.setValue("OneMotorControl/ManualMovementSpeed", value);
|
||||
}
|
||||
|
||||
bool AppSettings::isReverseMove() const
|
||||
{
|
||||
return m_settings.value("OneMotorControl/IsReverseMove", 0).toBool();
|
||||
}
|
||||
|
||||
void AppSettings::setIsReverseMove(bool value)
|
||||
{
|
||||
m_settings.setValue("OneMotorControl/IsReverseMove", 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));
|
||||
}
|
||||
|
||||
bool AppSettings::imageHorizontalMirror() const
|
||||
{
|
||||
return m_settings.value("Display/ImageHorizontalMirror", kDefaultImageHorizontalMirror).toBool();
|
||||
}
|
||||
|
||||
void AppSettings::setImageHorizontalMirror(bool value)
|
||||
{
|
||||
m_settings.setValue("Display/ImageHorizontalMirror", value);
|
||||
}
|
||||
|
||||
bool AppSettings::imageVerticalMirror() const
|
||||
{
|
||||
return m_settings.value("Display/ImageVerticalMirror", kDefaultImageVerticalMirror).toBool();
|
||||
}
|
||||
|
||||
void AppSettings::setImageVerticalMirror(bool value)
|
||||
{
|
||||
m_settings.setValue("Display/ImageVerticalMirror", value);
|
||||
}
|
||||
|
||||
int AppSettings::imageRotation() const
|
||||
{
|
||||
return m_settings.value("Display/ImageRotation", kDefaultImageRotation).toInt();
|
||||
}
|
||||
|
||||
void AppSettings::setImageRotation(int value)
|
||||
{
|
||||
m_settings.setValue("Display/ImageRotation", ((value % 360) + 360) % 360);
|
||||
}
|
||||
|
||||
@ -37,6 +37,54 @@ public:
|
||||
|
||||
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);
|
||||
|
||||
// 手动移动速度
|
||||
double manualMovementSpeed() const;
|
||||
void setManualMovementSpeed(double value);
|
||||
|
||||
bool isReverseMove() const;
|
||||
void setIsReverseMove(bool value);
|
||||
|
||||
// 贡嘎山记录端口
|
||||
int gonggaShanRecordPort() const;
|
||||
void setGonggaShanRecordPort(int value);
|
||||
|
||||
// 图像显示模式枚举
|
||||
enum class HyperimgDisplayMode { Full, Waterfall };
|
||||
|
||||
// 图像显示模式
|
||||
HyperimgDisplayMode hyperimgDisplayMode() const;
|
||||
void setHyperimgDisplayMode(HyperimgDisplayMode mode);
|
||||
|
||||
// 图像显示变换(左右镜像/上下镜像/旋转),全局生效
|
||||
bool imageHorizontalMirror() const;
|
||||
void setImageHorizontalMirror(bool value);
|
||||
|
||||
bool imageVerticalMirror() const;
|
||||
void setImageVerticalMirror(bool value);
|
||||
|
||||
// 旋转角度,取值 0、90、180、270
|
||||
int imageRotation() const;
|
||||
void setImageRotation(int value);
|
||||
|
||||
// 在此处添加更多参数的 getter/setter ...
|
||||
|
||||
private:
|
||||
@ -54,4 +102,11 @@ 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;
|
||||
static const bool kDefaultImageHorizontalMirror;
|
||||
static const bool kDefaultImageVerticalMirror;
|
||||
static const int kDefaultImageRotation;
|
||||
};
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "CaptureCoordinator.h"
|
||||
#include <algorithm>
|
||||
|
||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
@ -9,10 +10,10 @@ TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||
, m_isValidCapturing(false)
|
||||
{
|
||||
//这些信号槽是按照逻辑顺序的
|
||||
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, qOverload<int, double, double, int>(&TwoMotionCaptureCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, qOverload<const std::vector<double>, const std::vector<double>, int>(&TwoMotionCaptureCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<const std::vector<double>, const std::vector<double>, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, &TwoMotionCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
@ -443,9 +444,9 @@ OneMotionCaptureCoordinator::OneMotionCaptureCoordinator(
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_motorCtrl, SLOT(move(int, bool, double, int)));
|
||||
connect(this, qOverload<int, double, double, int>(&OneMotionCaptureCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, &OneMotionCaptureCoordinator::moveSignal, m_motorCtrl, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
connect(this, &OneMotionCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
@ -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);
|
||||
|
||||
@ -485,7 +488,7 @@ void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathL
|
||||
m_pathLine.timestamp1 = QDateTime::currentDateTime();
|
||||
|
||||
//移动马达并开始采集高光谱
|
||||
emit moveSignal(0, false, m_pathLine.speedRecord, 1000);
|
||||
emit moveSignal(0, m_pathLine.speedRecord, 1000);
|
||||
emit startRecordHSISignal();
|
||||
}
|
||||
|
||||
@ -497,14 +500,12 @@ void OneMotionCaptureCoordinator::stopStepMotion()
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
//emit stopMotorSignal(0);
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
void OneMotionCaptureCoordinator::handleHyperImagerCaptureComplete()
|
||||
{
|
||||
emit stopMotorSignal(0);
|
||||
m_isHypercamStopRecord = true;
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::getLocBeforeStart()
|
||||
@ -568,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)
|
||||
@ -615,9 +621,9 @@ DarkAndWhiteCaptureCoordinator::DarkAndWhiteCaptureCoordinator(
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_motorCtrl, SLOT(move(int, bool, double, int)));
|
||||
connect(this, qOverload<int, double, double, int>(&DarkAndWhiteCaptureCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::moveSignal, m_motorCtrl, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
@ -661,7 +667,7 @@ void DarkAndWhiteCaptureCoordinator::startStepMotion(double speed)
|
||||
getLocBeforeStart();
|
||||
|
||||
//移动马达并开始采集高光谱
|
||||
emit moveSignal(0, false, m_speed, 1000);
|
||||
emit moveSignal(0, m_speed, 1000);
|
||||
emit startRecordHSISignal();
|
||||
}
|
||||
|
||||
@ -716,3 +722,514 @@ 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有多个重载版本,所以使用qOverload来指定参数类型
|
||||
connect(this, qOverload<int, double, double, int>(&TwoMotor1PosCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, qOverload<const std::vector<double>, const std::vector<double>, int>(&TwoMotor1PosCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<const std::vector<double>, const std::vector<double>, int>(&IrisMultiMotorController::moveTo));
|
||||
|
||||
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, qOverload<int, double, double, int>(&OneMotionCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
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, qOverload<int, double, double, int>(&OneMotorMultiPosCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
|
||||
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,13 +141,14 @@ 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);
|
||||
void moveSignal(int, double, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void startRecordHSISignal();
|
||||
@ -165,6 +166,7 @@ private:
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
bool m_isHypercamStopRecord = false;
|
||||
|
||||
std::vector<double> m_locBeforeStart;
|
||||
void getLocBeforeStart();
|
||||
@ -188,7 +190,7 @@ public slots:
|
||||
signals:
|
||||
void sequenceComplete(int);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveSignal(int, bool, double, int);
|
||||
void moveSignal(int, double, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void startRecordHSISignal();
|
||||
@ -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
|
||||
@ -50,7 +50,7 @@ private:
|
||||
|
||||
public slots:
|
||||
virtual void recordDark(QString path) = 0;
|
||||
virtual void recordTarget(int recordTimes, QString path) = 0;
|
||||
virtual void recordTarget2csv(int recordTimes, QString path) = 0;
|
||||
virtual void autoExpose() = 0;
|
||||
|
||||
signals:
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "FodisWindow.h"
|
||||
#include "FodisWindow.h"
|
||||
#include "JinspFiberImagerConfig.h"
|
||||
|
||||
FodisWindow::FodisWindow(QWidget* parent)
|
||||
@ -9,6 +9,8 @@ FodisWindow::FodisWindow(QWidget* parent)
|
||||
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();
|
||||
|
||||
@ -25,10 +27,9 @@ FodisWindow::FodisWindow(QWidget* parent)
|
||||
|
||||
connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder()));
|
||||
|
||||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> AppSettings <20>ָ<EFBFBD><D6B8><EFBFBD>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD>ϣ<EFBFBD>
|
||||
ui.dataFolderLineEdit->setText(AppSettings::instance().depthCameraDataFolder());
|
||||
connect(ui.fileNameLineEdit, &QLineEdit::textChanged, this, &FodisWindow::onFileNameChanged);
|
||||
|
||||
setDataFolder(AppSettings::instance().FiberImagerDataFolder());
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
FodisWindow::~FodisWindow()
|
||||
@ -39,10 +40,16 @@ FodisWindow::~FodisWindow()
|
||||
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("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>"),
|
||||
QString::fromLocal8Bit("选择数据保存路径"),
|
||||
ui.dataFolderLineEdit->text());
|
||||
|
||||
setDataFolder(dir);
|
||||
@ -57,6 +64,17 @@ void FodisWindow::setDataFolder(QString 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);
|
||||
@ -64,9 +82,27 @@ void FodisWindow::setCaptureInterval(int 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())
|
||||
{
|
||||
emit openFiberImagerSignal();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +111,7 @@ void FodisWindow::onCamOpened()
|
||||
ui.open_btn->setEnabled(false);
|
||||
ui.close_btn->setEnabled(true);
|
||||
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("<EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||
}
|
||||
|
||||
void FodisWindow::closeFiberImager()
|
||||
@ -88,5 +124,5 @@ void FodisWindow::onCamClosed()
|
||||
ui.open_btn->setEnabled(true);
|
||||
ui.close_btn->setEnabled(false);
|
||||
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>"));
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("打 开"));
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
@ -31,22 +31,30 @@ public:
|
||||
|
||||
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();
|
||||
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();
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,119 @@
|
||||
#pragma once
|
||||
#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
|
||||
@ -15,20 +122,229 @@ public:
|
||||
GonggaShanRecordCtl(QWidget* parent = nullptr);
|
||||
~GonggaShanRecordCtl();
|
||||
|
||||
void recordHsiFinished();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onFiberImagerStartExposureSignal();
|
||||
void onRcordFinished();
|
||||
void onFiberImagerExposureCompleteSignal(int exposureTime);
|
||||
|
||||
Q_SIGNALS:
|
||||
// Emitted when user changes any of the R/G/B wavelength values
|
||||
void startRcordHsiSignal();
|
||||
void stopRcordHsiSignal();
|
||||
void gpsAcquisitionDoneSignal_gonggashan(double lat, double lon, double alt);
|
||||
|
||||
void startRcordFodisSignal();
|
||||
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; // 旋转速度(度/秒)
|
||||
};
|
||||
|
||||
240
HPPA/HPPA.cpp
240
HPPA/HPPA.cpp
@ -659,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);
|
||||
@ -666,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);
|
||||
@ -674,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();
|
||||
}
|
||||
|
||||
@ -772,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();
|
||||
@ -930,6 +959,9 @@ void HPPA::initMenubarToolbar()
|
||||
|
||||
ui.mActionPan->setIcon(QIcon(":/svg/resources/icons/svg/pan.svg"));
|
||||
ui.mActionSpectral->setIcon(QIcon(":/svg/resources/icons/svg/spectral.svg"));
|
||||
ui.mActionRotation90->setIcon(QIcon(":/svg/resources/icons/svg/rotate90.svg"));
|
||||
ui.mActionVerticalMirror->setIcon(QIcon(":/svg/resources/icons/svg/VerticalMirror.svg"));
|
||||
ui.mActionHorizontalMirror->setIcon(QIcon(":/svg/resources/icons/svg/HorizontalMirror.svg"));
|
||||
|
||||
connect(ui.mActionPan, &QAction::toggled, this, [=](bool checked) {
|
||||
if (checked)
|
||||
@ -945,6 +977,34 @@ void HPPA::initMenubarToolbar()
|
||||
ui.mActionSpectral->setIcon(QIcon(":/svg/resources/icons/svg/spectral.svg"));
|
||||
});
|
||||
|
||||
connect(ui.mActionRotation90, &QAction::triggered, this, [=](bool) {
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->currentWidget();
|
||||
if (!currentWidget) return;
|
||||
|
||||
QList<Mapcavas*> canvases = currentWidget->findChildren<Mapcavas*>();
|
||||
if (canvases.isEmpty()) return;
|
||||
|
||||
canvases[0]->rotateImage90();
|
||||
});
|
||||
connect(ui.mActionVerticalMirror, &QAction::triggered, this, [=](bool) {
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->currentWidget();
|
||||
if (!currentWidget) return;
|
||||
|
||||
QList<Mapcavas*> canvases = currentWidget->findChildren<Mapcavas*>();
|
||||
if (canvases.isEmpty()) return;
|
||||
|
||||
canvases[0]->toggleVerticalMirror();
|
||||
});
|
||||
connect(ui.mActionHorizontalMirror, &QAction::triggered, this, [=](bool) {
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->currentWidget();
|
||||
if (!currentWidget) return;
|
||||
|
||||
QList<Mapcavas*> canvases = currentWidget->findChildren<Mapcavas*>();
|
||||
if (canvases.isEmpty()) return;
|
||||
|
||||
canvases[0]->toggleHorizontalMirror();
|
||||
});
|
||||
|
||||
// 使用样式表设置透明背景
|
||||
toolBar->setStyleSheet(R"(
|
||||
QToolBar {
|
||||
@ -1050,6 +1110,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)));
|
||||
@ -1057,16 +1122,18 @@ 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"));
|
||||
|
||||
//
|
||||
m_gonggaShanRecordCtl = new GonggaShanRecordCtl(this);
|
||||
m_gonggaShanRecordCtl->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_gonggaShanRecordCtl, QString::fromLocal8Bit("触发采集"));
|
||||
setupGonggashanAutoRecordConnection();
|
||||
|
||||
|
||||
// Connect ImageControl band change to re-render (m_ic created in initControlTabwidget)
|
||||
@ -1074,6 +1141,81 @@ void HPPA::initControlTabwidget()
|
||||
// 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, this, &HPPA::onSequenceCompleteStopRecord);
|
||||
//connect(m_omc, &OneMotorControl::sequenceComplete_motorBack2Origin, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::);
|
||||
}
|
||||
|
||||
void HPPA::onSequenceCompleteStopRecord()
|
||||
{
|
||||
if (m_ScenarioActionGroup->checkedAction() != ui.mActionGonggaRotatingPlatformScenario)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_rgbCameraControlWindow->toggleTakePhoto();
|
||||
m_fodisWindow->closeFiberImager();
|
||||
m_gonggaShanRecordCtl->recordHsiFinished();
|
||||
}
|
||||
|
||||
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())
|
||||
@ -1573,6 +1715,7 @@ void HPPA::createGonggaRotatingPlatformScenario()
|
||||
|
||||
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);
|
||||
@ -1634,6 +1777,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);
|
||||
|
||||
@ -1943,7 +2087,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);
|
||||
|
||||
@ -1977,6 +2124,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];
|
||||
@ -2354,7 +2505,7 @@ void HPPA::disconnectImagerAndCleanup()
|
||||
{
|
||||
m_RecordThread->quit();
|
||||
m_RecordThread->wait(3000);
|
||||
delete m_RecordThread;
|
||||
m_RecordThread->deleteLater();
|
||||
m_RecordThread = nullptr;
|
||||
}
|
||||
|
||||
@ -2491,7 +2642,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()));
|
||||
|
||||
@ -2521,6 +2672,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;
|
||||
|
||||
@ -2530,6 +2690,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;
|
||||
|
||||
@ -2751,6 +2920,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());
|
||||
@ -2810,6 +2983,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);
|
||||
@ -2831,6 +3008,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;
|
||||
@ -2973,22 +3154,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);
|
||||
@ -3005,15 +3186,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();
|
||||
|
||||
19
HPPA/HPPA.h
19
HPPA/HPPA.h
@ -321,6 +321,7 @@ private:
|
||||
PowerControl3D* m_pc3D;
|
||||
RobotArmControl* m_rac;
|
||||
OneMotorControl* m_omc;
|
||||
OneMotorControl_LiftingPlatform* m_omc_LiftingPlatform;
|
||||
TwoMotorControl* m_tmc;
|
||||
FodisWindow* m_fodisWindow;
|
||||
GonggaShanRecordCtl* m_gonggaShanRecordCtl;
|
||||
@ -362,6 +363,9 @@ private:
|
||||
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);
|
||||
@ -426,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();
|
||||
@ -446,10 +450,19 @@ 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);
|
||||
|
||||
void onSequenceCompleteStopRecord();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
<file>resources/icons/svg/tree_tri_down.svg</file>
|
||||
<file>resources/icons/svg/tree_tri_right.svg</file>
|
||||
<file>resources/icons/svg/mIconRaster.svg</file>
|
||||
<file>resources/icons/svg/HorizontalMirror.svg</file>
|
||||
<file>resources/icons/svg/rotate90.svg</file>
|
||||
<file>resources/icons/svg/VerticalMirror.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/png">
|
||||
<file>resources/icons/png/Spectral_Insight_27.png</file>
|
||||
|
||||
24
HPPA/HPPA.ui
24
HPPA/HPPA.ui
@ -203,6 +203,9 @@ QToolBar QToolButton:hover {
|
||||
<addaction name="actionOpenDirectory"/>
|
||||
<addaction name="mActionPan"/>
|
||||
<addaction name="mActionSpectral"/>
|
||||
<addaction name="mActionVerticalMirror"/>
|
||||
<addaction name="mActionHorizontalMirror"/>
|
||||
<addaction name="mActionRotation90"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar">
|
||||
<property name="styleSheet">
|
||||
@ -758,6 +761,27 @@ QPushButton:pressed
|
||||
<string>贡嘎山旋转平台</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionVerticalMirror">
|
||||
<property name="text">
|
||||
<string>上下镜像</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionHorizontalMirror">
|
||||
<property name="text">
|
||||
<string>左右镜像</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>左右镜像</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionRotation90">
|
||||
<property name="text">
|
||||
<string>旋转90度</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>旋转90度</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
<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>
|
||||
@ -71,11 +71,12 @@
|
||||
</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>
|
||||
@ -159,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" />
|
||||
@ -185,6 +187,7 @@
|
||||
<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" />
|
||||
@ -211,6 +214,7 @@
|
||||
<QtUic Include="twoMotorControl.ui" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="DepthValueLogger.h" />
|
||||
<QtMoc Include="fileOperation.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -286,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,9 +226,6 @@
|
||||
<ClCompile Include="PowerControl3D.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TaskTreeModel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PathLine.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -265,6 +241,51 @@
|
||||
<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>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -291,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>
|
||||
@ -339,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>
|
||||
@ -363,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>
|
||||
@ -405,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>
|
||||
@ -423,9 +411,6 @@
|
||||
<QtMoc Include="PowerControl3D.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TaskTreeModel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="FodisWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -435,6 +420,45 @@
|
||||
<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>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -455,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>
|
||||
@ -482,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>
|
||||
@ -497,6 +515,12 @@
|
||||
<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">
|
||||
|
||||
@ -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,9 @@ Mapcavas::Mapcavas(QWidget* pParent) :QGraphicsView(pParent)
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
|
||||
loadSettings();
|
||||
//addSceneCoordinateSystem();
|
||||
}
|
||||
|
||||
Mapcavas::~Mapcavas()
|
||||
@ -55,6 +58,99 @@ Mapcavas::~Mapcavas()
|
||||
|
||||
}
|
||||
|
||||
void Mapcavas::loadSettings()
|
||||
{
|
||||
updateDisplayMode();
|
||||
|
||||
//更新控制图像变换的变量m_imageTransformState
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
m_imageTransformState.horizontalMirror = settings.imageHorizontalMirror();
|
||||
m_imageTransformState.verticalMirror = settings.imageVerticalMirror();
|
||||
m_imageTransformState.rotation = settings.imageRotation();
|
||||
}
|
||||
|
||||
void Mapcavas::applyImageTransform()
|
||||
{
|
||||
if (m_GraphicsPixmapItemHandle == nullptr)
|
||||
return;
|
||||
|
||||
const double sx = m_imageTransformState.horizontalMirror ? -1.0 : 1.0;
|
||||
const double sy = m_imageTransformState.verticalMirror ? -1.0 : 1.0;
|
||||
const QPointF center = m_GraphicsPixmapItemHandle->boundingRect().center();
|
||||
|
||||
QTransform transform_all;
|
||||
transform_all.translate(center.x(), center.y());// 围绕图片中心变换
|
||||
transform_all.scale(sx, sy);
|
||||
transform_all.rotate(m_imageTransformState.rotation);
|
||||
transform_all.translate(-center.x(), -center.y());
|
||||
|
||||
// setTransform 是替换而非叠加,因此可对已显示的图像重复调用
|
||||
m_GraphicsPixmapItemHandle->setTransform(transform_all);
|
||||
|
||||
//QPointF itemOrigin(0, 0);
|
||||
//QPointF sceneOrigin = m_GraphicsPixmapItemHandle->mapToScene(itemOrigin);
|
||||
//QPointF sceneOrigin2 = m_GraphicsPixmapItemHandle->scenePos();
|
||||
|
||||
// 变换后重新定位十字叉,使其始终跟随同一个图像像素
|
||||
repositionCrosshair();
|
||||
}
|
||||
|
||||
void Mapcavas::repositionCrosshair()
|
||||
{
|
||||
if (!m_hLine || !m_vLine || !m_GraphicsPixmapItemHandle)
|
||||
return;
|
||||
|
||||
const QPointF scenePt = m_GraphicsPixmapItemHandle->mapToScene(m_crosshairItemPos);
|
||||
m_hLine->setPos(scenePt);
|
||||
m_vLine->setPos(scenePt);
|
||||
}
|
||||
|
||||
void Mapcavas::refreshImageTransform()
|
||||
{
|
||||
if (!HasImage())
|
||||
return;
|
||||
|
||||
applyImageTransform();
|
||||
|
||||
if (m_displayMode == AppSettings::HyperimgDisplayMode::Full)
|
||||
{
|
||||
ensureSceneVisible();
|
||||
}
|
||||
else if (m_displayMode == AppSettings::HyperimgDisplayMode::Waterfall)
|
||||
{
|
||||
ensureWaterfallVisible();
|
||||
}
|
||||
}
|
||||
|
||||
void Mapcavas::rotateImage90()
|
||||
{
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
settings.setImageRotation(settings.imageRotation() + 90);
|
||||
loadSettings();
|
||||
refreshImageTransform();
|
||||
}
|
||||
|
||||
void Mapcavas::toggleHorizontalMirror()
|
||||
{
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
settings.setImageHorizontalMirror(!settings.imageHorizontalMirror());
|
||||
loadSettings();
|
||||
refreshImageTransform();
|
||||
}
|
||||
|
||||
void Mapcavas::toggleVerticalMirror()
|
||||
{
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
settings.setImageVerticalMirror(!settings.imageVerticalMirror());
|
||||
loadSettings();
|
||||
refreshImageTransform();
|
||||
}
|
||||
|
||||
void Mapcavas::updateDisplayMode()
|
||||
{
|
||||
m_displayMode = AppSettings::instance().hyperimgDisplayMode();
|
||||
}
|
||||
|
||||
void Mapcavas::DisplayFrameNumber(int frameNumber)
|
||||
{
|
||||
m_framNumberLabel->setText(QString::number(frameNumber));
|
||||
@ -71,7 +167,13 @@ void Mapcavas::SetImage(QPixmap *image)
|
||||
{
|
||||
m_GraphicsPixmapItemHandle->setPixmap(*image);
|
||||
}
|
||||
ensureSceneVisible();
|
||||
|
||||
refreshImageTransform();
|
||||
}
|
||||
|
||||
QGraphicsPixmapItem* Mapcavas::pixmapItemHandle()
|
||||
{
|
||||
return m_GraphicsPixmapItemHandle;
|
||||
}
|
||||
|
||||
void Mapcavas::ensureSceneVisible()
|
||||
@ -91,6 +193,92 @@ void Mapcavas::ensureSceneVisible()
|
||||
centerOn(scene_rect.center());
|
||||
}
|
||||
|
||||
void Mapcavas::ensureWaterfallVisible()
|
||||
{
|
||||
if (!HasImage())
|
||||
return;
|
||||
|
||||
resetTransform();
|
||||
|
||||
QGraphicsPixmapItem* item = m_GraphicsPixmapItemHandle;
|
||||
const QRectF item_rect = item->boundingRect();
|
||||
if (item_rect.isEmpty())
|
||||
return;
|
||||
|
||||
// 图像已经应用了 m_imageTransformState 的镜像/旋转,这里以场景中的实际位置为准
|
||||
const QRectF scene_rect = item->sceneBoundingRect();
|
||||
|
||||
qreal view_width = viewport()->rect().width();
|
||||
qreal view_height = viewport()->rect().height();
|
||||
if (view_width <= 0.0 || view_height <= 0.0)
|
||||
return;
|
||||
if (scene_rect.width() <= 0.0 || scene_rect.height() <= 0.0)
|
||||
return;
|
||||
|
||||
// 图像坐标中:x 为扫描线空间轴(固定),y 为采集帧数(不断增长),最新一帧位于 y 最大处。
|
||||
// 经过镜像/旋转后,增长轴可能竖直(0°/180°)或水平(90°/270°)。
|
||||
const QPointF growth_dir = item->mapToScene(QPointF(0.0, 1.0))
|
||||
- item->mapToScene(QPointF(0.0, 0.0));
|
||||
const bool growth_vertical = qAbs(growth_dir.y()) >= qAbs(growth_dir.x());
|
||||
|
||||
// 最新一帧(图像底边中心)在场景中的位置,用于判断应该贴哪条边
|
||||
const QPointF newest_scene = item->mapToScene(
|
||||
QPointF(item_rect.width() / 2.0, item_rect.height()));
|
||||
|
||||
if (growth_vertical)
|
||||
{
|
||||
// 竖直瀑布:空间轴横向铺满视图宽度,最新一帧固定在上/下边缘
|
||||
const double x_scale = view_width / scene_rect.width();
|
||||
scale(x_scale, x_scale);
|
||||
m_scale *= x_scale;
|
||||
|
||||
// 计算缩放后的图片可见高度
|
||||
qreal scaled_height = scene_rect.height() * x_scale;
|
||||
|
||||
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;
|
||||
if (newest_scene.y() >= scene_rect.center().y())
|
||||
center_y = scene_rect.bottom() - half_view_height; // 最新帧在下方,贴底
|
||||
else
|
||||
center_y = scene_rect.top() + half_view_height; // 最新帧在上方,贴顶
|
||||
}
|
||||
|
||||
centerOn(scene_rect.center().x(), center_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 水平瀑布:空间轴竖向铺满视图高度,最新一帧固定在左/右边缘
|
||||
const double y_scale = view_height / scene_rect.height();
|
||||
scale(y_scale, y_scale);
|
||||
m_scale *= y_scale;
|
||||
|
||||
// 计算缩放后的图片可见宽度
|
||||
qreal scaled_width = scene_rect.width() * y_scale;
|
||||
|
||||
qreal center_x;
|
||||
if (scaled_width <= view_width)
|
||||
{
|
||||
center_x = scene_rect.center().x();
|
||||
}
|
||||
else
|
||||
{
|
||||
qreal half_view_width = view_width / 2.0 / y_scale;
|
||||
if (newest_scene.x() >= scene_rect.center().x())
|
||||
center_x = scene_rect.right() - half_view_width; // 最新帧在右侧,贴右
|
||||
else
|
||||
center_x = scene_rect.left() + half_view_width; // 最新帧在左侧,贴左
|
||||
}
|
||||
|
||||
centerOn(center_x, scene_rect.center().y());
|
||||
}
|
||||
}
|
||||
|
||||
bool Mapcavas::HasImage()
|
||||
{
|
||||
if (m_GraphicsPixmapItemHandle == nullptr)
|
||||
@ -111,21 +299,32 @@ void Mapcavas::updateCrosshair(double sceneX, double sceneY)
|
||||
if (!m_hLine)
|
||||
{
|
||||
m_hLine = m_qtGraphicsScene->addLine(0, 0, 0, 0, pen);
|
||||
m_hLine->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
|
||||
m_hLine->setZValue(1e9);
|
||||
}
|
||||
if (!m_vLine)
|
||||
{
|
||||
m_vLine = m_qtGraphicsScene->addLine(0, 0, 0, 0, pen);
|
||||
m_vLine->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
|
||||
m_vLine->setZValue(1e9);
|
||||
}
|
||||
|
||||
m_hLine->setPen(pen);
|
||||
m_vLine->setPen(pen);
|
||||
|
||||
m_hLine->setLine(sceneX - m_CrosshairHalfLen, sceneY,
|
||||
sceneX + m_CrosshairHalfLen, sceneY);
|
||||
m_vLine->setLine(sceneX, sceneY - m_CrosshairHalfLen,
|
||||
sceneX, sceneY + m_CrosshairHalfLen);
|
||||
// 设置 ItemIgnoresTransformations 后,图元的原点依旧按场景坐标定位,
|
||||
// 但局部坐标不再受视图缩放影响(1 单位 = 1 屏幕像素)。
|
||||
// 这里把锚点记录在图像(图元)坐标系中,再据此定位十字叉:
|
||||
// 这样点击某个像素后,无论滚轮缩放还是镜像/旋转图像,十字叉都锚定在该像素上。
|
||||
const QPointF scenePt(sceneX + 0.5, sceneY + 0.5);
|
||||
m_crosshairItemPos = m_GraphicsPixmapItemHandle->mapFromScene(scenePt);
|
||||
|
||||
repositionCrosshair();
|
||||
|
||||
m_hLine->setLine(-m_CrosshairHalfLen, 0.0,
|
||||
m_CrosshairHalfLen, 0.0);
|
||||
m_vLine->setLine(0.0, -m_CrosshairHalfLen,
|
||||
0.0, m_CrosshairHalfLen);
|
||||
}
|
||||
|
||||
void Mapcavas::removeCrosshair()
|
||||
@ -144,6 +343,7 @@ void Mapcavas::removeCrosshair()
|
||||
delete m_vLine;
|
||||
m_vLine = nullptr;
|
||||
}
|
||||
m_crosshairItemPos = QPointF();
|
||||
}
|
||||
|
||||
|
||||
@ -323,3 +523,91 @@ MapTool* Mapcavas::mapTool() const
|
||||
{
|
||||
return m_mapTool;
|
||||
}
|
||||
|
||||
void Mapcavas::addSceneCoordinateSystem()
|
||||
{
|
||||
const double length = 200.0;
|
||||
const double arrowSize = 10.0;
|
||||
|
||||
// 坐标系作为参考叠加层,需要始终绘制在图像和其他图元之上;
|
||||
// 十字叉使用更大的 Z 值(1e9),因此这里取一个略小的值。
|
||||
const double zOrder = 1e8;
|
||||
|
||||
// X 轴
|
||||
QPen xPen(Qt::red);
|
||||
xPen.setWidth(2);
|
||||
|
||||
QGraphicsLineItem* xAxis = m_qtGraphicsScene->addLine(
|
||||
0, 0,
|
||||
length, 0,
|
||||
xPen
|
||||
);
|
||||
xAxis->setZValue(zOrder);
|
||||
|
||||
// X 箭头
|
||||
QPolygonF xArrow;
|
||||
xArrow << QPointF(length, 0)
|
||||
<< QPointF(length - arrowSize, -arrowSize / 2)
|
||||
<< QPointF(length - arrowSize, arrowSize / 2);
|
||||
|
||||
QGraphicsPolygonItem* xArrowItem = m_qtGraphicsScene->addPolygon(
|
||||
xArrow,
|
||||
xPen,
|
||||
QBrush(Qt::red)
|
||||
);
|
||||
xArrowItem->setZValue(zOrder);
|
||||
|
||||
|
||||
// Y 轴
|
||||
QPen yPen(Qt::green);
|
||||
yPen.setWidth(2);
|
||||
|
||||
QGraphicsLineItem* yAxis = m_qtGraphicsScene->addLine(
|
||||
0, 0,
|
||||
0, length,
|
||||
yPen
|
||||
);
|
||||
yAxis->setZValue(zOrder);
|
||||
|
||||
// Y 箭头
|
||||
QPolygonF yArrow;
|
||||
yArrow << QPointF(0, length)
|
||||
<< QPointF(-arrowSize / 2, length - arrowSize)
|
||||
<< QPointF(arrowSize / 2, length - arrowSize);
|
||||
|
||||
QGraphicsPolygonItem* yArrowItem = m_qtGraphicsScene->addPolygon(
|
||||
yArrow,
|
||||
yPen,
|
||||
QBrush(Qt::green)
|
||||
);
|
||||
yArrowItem->setZValue(zOrder);
|
||||
|
||||
|
||||
// 原点
|
||||
QGraphicsEllipseItem* originItem = m_qtGraphicsScene->addEllipse(
|
||||
-4, -4,
|
||||
8, 8,
|
||||
QPen(Qt::blue),
|
||||
QBrush(Qt::blue)
|
||||
);
|
||||
originItem->setZValue(zOrder);
|
||||
|
||||
|
||||
// X 标签
|
||||
QGraphicsTextItem* xText = m_qtGraphicsScene->addText("X");
|
||||
xText->setDefaultTextColor(Qt::red);
|
||||
xText->setPos(length + 5, -15);
|
||||
xText->setZValue(zOrder);
|
||||
|
||||
// Y 标签
|
||||
QGraphicsTextItem* yText = m_qtGraphicsScene->addText("Y");
|
||||
yText->setDefaultTextColor(Qt::green);
|
||||
yText->setPos(5, length + 5);
|
||||
yText->setZValue(zOrder);
|
||||
|
||||
// 原点标签
|
||||
QGraphicsTextItem* originText = m_qtGraphicsScene->addText("(0, 0)");
|
||||
originText->setDefaultTextColor(Qt::blue);
|
||||
originText->setPos(5, 5);
|
||||
originText->setZValue(zOrder);
|
||||
}
|
||||
|
||||
@ -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();
|
||||
@ -59,6 +61,16 @@ public:
|
||||
void unsetMapTool(MapTool* tool);
|
||||
MapTool* mapTool() const;
|
||||
|
||||
QGraphicsPixmapItem* pixmapItemHandle();
|
||||
|
||||
// 图像显示变换(左右镜像/上下镜像/旋转),状态保存在 AppSettings 中全局生效
|
||||
void rotateImage90();
|
||||
void toggleHorizontalMirror();
|
||||
void toggleVerticalMirror();
|
||||
|
||||
// 把当前的镜像/旋转重新应用到已经显示的图像,并按显示模式重新适配视图
|
||||
void refreshImageTransform();
|
||||
|
||||
protected:
|
||||
QGraphicsScene *m_qtGraphicsScene;
|
||||
private:
|
||||
@ -77,7 +89,23 @@ private:
|
||||
double m_CrosshairHalfLen = 10.0;
|
||||
QGraphicsLineItem* m_hLine = nullptr; // horizontal line
|
||||
QGraphicsLineItem* m_vLine = nullptr; // vertical line
|
||||
QPointF m_crosshairItemPos; // 十字叉锚点,保存在图像(图元)坐标系
|
||||
|
||||
AppSettings::HyperimgDisplayMode m_displayMode;
|
||||
|
||||
struct ImageTransformState
|
||||
{
|
||||
bool horizontalMirror = true;
|
||||
bool verticalMirror = true;
|
||||
int rotation = 90*3; // 0、90、180、270
|
||||
};
|
||||
ImageTransformState m_imageTransformState;
|
||||
|
||||
void applyImageTransform();
|
||||
void repositionCrosshair();
|
||||
void loadSettings();
|
||||
|
||||
void addSceneCoordinateSystem();
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
//
|
||||
// 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)
|
||||
@ -12,7 +14,7 @@ JinspFiberImager::JinspFiberImager(bool bIsUSBMode, std::string ucPortNumber, st
|
||||
|
||||
m_record = false;
|
||||
|
||||
m_captureIntervalMilliseconds = 5 * 1000;
|
||||
m_captureIntervalMilliseconds = 1 * 1000;
|
||||
|
||||
qRegisterMetaType<DeviceAttribute>("DeviceAttribute");
|
||||
qRegisterMetaType<DataFrame>("DataFrame");
|
||||
@ -131,7 +133,7 @@ void JinspFiberImager::recordDark(QString path)
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
void JinspFiberImager::recordTarget(int recordTimes, QString path)
|
||||
void JinspFiberImager::recordTarget2csv(int recordTimes, QString path)
|
||||
{
|
||||
//获取设备信息
|
||||
DeviceAttribute attribute;
|
||||
@ -171,7 +173,7 @@ void JinspFiberImager::recordTarget(int recordTimes, QString path)
|
||||
//输出到csv
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral_dn.csv";
|
||||
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++)
|
||||
@ -188,73 +190,110 @@ void JinspFiberImager::recordTarget(int recordTimes, QString path)
|
||||
|
||||
void JinspFiberImager::autoExpose()
|
||||
{
|
||||
// float fPredictedExposureTime;
|
||||
// m_FiberSpectrometer->PerformAutoExposure(0.6,0.9,fPredictedExposureTime);
|
||||
int allowMaxExposure = 6000;
|
||||
|
||||
//tc
|
||||
DeviceAttribute attribute;
|
||||
getDeviceAttribute(attribute);
|
||||
|
||||
int iterations = 0;//记录自动曝光已经迭代的次数
|
||||
int maxIterations = 10;//允许最大的迭代次数
|
||||
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 thresholdValue = m_MaxValueOfFiberSpectrometer * 0.8;//最佳线性区间为80%
|
||||
ZZ_U16 range = 10000;
|
||||
ZZ_U32 thresholdLow = targetMin;
|
||||
ZZ_U32 thresholdHigh = targetMax;
|
||||
|
||||
//设置初始曝光时间
|
||||
int exposureTimeInMS = 200;
|
||||
setExposureTime(exposureTimeInMS);
|
||||
// 自适应初始曝光时间:先快速探测亮度水平
|
||||
int exposureTime = 10;
|
||||
setExposureTime(exposureTime);
|
||||
DataFrame dataFrame;
|
||||
singleShot(dataFrame);
|
||||
ZZ_S32 maxValue = GetMaxValue(dataFrame.lData, attribute.iPixels);
|
||||
|
||||
// int exposureTime;
|
||||
// m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
|
||||
emit sendExposureTimeSignal(exposureTimeInMS);
|
||||
|
||||
DataFrame integratingSphereData_tmp;
|
||||
ZZ_S32 maxValue;
|
||||
while (true)
|
||||
// 探测阶段:快速逼近目标区间
|
||||
if (maxValue > 0)
|
||||
{
|
||||
if (iterations > maxIterations)//是否超过允许的最大迭代次数
|
||||
// 预测达到目标区间所需的曝光时间
|
||||
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;
|
||||
}
|
||||
|
||||
singleShot(integratingSphereData_tmp);
|
||||
maxValue = GetMaxValue(integratingSphereData_tmp.lData, attribute.iPixels);
|
||||
// 获取当前曝光时间
|
||||
m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
|
||||
if (maxValue < thresholdValue && maxValue < (thresholdValue - range))//曝光时间过小
|
||||
if (maxValue < thresholdLow)
|
||||
{
|
||||
double scale = 1 + ((double)(thresholdValue - maxValue) / (double)thresholdValue);
|
||||
|
||||
int exposureTime;
|
||||
m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
m_FiberSpectrometer->SetExposureTime(exposureTime * scale);
|
||||
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
std::cout << "自动曝光-----------" << "最大值为" << maxValue << std::endl;
|
||||
}
|
||||
else if (maxValue > thresholdValue)//曝光时间过大
|
||||
// 曝光不足,增大曝光时间 - 使用二分策略
|
||||
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
|
||||
{
|
||||
double scale = 1 - ((double)(maxValue - thresholdValue) / (double)thresholdValue);
|
||||
|
||||
int exposureTime;
|
||||
m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
m_FiberSpectrometer->SetExposureTime(exposureTime * scale);
|
||||
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
std::cout << "自动曝光++++++++++++" << "最大值为" << maxValue << std::endl;
|
||||
}
|
||||
else//找到最佳曝光时间,跳出while循环
|
||||
{
|
||||
break;
|
||||
// 曝光过度,减小曝光时间 - 使用二分策略
|
||||
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++;
|
||||
}
|
||||
|
||||
int a = 2;
|
||||
if (iterations >= maxIterations) {
|
||||
std::cout << "自动曝光达到最大迭代次数,最终曝光时间:"
|
||||
<< exposureTime << "ms, 最大值:" << maxValue << std::endl;
|
||||
}
|
||||
|
||||
m_iExposureTime = exposureTime;
|
||||
}
|
||||
|
||||
ZZ_S32 JinspFiberImager::GetMaxValue(ZZ_S32 * dark, int number)
|
||||
@ -280,7 +319,7 @@ void JinspFiberImager::setCaptureInterval(int captureIntervalSeconds)
|
||||
m_captureIntervalMilliseconds = captureIntervalSeconds * 1000;
|
||||
}
|
||||
|
||||
void JinspFiberImager::OpenFiberImagerAndRecord()
|
||||
void JinspFiberImager::OpenFiberImagerAndRecord(QString filePath)
|
||||
{
|
||||
//连接光谱仪
|
||||
QString SN;
|
||||
@ -290,16 +329,30 @@ void JinspFiberImager::OpenFiberImagerAndRecord()
|
||||
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)
|
||||
{
|
||||
recordTarget(1, AppSettings::instance().FiberImagerDataFolder());
|
||||
singleShot(data);
|
||||
qfData.write((char*)&data, sizeof(DataFrame));
|
||||
qfData.flush();
|
||||
|
||||
QThread::msleep(m_captureIntervalMilliseconds);
|
||||
}
|
||||
qfData.close();
|
||||
|
||||
std::cout << "close.........." << std::endl;
|
||||
m_FiberSpectrometer->Close();
|
||||
|
||||
@ -53,16 +53,23 @@ private:
|
||||
bool m_record;
|
||||
int m_captureIntervalMilliseconds;
|
||||
|
||||
int m_iExposureTime;
|
||||
|
||||
QString m_posInfo;
|
||||
|
||||
// ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
|
||||
public slots:
|
||||
void recordDark(QString path);
|
||||
void recordTarget(int recordTimes, QString path);
|
||||
void recordTarget2csv(int recordTimes, QString path);
|
||||
void autoExpose();
|
||||
|
||||
void OpenFiberImagerAndRecord();
|
||||
void OpenFiberImagerAndRecord(QString filePath);
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
void spectalCaptured(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void exposureCompleteSignal(int exposureTime);
|
||||
void startExposureSignal();
|
||||
};
|
||||
|
||||
@ -37,21 +37,35 @@ void MapToolSpectral::canvasMousePressEvent(QMouseEvent* e)
|
||||
if (!canvas())
|
||||
return;
|
||||
|
||||
const QPointF scenePt = canvas()->mapToScene(e->pos());
|
||||
const int x = static_cast<int>(std::floor(scenePt.x()));
|
||||
const int y = static_cast<int>(std::floor(scenePt.y()));
|
||||
//获取图像元素
|
||||
QGraphicsPixmapItem* item = canvas()->pixmapItemHandle();
|
||||
QPointF scenePos = item->pos();
|
||||
QPointF scenePos2 = item->scenePos();
|
||||
|
||||
if (item==nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QPointF scenePt = canvas()->mapToScene(e->pos());
|
||||
int x_scenePt = static_cast<int>(std::floor(scenePt.x()));
|
||||
int y_scenePt = static_cast<int>(std::floor(scenePt.y()));
|
||||
|
||||
QPointF itemPt = item->mapFromScene(scenePt);
|
||||
int x_itemPt = static_cast<int>(std::floor(itemPt.x()));
|
||||
int y_itemPt = static_cast<int>(std::floor(itemPt.y()));
|
||||
|
||||
auto* imageLayer = canvas()->imageLayer();
|
||||
RasterLayer* rl = imageLayer ? imageLayer->layer() : nullptr;
|
||||
if (rl && rl->isValidPixel(x, y))
|
||||
if (rl && rl->isValidPixel(x_itemPt, y_itemPt))
|
||||
{
|
||||
canvas()->updateCrosshair(x + 0.5, y + 0.5);
|
||||
canvas()->updateCrosshair(x_scenePt + 0.5, y_scenePt + 0.5);
|
||||
|
||||
QVector<double> wavelengths;
|
||||
QVector<double> spectrum;
|
||||
if (rl->readPixelSpectrum(x, y, wavelengths, spectrum))
|
||||
if (rl->readPixelSpectrum(x_itemPt, y_itemPt, wavelengths, spectrum))
|
||||
{
|
||||
emit spectralClicked(x, y, wavelengths, spectrum);
|
||||
emit spectralClicked(x_itemPt, y_itemPt, wavelengths, spectrum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,22 @@ 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
|
||||
connect(ui.scanSpeed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setScanSpeed(ui.scanSpeed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.return_speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setReturnSpeed(ui.return_speed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.manualMovementSpeed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setManualMovementSpeed(ui.manualMovementSpeed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.reverseMove_radioButton, &QRadioButton::toggled, [this](bool checked) {
|
||||
AppSettings::instance().setIsReverseMove(checked);
|
||||
});
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
OneMotorControl::~OneMotorControl()
|
||||
@ -24,27 +40,49 @@ OneMotorControl::~OneMotorControl()
|
||||
m_motorThread.wait();
|
||||
}
|
||||
|
||||
void OneMotorControl::loadSettings()
|
||||
{
|
||||
ui.scanSpeed_lineEdit->setText(QString::number(AppSettings::instance().scanSpeed()));
|
||||
ui.return_speed_lineEdit->setText(QString::number(AppSettings::instance().returnSpeed()));
|
||||
ui.manualMovementSpeed_lineEdit->setText(QString::number(AppSettings::instance().manualMovementSpeed()));
|
||||
|
||||
ui.reverseMove_radioButton->setChecked(AppSettings::instance().isReverseMove());
|
||||
}
|
||||
|
||||
void OneMotorControl::onConnectMotor()
|
||||
{
|
||||
connectMotor(true);
|
||||
}
|
||||
|
||||
void OneMotorControl::setScanSpeed(double speed)
|
||||
{
|
||||
ui.scanSpeed_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;
|
||||
}
|
||||
|
||||
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>)));
|
||||
disconnect(m_multiAxisController, &IrisMultiMotorController::broadcastLocationSignal, this, &OneMotorControl::display_x_loc);
|
||||
disconnect(this, &OneMotorControl::moveSignal, m_multiAxisController, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
disconnect(this, qOverload<int, double, double, int>(&OneMotorControl::move2LocSignal), m_multiAxisController, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
disconnect(this, &OneMotorControl::stopSignal, m_multiAxisController, &IrisMultiMotorController::stop);
|
||||
disconnect(this, &OneMotorControl::zeroStartSignal, m_multiAxisController, &IrisMultiMotorController::zeroStart);
|
||||
disconnect(this, &OneMotorControl::rangeMeasurement, m_multiAxisController, &IrisMultiMotorController::rangeMeasurement);
|
||||
disconnect(this, &OneMotorControl::testConnectivitySignal, m_multiAxisController, &IrisMultiMotorController::testConnectivity);
|
||||
disconnect(m_multiAxisController, &IrisMultiMotorController::broadcastConnectivity, this, &OneMotorControl::display_motors_connectivity);
|
||||
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
@ -68,20 +106,20 @@ void OneMotorControl::onConnectMotor()
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(&m_motorThread, &QThread::finished, m_multiAxisController, &QObject::deleteLater);
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
connect(m_multiAxisController, &IrisMultiMotorController::broadcastLocationSignal, this, &OneMotorControl::display_x_loc);
|
||||
|
||||
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, &OneMotorControl::moveSignal, m_multiAxisController, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
connect(this, qOverload<int, double, double, int>(&OneMotorControl::move2LocSignal), m_multiAxisController, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, &OneMotorControl::stopSignal, m_multiAxisController, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, &OneMotorControl::zeroStartSignal, m_multiAxisController, &IrisMultiMotorController::zeroStart);
|
||||
|
||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, &OneMotorControl::rangeMeasurement, m_multiAxisController, &IrisMultiMotorController::rangeMeasurement);
|
||||
|
||||
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>)));
|
||||
connect(this, &OneMotorControl::testConnectivitySignal, m_multiAxisController, &IrisMultiMotorController::testConnectivity);
|
||||
connect(m_multiAxisController, &IrisMultiMotorController::broadcastConnectivity, this, &OneMotorControl::display_motors_connectivity);
|
||||
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
@ -90,7 +128,7 @@ void OneMotorControl::onConnectMotor()
|
||||
void OneMotorControl::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
this->ui.realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
this->ui.realTimeLoc_label->setText(QString::number(tmp));
|
||||
|
||||
emit broadcastLocationSignal(loc);
|
||||
}
|
||||
@ -140,13 +178,13 @@ void OneMotorControl::zeroStart()
|
||||
|
||||
void OneMotorControl::onx_rangeMeasurement()
|
||||
{
|
||||
double s0 = ui.speed_lineEdit->text().toDouble();
|
||||
double s0 = ui.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(0, s0, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl::onxMove2Loc()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
double s = ui.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(0, l, s, 1000);
|
||||
@ -154,16 +192,16 @@ void OneMotorControl::onxMove2Loc()
|
||||
|
||||
void OneMotorControl::onxMotorRight()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
double s = ui.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, false, s, 1000);
|
||||
emit moveSignal(0, abs(s), 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl::onxMotorLeft()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
double s = ui.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, true, s, 1000);
|
||||
emit moveSignal(0, abs(s)*-1, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl::onxMotorStop()
|
||||
@ -178,7 +216,11 @@ void OneMotorControl::setImager(ImagerOperationBase* imager)
|
||||
|
||||
void OneMotorControl::record_dark()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
double s = ui.scanSpeed_lineEdit->text().toDouble();
|
||||
if (ui.reverseMove_radioButton->isChecked())
|
||||
{
|
||||
s = s * -1;
|
||||
}
|
||||
|
||||
if (m_darkCaptureCoordinator == nullptr)
|
||||
{
|
||||
@ -190,7 +232,11 @@ void OneMotorControl::record_dark()
|
||||
|
||||
void OneMotorControl::record_white()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
double s = ui.scanSpeed_lineEdit->text().toDouble();
|
||||
if (ui.reverseMove_radioButton->isChecked())
|
||||
{
|
||||
s = s * -1;
|
||||
}
|
||||
|
||||
if (m_whiteCaptureCoordinator == nullptr)
|
||||
{
|
||||
@ -202,15 +248,31 @@ 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();
|
||||
|
||||
double s = ui.scanSpeed_lineEdit->text().toDouble();
|
||||
if (ui.reverseMove_radioButton->isChecked())
|
||||
{
|
||||
s = s * -1;
|
||||
}
|
||||
tmp.speedRecord = s;
|
||||
tmp.speedBack = ui.return_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit start(tmp);
|
||||
@ -221,13 +283,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.manualMovementSpeed_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 +326,285 @@ 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
|
||||
connect(ui.scanSpeed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setScanSpeed(ui.scanSpeed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.return_speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setReturnSpeed(ui.return_speed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.manualMovementSpeed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setManualMovementSpeed(ui.manualMovementSpeed_lineEdit->text().toDouble());
|
||||
});
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
OneMotorControl_LiftingPlatform::~OneMotorControl_LiftingPlatform()
|
||||
{
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::loadSettings()
|
||||
{
|
||||
ui.scanSpeed_lineEdit->setText(QString::number(AppSettings::instance().scanSpeed()));
|
||||
ui.return_speed_lineEdit->setText(QString::number(AppSettings::instance().returnSpeed()));
|
||||
ui.manualMovementSpeed_lineEdit->setText(QString::number(AppSettings::instance().manualMovementSpeed()));
|
||||
}
|
||||
|
||||
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, &IrisMultiMotorController::broadcastLocationSignal, this, &OneMotorControl_LiftingPlatform::display_x_loc);
|
||||
disconnect(this, &OneMotorControl_LiftingPlatform::moveSignal, m_multiAxisController, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
disconnect(this, qOverload<int, double, double, int>(&OneMotorControl_LiftingPlatform::move2LocSignal), m_multiAxisController, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
disconnect(this, &OneMotorControl_LiftingPlatform::stopSignal, m_multiAxisController, &IrisMultiMotorController::stop);
|
||||
disconnect(this, &OneMotorControl_LiftingPlatform::zeroStartSignal, m_multiAxisController, &IrisMultiMotorController::zeroStart);
|
||||
disconnect(this, &OneMotorControl_LiftingPlatform::rangeMeasurement, m_multiAxisController, &IrisMultiMotorController::rangeMeasurement);
|
||||
disconnect(this, &OneMotorControl_LiftingPlatform::testConnectivitySignal, m_multiAxisController, &IrisMultiMotorController::testConnectivity);
|
||||
disconnect(m_multiAxisController, &IrisMultiMotorController::broadcastConnectivity, this, &OneMotorControl_LiftingPlatform::display_motors_connectivity);
|
||||
|
||||
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, &QThread::finished, m_multiAxisController, &QObject::deleteLater);
|
||||
|
||||
connect(m_multiAxisController, &IrisMultiMotorController::broadcastLocationSignal, this, &OneMotorControl_LiftingPlatform::display_x_loc);
|
||||
|
||||
connect(this, &OneMotorControl_LiftingPlatform::moveSignal, m_multiAxisController, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
connect(this, qOverload<int, double, double, int>(&OneMotorControl_LiftingPlatform::move2LocSignal), m_multiAxisController, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, &OneMotorControl_LiftingPlatform::stopSignal, m_multiAxisController, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(this, &OneMotorControl_LiftingPlatform::zeroStartSignal, m_multiAxisController, &IrisMultiMotorController::zeroStart);
|
||||
|
||||
connect(this, &OneMotorControl_LiftingPlatform::rangeMeasurement, m_multiAxisController, &IrisMultiMotorController::rangeMeasurement);
|
||||
|
||||
connect(this, &OneMotorControl_LiftingPlatform::testConnectivitySignal, m_multiAxisController, &IrisMultiMotorController::testConnectivity);
|
||||
connect(m_multiAxisController, &IrisMultiMotorController::broadcastConnectivity, this, &OneMotorControl_LiftingPlatform::display_motors_connectivity);
|
||||
|
||||
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_label->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.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(0, s0, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onxMove2Loc()
|
||||
{
|
||||
double s = ui.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(0, l, s, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onxMotorRight()
|
||||
{
|
||||
double s = ui.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, abs(s), 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl_LiftingPlatform::onxMotorLeft()
|
||||
{
|
||||
double s = ui.manualMovementSpeed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, abs(s)*-1, 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.manualMovementSpeed_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,10 +50,11 @@ 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);
|
||||
void moveSignal(int, double, int);
|
||||
void move2LocSignal(int, double, double, int);
|
||||
void move2LocSignal(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopSignal(int);
|
||||
@ -56,20 +67,92 @@ 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;
|
||||
|
||||
void loadSettings();
|
||||
};
|
||||
|
||||
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, 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;
|
||||
void loadSettings();
|
||||
};
|
||||
|
||||
@ -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())
|
||||
@ -233,7 +306,7 @@ void TwoMotorControl::run()
|
||||
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
|
||||
|
||||
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
|
||||
connect(this, SIGNAL(stopSignal_CaptureCoordinator()), m_coordinator, SLOT(stop()));
|
||||
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
|
||||
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int)));
|
||||
@ -279,7 +352,7 @@ void TwoMotorControl::stop_record()
|
||||
|
||||
void TwoMotorControl::stop()
|
||||
{
|
||||
emit stopSignal();
|
||||
emit stopSignal_CaptureCoordinator();
|
||||
}
|
||||
|
||||
TwoMotorControl::~TwoMotorControl()
|
||||
@ -312,14 +385,14 @@ void TwoMotorControl::connectMotor(bool isNotification)
|
||||
|
||||
if (m_multiAxisController != nullptr)
|
||||
{
|
||||
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(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>)));
|
||||
disconnect(m_multiAxisController, &IrisMultiMotorController::broadcastLocationSignal, this, &TwoMotorControl::displayRealTimeLoc);
|
||||
disconnect(this, &TwoMotorControl::moveSignal, m_multiAxisController, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
disconnect(this, qOverload<int, double, double, int>(&TwoMotorControl::move2LocSignal), m_multiAxisController, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
disconnect(this, &TwoMotorControl::stopSignal, m_multiAxisController, &IrisMultiMotorController::stop);
|
||||
disconnect(this, &TwoMotorControl::zeroStartSignal, m_multiAxisController, &IrisMultiMotorController::zeroStart);
|
||||
disconnect(this, &TwoMotorControl::rangeMeasurement, m_multiAxisController, &IrisMultiMotorController::rangeMeasurement);
|
||||
disconnect(this, &TwoMotorControl::testConnectivitySignal, m_multiAxisController, &IrisMultiMotorController::testConnectivity);
|
||||
disconnect(m_multiAxisController, &IrisMultiMotorController::broadcastConnectivity, this, &TwoMotorControl::display_motors_connectivity);
|
||||
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
@ -343,20 +416,20 @@ void TwoMotorControl::connectMotor(bool isNotification)
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(&m_motorThread, &QThread::finished, m_multiAxisController, &QObject::deleteLater);
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
|
||||
connect(m_multiAxisController, &IrisMultiMotorController::broadcastLocationSignal, this, &TwoMotorControl::displayRealTimeLoc);
|
||||
|
||||
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, &TwoMotorControl::moveSignal, m_multiAxisController, qOverload<int, double, int>(&IrisMultiMotorController::move));
|
||||
connect(this, qOverload<int, double, double, int>(&TwoMotorControl::move2LocSignal), m_multiAxisController, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
connect(this, &TwoMotorControl::stopSignal, m_multiAxisController, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, &TwoMotorControl::zeroStartSignal, m_multiAxisController, &IrisMultiMotorController::zeroStart);
|
||||
|
||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, &TwoMotorControl::rangeMeasurement, m_multiAxisController, &IrisMultiMotorController::rangeMeasurement);
|
||||
|
||||
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>)));
|
||||
connect(this, &TwoMotorControl::testConnectivitySignal, m_multiAxisController, &IrisMultiMotorController::testConnectivity);
|
||||
connect(m_multiAxisController, &IrisMultiMotorController::broadcastConnectivity, this, &TwoMotorControl::display_motors_connectivity);
|
||||
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
@ -470,14 +543,14 @@ void TwoMotorControl::onxMotorRight()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, false, s, 1000);
|
||||
emit moveSignal(0, abs(s), 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorLeft()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, true, s, 1000);
|
||||
emit moveSignal(0, abs(s)*-1, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorStop()
|
||||
@ -489,14 +562,14 @@ void TwoMotorControl::onyMotorforward()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(1, false, s, 1000);
|
||||
emit moveSignal(1, abs(s), 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorbackward()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(1, true, s, 1000);
|
||||
emit moveSignal(1, abs(s)*-1, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorStop()
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
|
||||
#include "PathLine.h"
|
||||
|
||||
#include "DepthValueLogger.h"
|
||||
|
||||
#include "focusWindow.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
class TwoMotorControl : public QDialog, public MotorWindowBase
|
||||
@ -82,12 +86,17 @@ 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();
|
||||
|
||||
signals:
|
||||
void moveSignal(int, bool, double, int);
|
||||
void moveSignal(int, double, int);
|
||||
void move2LocSignal(int, double, double, int);
|
||||
void move2LocSignal(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopSignal(int);
|
||||
@ -97,7 +106,7 @@ signals:
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void start(QVector<PathLine>);
|
||||
void stopSignal();
|
||||
void stopSignal_CaptureCoordinator();
|
||||
|
||||
void startLineNumSignal(int lineNum);
|
||||
void sequenceComplete(int status);//所有采集线正常运行完成
|
||||
@ -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,18 +856,22 @@ 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, qOverload<int, double, double, int>(&MotionCaptureCoordinator::moveTo),
|
||||
m_motorCtrl, qOverload<int, double, double, int>(&IrisMultiMotorController::moveTo));
|
||||
|
||||
connect(this, &MotionCaptureCoordinator::zeroStart,
|
||||
m_motorCtrl, &IrisMultiMotorController::zeroStart);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &MotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &MotionCaptureCoordinator::handleError);
|
||||
|
||||
connect(this, SIGNAL(getFocusIndexSobel()),
|
||||
m_cameraCtrl, SLOT(getFocusIndexSobel()));
|
||||
connect(this, &MotionCaptureCoordinator::getFocusIndexSobel,
|
||||
m_cameraCtrl, &ImagerOperationBase::getFocusIndexSobel);
|
||||
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::FocusIndexSobelSignal,
|
||||
this, &MotionCaptureCoordinator::handleCaptureComplete);
|
||||
@ -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
|
||||
|
||||
100
HPPA/fodis.ui
100
HPPA/fodis.ui
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>857</width>
|
||||
<height>477</height>
|
||||
<width>438</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -83,7 +83,7 @@ QPushButton:pressed
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="1" column="1" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="close_btn">
|
||||
@ -113,33 +113,7 @@ QPushButton:pressed
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="2" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
@ -184,7 +158,71 @@ QPushButton:pressed
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<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>
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>535</width>
|
||||
<height>229</height>
|
||||
<width>572</width>
|
||||
<height>384</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -24,6 +24,14 @@
|
||||
color: #ACCDFF;
|
||||
}
|
||||
|
||||
QSpinBox
|
||||
{
|
||||
font: 10pt "新宋体";
|
||||
background-color: #142D7F;
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
@ -66,58 +74,9 @@ QPushButton:pressed
|
||||
QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
QSlider::groove:horizontal {
|
||||
height: 10px;
|
||||
background: #1e2a44;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 已滑过:渐变蓝 */
|
||||
QSlider::sub-page:horizontal {
|
||||
background: qlineargradient(
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1f4fff,
|
||||
stop:0.5 #2f6bff,
|
||||
stop:1 #5fa0ff
|
||||
);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* 未滑过 */
|
||||
QSlider::add-page:horizontal {
|
||||
height: 10px;
|
||||
background: #2a3550;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* ===== 滑块按钮 ===== */
|
||||
QSlider::handle:horizontal {
|
||||
width: 15px;
|
||||
height: 10px;
|
||||
|
||||
/* 蓝色实心 */
|
||||
background: #2f6bff;
|
||||
|
||||
/* 白色外圈 */
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 5px;
|
||||
|
||||
/* 垂直居中 */
|
||||
margin: -5px 0;
|
||||
}
|
||||
|
||||
/* 悬停 */
|
||||
QSlider::handle:horizontal:hover {
|
||||
background: #4d8dff;
|
||||
}
|
||||
|
||||
/* 按下 */
|
||||
QSlider::handle:horizontal:pressed {
|
||||
background: #1f4fff;
|
||||
}</string>
|
||||
</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupAdjustments">
|
||||
<property name="styleSheet">
|
||||
@ -135,46 +94,30 @@ QSlider::handle:horizontal:pressed {
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item row="1" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="spinbox_Port">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</spacer>
|
||||
<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_4">
|
||||
<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_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">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -187,48 +130,18 @@ QSlider::handle:horizontal:pressed {
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="lineEdit_IP">
|
||||
<property name="text">
|
||||
<string>192.168.1.2</string>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelIP">
|
||||
<property name="text">
|
||||
<string>ip</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" 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="1" 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>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -280,6 +193,68 @@ QSlider::handle:horizontal:pressed {
|
||||
</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/>
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -56,7 +56,11 @@ QLabel
|
||||
color: #ACCDFF;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QRadioButton
|
||||
{
|
||||
color: #ACCDFF;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -80,7 +84,7 @@ QLineEdit:focus {
|
||||
background-color: #23345c;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" rowstretch="1,3,1" columnstretch="1,3,1">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -112,75 +116,8 @@ QLineEdit:focus {
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<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 row="0" column="1">
|
||||
<widget class="QLineEdit" name="realTimeLoc_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="0" column="2">
|
||||
<widget class="QPushButton" name="connect_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="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<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 row="1" column="1">
|
||||
<widget class="QLineEdit" name="speed_lineEdit">
|
||||
<widget class="QLineEdit" name="scanSpeed_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
@ -210,7 +147,33 @@ QLineEdit:focus {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="move2loc_pushButton">
|
||||
<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="3" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_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="2" column="2">
|
||||
<widget class="QPushButton" name="zero_start_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
@ -223,8 +186,56 @@ QLineEdit:focus {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="left_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>←0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="right_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="4" column="1">
|
||||
<widget class="QLineEdit" name="move2loc_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
@ -232,7 +243,99 @@ QLineEdit:focus {
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>返回速度</string>
|
||||
<string>扫描速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="connect_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="6" column="1">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<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 row="0" column="1">
|
||||
<widget class="QLabel" name="realTimeLoc_label">
|
||||
<property name="text">
|
||||
<string>null</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="manualMovementSpeed_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0.1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>手动速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
@ -261,113 +364,60 @@ QLineEdit:focus {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="move2loc_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
<string>返回速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="move2loc_pushButton">
|
||||
<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="4" column="1">
|
||||
<widget class="QPushButton" name="left_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>←0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="right_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="5" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>状态</string>
|
||||
</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">background-color: red;
|
||||
<item row="6" column="2">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="reverseMove_radioButton">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>反转</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<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">background-color: red;
|
||||
border-radius: 4px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@ -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(QString::fromLocal8Bit("全图"));
|
||||
ui.hyperimgDisplayMode_comboBox->addItem(QString::fromLocal8Bit("瀑布流"));
|
||||
|
||||
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()
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core</QtModules>
|
||||
<QtModules>core;serialport</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
@ -58,6 +58,7 @@
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user