add,山地所贡嘎山5,初步实现:
1、监听tcp消息,收到位置后触发pica L和is11采集。 2、releases可编译;
This commit is contained in:
@ -8,6 +8,8 @@ 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;
|
||||
|
||||
AppSettings::AppSettings()
|
||||
: m_settings(QSettings::IniFormat, QSettings::UserScope,
|
||||
@ -115,3 +117,23 @@ void AppSettings::setFiberImagerDataFolder(const QString& path)
|
||||
{
|
||||
m_settings.setValue("General/FiberImagerDataFolder", path);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -37,6 +37,14 @@ public:
|
||||
|
||||
QString FiberImagerDataFolder() const;
|
||||
void setFiberImagerDataFolder(const QString& path);
|
||||
|
||||
// 扫描速度
|
||||
double scanSpeed() const;
|
||||
void setScanSpeed(double value);
|
||||
|
||||
// 返回速度
|
||||
double returnSpeed() const;
|
||||
void setReturnSpeed(double value);
|
||||
// 在此处添加更多参数的 getter/setter ...
|
||||
|
||||
private:
|
||||
@ -54,4 +62,6 @@ private:
|
||||
static const int kDefaultGain;
|
||||
static const QString kDefaultSLRDataFolder;
|
||||
static const QString kDefaultDepthCameraDataFolder;
|
||||
static const double kDefaultScanSpeed;
|
||||
static const double kDefaultReturnSpeed;
|
||||
};
|
||||
|
||||
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ 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::exposureCompleteSignal, this, &FodisWindow::exposureCompleteSignal);
|
||||
m_JinspFiberImagerOperation->moveToThread(m_FiberImagerThread);
|
||||
m_FiberImagerThread->start();
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@ signals:
|
||||
|
||||
void spectalCaptured(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void exposureCompleteSignal();
|
||||
|
||||
private:
|
||||
Ui::FodisWindow ui;
|
||||
QThread* m_FiberImagerThread;
|
||||
|
||||
@ -11,15 +11,30 @@ GonggaShanRecordCtl::GonggaShanRecordCtl(QWidget* parent)
|
||||
|
||||
GonggaShanRecordCtl::~GonggaShanRecordCtl()
|
||||
{
|
||||
|
||||
tcpServer6005->deleteLater();
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::startListen()
|
||||
{
|
||||
MotorParams::TCPConnectionParams tcpConnectionParams6005;
|
||||
tcpConnectionParams6005.port = ui.spinbox_Port->text().toInt();
|
||||
tcpConnectionParams6005.serverIP = "192.168.1.2";
|
||||
tcpServer6005 = new MotorParams::CommunicationViaTCP(tcpConnectionParams6005, this);
|
||||
|
||||
connect(tcpServer6005, &MotorParams::CommunicationViaTCP::positionReceived, this, &GonggaShanRecordCtl::startRecord);
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::stopListen()
|
||||
{
|
||||
|
||||
disconnect(tcpServer6005, &MotorParams::CommunicationViaTCP::positionReceived, this, &GonggaShanRecordCtl::startRecord);
|
||||
|
||||
tcpServer6005->deleteLater();
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::startRecord(int position)
|
||||
{
|
||||
//<2F><>¼λ<C2BC><CEBB>
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
emit startRcordSignal();
|
||||
}
|
||||
|
||||
@ -4,9 +4,12 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <vector>
|
||||
#include <QPointer>
|
||||
|
||||
#include "ui_gonggashanCtl.h"
|
||||
|
||||
#include "CommunicationViaTCP.h"
|
||||
|
||||
class GonggaShanRecordCtl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -20,15 +23,15 @@ public Q_SLOTS:
|
||||
|
||||
Q_SIGNALS:
|
||||
// Emitted when user changes any of the R/G/B wavelength values
|
||||
void startRcordHsiSignal();
|
||||
void stopRcordHsiSignal();
|
||||
|
||||
void startRcordFodisSignal();
|
||||
void startRcordSignal();
|
||||
|
||||
private Q_SLOTS:
|
||||
void startListen();
|
||||
void stopListen();
|
||||
|
||||
void startRecord(int position);
|
||||
|
||||
private:
|
||||
Ui::gongga_control ui;
|
||||
QPointer<MotorParams::CommunicationViaTCP> tcpServer6005;
|
||||
};
|
||||
|
||||
@ -1057,16 +1057,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 +1076,37 @@ void HPPA::initControlTabwidget()
|
||||
// this, SLOT(onBandSelectionChanged(double, double, double)));
|
||||
}
|
||||
|
||||
void HPPA::setupGonggashanAutoRecordConnection()
|
||||
{
|
||||
connect(m_gonggaShanRecordCtl, &GonggaShanRecordCtl::startRcordSignal, this, &HPPA::onGonggashanRecord);
|
||||
connect(m_fodisWindow, &FodisWindow::exposureCompleteSignal, this, &HPPA::onStartRecordStep1);
|
||||
connect(m_omc, &OneMotorControl::sequenceComplete, m_fodisWindow, &FodisWindow::closeFiberImager);
|
||||
}
|
||||
|
||||
void HPPA::onGonggashanRecord()
|
||||
{
|
||||
//设置文件名
|
||||
//AppSettings::instance().setFrameRate(f);
|
||||
//AppSettings::instance().setIntegrationTime(e);
|
||||
//AppSettings::instance().setDataFolder(filePath);
|
||||
|
||||
QString dateStr = QDateTime::currentDateTime().toString("yyyy-MM-dd_HH-mm-ss");
|
||||
//QString fi = AppSettings::instance().fileName() + "_" + dateStr;
|
||||
AppSettings::instance().setFileName(dateStr);
|
||||
|
||||
this->frame_number->setText("100000");
|
||||
|
||||
//连接马达和光谱仪
|
||||
m_omc->connectMotor(false);
|
||||
|
||||
if (!testImagerVality())
|
||||
{
|
||||
onconnect();
|
||||
}
|
||||
|
||||
m_fodisWindow->openFiberImager();
|
||||
}
|
||||
|
||||
void HPPA::recordFromRobotArm(int fileCounter)
|
||||
{
|
||||
if (!testImagerVality())
|
||||
|
||||
@ -362,6 +362,9 @@ private:
|
||||
QChart* m_FiberImagerChart;
|
||||
void showFiberImagerSpectral(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void setupGonggashanAutoRecordConnection();
|
||||
void onGonggashanRecord();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
|
||||
void focusPlotSpectralImg(int state);
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by 73505 on 2023/5/7.
|
||||
//
|
||||
#include <algorithm>
|
||||
|
||||
#include "JinspFiberImager.h"
|
||||
|
||||
@ -12,7 +13,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");
|
||||
@ -188,73 +189,108 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
ZZ_S32 JinspFiberImager::GetMaxValue(ZZ_S32 * dark, int number)
|
||||
@ -291,6 +327,7 @@ void JinspFiberImager::OpenFiberImagerAndRecord()
|
||||
|
||||
//曝光
|
||||
autoExpose();
|
||||
emit exposureCompleteSignal();
|
||||
|
||||
//采集
|
||||
m_record = true;
|
||||
|
||||
@ -65,4 +65,6 @@ public slots:
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
void spectalCaptured(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void exposureCompleteSignal();
|
||||
};
|
||||
|
||||
@ -16,6 +16,19 @@ OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
|
||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
|
||||
// 从 AppSettings 读取速度参数
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
ui.speed_lineEdit->setText(QString::number(settings.scanSpeed()));
|
||||
ui.return_speed_lineEdit->setText(QString::number(settings.returnSpeed()));
|
||||
|
||||
// 连接信号,当控件数值变化时保存到 AppSettings
|
||||
connect(ui.speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setScanSpeed(ui.speed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.return_speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setReturnSpeed(ui.return_speed_lineEdit->text().toDouble());
|
||||
});
|
||||
}
|
||||
|
||||
OneMotorControl::~OneMotorControl()
|
||||
@ -25,13 +38,21 @@ OneMotorControl::~OneMotorControl()
|
||||
}
|
||||
|
||||
void OneMotorControl::onConnectMotor()
|
||||
{
|
||||
connectMotor(true);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
#include "MotorWindowBase.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
class OneMotorControl : public QDialog, public MotorWindowBase
|
||||
{
|
||||
@ -27,6 +28,8 @@ public:
|
||||
|
||||
bool getMotorsConnectionStatus();
|
||||
|
||||
void connectMotor(bool isNotification);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
|
||||
|
||||
@ -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