18 Commits
1.5 ... 1.9.0

Author SHA1 Message Date
48be580226 add
1、创建场景:室内线性一轴平台;
fix
1、采集逻辑错误;
2、鼠标左键单击显示光谱;
2025-07-17 18:30:30 +08:00
a629115e91 add
1、添加corning 410控制;
2、通过 IrisMultiMotorController 添加一轴马达控制,通过配置文件控制马达个数和马达初始化参数;

fix
1、修复点击显示光谱bug;
2、修复机械臂bug;
2025-05-15 16:40:42 +08:00
c1e4144ed6 add
支持corning 410,并添加配置文件
2025-05-09 17:27:04 +08:00
c2b3f131ee fix
1、重启软件后,恢复上次关闭的布局;
2、菜单栏添加/:光谱曲线显示停靠窗;
add
双轴线性平台:采集暗电流也移动x马达;
2025-05-07 10:05:16 +08:00
20848bef1a 机械臂和光谱仪联动,右下角机械臂控制窗口不会触发相机采集; 2025-04-16 16:25:51 +08:00
f6138dd2ed QTcpSocket异步通讯控制机械臂 2025-04-14 10:02:37 +08:00
f32ade7487 1、添加仅采集影像,马达不运动的功能,可用于机械臂和影像采集测试;
2、使用 QSettings 记录 Action 的 isChecked 状态,并在打开软件时恢复;
2025-04-11 15:48:27 +08:00
89c701c5f2 使用QSettings保存选择的相机类型 2025-03-11 16:51:35 +08:00
a7fd9e4fa9 添加3个升降桌 2025-03-06 19:16:21 +08:00
5af6a039c2 x马达扫描速度接受小数 2025-02-27 14:18:02 +08:00
b779118d72 1、记录x马达位置用于拼接影像;
2、修复了航线读写错误问题;
2025-02-27 11:18:26 +08:00
380e8042d9 fix:
1、暗电流/白板都是550帧平均,采集白板时电机会运动;
2、文件名后加bil后缀;
3、航迹规划小数点从2位改为5位;
2025-02-07 16:25:21 +08:00
0e46470402 加入 dockWidget 2025-01-05 18:34:23 +08:00
cbc81cb75e 1、QMotorDoubleSlider 将细分参数和 Vince 统一,使用7代表128,并修改配置文件类的相关功能;
2、resonon nir 采集白板崩溃:重连相机解决;
3、去掉 imageViewer 的边缘黑框;
4、解决问题:当采集白板数据后,采集影像拉伸问题:硬编码的4096 → 自动计算最大值;
5、记录上次软件布局状态信息,再次打开时恢复;
6、轨迹规划界面文字居中;
7、将 groupbox 换成 dockwidget,然后再菜单栏添加 dock 的开关;
2024-12-25 17:21:53 +08:00
6469bff15d fix & add
1、在界面上实现选择相机类型的功能;
2、创建了一个光谱仪操作的纯虚基类(ImagerOperationBase)并实现了大部分的操作,具体类型的光谱仪应继承此类并实现纯虚函数;
3、添加了 resonon 的 nir 320 相机,修改 resonon 的 pica l 相机的实现:继承 ImagerOperationBase;
4、重构类 QMotorDoubleSlider,提高其通用性,所有马达相关的 slider 都使用此类;
5、适配 resonon nir 320 显微镜使用的 2 轴线性平台,有些特殊的马达参数设置(setMotorParamMicroscope 函数)绑定了 nir 的相机类型参数;
6、修改:将线性平台的量程信息保存在cfg配置文件中,并修改配置文件读写类来读写此量程信息;
2024-12-11 17:33:29 +08:00
9fa9fc8efb 添加升降台控制功能 2024-11-29 11:15:58 +08:00
8e3315338f add:添加控制升降台功能 2024-06-20 16:26:54 +08:00
868b60ff67 1、修复bug:关闭-打开马达电源后,总有一个马达连接不上,通过删掉重建马达对象解决;
2、将任总的马达控制库加入本工程;
2024-03-15 14:45:33 +08:00
51 changed files with 8223 additions and 2859 deletions

View File

@ -1,20 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1267
# Visual Studio Version 17
VisualStudioVersion = 17.5.33502.453
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPPA", "HPPA\HPPA.vcxproj", "{E7886664-B69E-4781-BCBE-804574FB4033}"
ProjectSection(ProjectDependencies) = postProject
{B12702AD-ABFB-343A-A199-8E24837244A3} = {B12702AD-ABFB-343A-A199-8E24837244A3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vincecontrol", "vincecontrol\vincecontrol.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IrisMultiMotorController", "IrisMultiMotorController\IrisMultiMotorController\IrisMultiMotorController.vcxproj", "{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.ActiveCfg = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.Build.0 = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x86.ActiveCfg = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x86.Build.0 = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.ActiveCfg = Release|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.Build.0 = Release|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x86.ActiveCfg = Release|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x86.Build.0 = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x64.ActiveCfg = Debug|x64
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x64.Build.0 = Debug|x64
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x86.ActiveCfg = Debug|x64
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x86.Build.0 = Debug|x64
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x64.ActiveCfg = Release|x64
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x64.Build.0 = Release|x64
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.ActiveCfg = Release|x64
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

158
HPPA/Corning410Imager.cpp Normal file
View File

@ -0,0 +1,158 @@
#include "Corning410Imager.h"
Corning410Imager::Corning410Imager()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><D0A3>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string CfgFile = getPathofEXE() + "\\corning410.cfg";
m_configfile.setConfigfilePath(CfgFile);
if (!m_configfile.isConfigfileExist())
{
m_configfile.createConfigFile();
qDebug() << "create: " << QString::fromStdString(CfgFile);
}
m_configfile.parseConfigfile();
qDebug() << "exist: " << QString::fromStdString(CfgFile);
}
Corning410Imager::~Corning410Imager()
{
if (buffer != nullptr)
{
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
free(buffer);
free(dark);
free(white);
}
}
double Corning410Imager::getFramerate()
{
return m_imager.get_framerate();
}
double Corning410Imager::getIntegrationTime()
{
return m_imager.get_integration_time() / 1000;
}
double Corning410Imager::getGain()
{
return m_imager.get_gain();
}
void Corning410Imager::setGain(const double gain)
{
m_imager.set_gain(gain);
}
void Corning410Imager::setFramerate(const double frames_per_second)
{
m_imager.set_framerate(frames_per_second);
m_RgbImage->m_iFramerate = frames_per_second;
}
void Corning410Imager::setIntegrationTime(const double milliseconds)
{
m_imager.set_integration_time(milliseconds * 1000);
}
int Corning410Imager::getStartBand()
{
return m_imager.get_start_band();
}
int Corning410Imager::getEndBand()
{
return m_imager.get_end_band();
}
void Corning410Imager::connectImager(const char* camera_sn)
{
m_imager.connect();
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
bool ret, ret1, ret2;
int spatialBin;
int spectralBin;
ret1 = m_configfile.getspatialBin(spatialBin);
ret2 = m_configfile.getSpectralBin(spectralBin);
if (ret1 && ret2)
{
bool haha = m_imager.setSpectralBin(spectralBin);
bool haha2 = m_imager.setSpatialBin(spatialBin);
std::cout << "spectralBin<EFBFBD><EFBFBD>" << spectralBin << std::endl;
std::cout << "spatialBin<EFBFBD><EFBFBD>" << spatialBin << std::endl;
}
float gain, offset;
ret = m_configfile.getGainOffset(gain, offset);
if (ret)
{
m_imager.setGainOffset(gain, offset);
}
int width = 0, offsetx = 0, height = 0, offsety = 0;
ret = m_configfile.getEffectiveWindow(width, offsetx, height, offsety);
if (ret)
{
m_imager.setEffectiveWindow(offsetx, width, offsety, height);
}
int bufferPolicy, acqBufferSize;
ret1 = m_configfile.getBufferPolicy(bufferPolicy);
if (ret1)
{
m_imager.setBufferPolicy(bufferPolicy);
}
ret1 = m_configfile.getAcqBufferSize(acqBufferSize);
if (ret1)
{
m_imager.setAcqBufferSize(acqBufferSize);
}
}
void Corning410Imager::disconnectImager()
{
m_imager.disconnect();
}
void Corning410Imager::imagerStartCollect()
{
m_imager.start();
}
void Corning410Imager::imagerStopCollect()
{
m_imager.stop();
}
unsigned short* Corning410Imager::getFrame(unsigned short* buffer)
{
m_imager.get_frame(buffer);
return buffer;
}
void Corning410Imager::setSpectraBin(int new_spectral_bin)
{
}
double Corning410Imager::getWavelengthAtBand(int band)
{
return m_imager.get_wavelength_at_band(band);
}
int Corning410Imager::getBandCount()
{
return m_imager.get_band_count();
}
int Corning410Imager::getSampleCount()
{
return m_imager.get_sample_count();
}

48
HPPA/Corning410Imager.h Normal file
View File

@ -0,0 +1,48 @@
#pragma once
#include <string>
#include <opencv2/core/core.hpp>
#include "ImagerOperationBase.h"
#include "image2display.h"
#include "fileOperation.h"
#include "irisximeaimager.h"
#include "path_tc.h"
#include "hppaConfigFile.h"
class Corning410Imager :public ImagerOperationBase
{
Q_OBJECT
public:
Corning410Imager();
~Corning410Imager();
Iris::IrisXimeaImager m_imager;
double getWavelengthAtBand(int band);
int getBandCount();
int getSampleCount();
double getFramerate();
double getIntegrationTime();
double getGain();
void setFramerate(const double frames_per_second);
void setIntegrationTime(const double milliseconds);
void setGain(const double gain);
int getStartBand();
int getEndBand();
void connectImager(const char* camera_sn = NULL);
void disconnectImager();
void imagerStartCollect();
void imagerStopCollect();
unsigned short* getFrame(unsigned short* buffer);
void setSpectraBin(int new_spectral_bin);
protected:
private:
CorningConfigfile m_configfile;
public slots:
signals:
};

View File

@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>1312</width>
<height>752</height>
<width>600</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>调焦</string>
</property>
<property name="windowIcon">
<iconset resource="HPPA.qrc">

File diff suppressed because it is too large Load Diff

View File

@ -26,13 +26,22 @@
#include "fileOperation.h"
#include "RgbCameraOperation.h"
#include "imageProcessor.h"
#include "fileOperation.h"
#include "focusWindow.h"
#include "aboutWindow.h"
#include "adjustTable.h"
#include "PowerControl.h"
#include "PathPlan.h"
#include "RobotArmControl.h"
#include "OneMotorControl.h"
#include "hppaConfigFile.h"
#include "path_tc.h"
#include "ResononNirImager.h"
#include "Corning410Imager.h"
#define PI 3.1415926
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<><CAB9> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>ʹ<EFBFBD><CAB9>
@ -44,9 +53,9 @@ private:
public:
ResononImager *m_Imager;
ImagerOperationBase*m_Imager;
WorkerThread(ResononImager * Imager)
WorkerThread(ImagerOperationBase* Imager)
{
m_Imager = Imager;
}
@ -158,13 +167,21 @@ public:
private:
Ui::HPPAClass ui;
QMenu* mPanelMenu = nullptr;
QMenu* mToolbarMenu = nullptr;
void initPanelToolbar();
QLineEdit * frame_number;
QLineEdit * m_FilenameLineEdit;
QLabel * xmotor_state_label1;
QLabel * ymotor_state_label1;
Configfile mConfigfile;
ForLoopControl * m_ForLoopControl;
ResononImager * m_Imager;//
ImagerOperationBase* m_Imager;//
int m_RecordState;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>̣<EFBFBD>ȡ2<C8A1><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1 <20><> <20><><EFBFBD>ڲɼ<DAB2><C9BC><EFBFBD>0 <20><> ֹͣ<CDA3>ɼ<EFBFBD>
@ -201,8 +218,7 @@ private:
QTimer *m_timerYmotorLocationFeedBackAfterRecord;//<2F>ɼ<EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD>ɺ󣬽<C9BA><F3A3ACBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʵʱ<CAB5><CAB1><EFBFBD>ص<EFBFBD>slider<65><72>
QString operateWidget;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<C4BF><D8BC><EFBFBD>
//<2F><><EFBFBD><EFBFBD>
bool isMotorConnected(VinceControl *motor);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD>false
void SetXMotorWidgetEnable(bool enable);
void SetYMotorWidgetEnable(bool enable);
@ -222,8 +238,24 @@ private:
void getRequest(QString str);
QActionGroup* mImagerGroup = nullptr;
void createActionGroups();
void selectingImager(QAction* selectedAction);
QActionGroup* moveplatformActionGroup = nullptr;
void createMoveplatformActionGroup();
void selectingMoveplatform(QAction* selectedAction);
RobotArmControl* rac;
OneMotorControl* omc;
QDockWidget* dock_omc;
PathPlan* m_pathPlan;
FILE* m_hTimesFile;
public Q_SLOTS:
void onPlotHyperspectralImageRgbImage();
void onPlotHyperspectralImageRgbImage(int number);
void PlotSpectral(int state);
void onRecordFinishedSignal_WhenFrameNumberMeet();
void onRecordFinishedSignal_WhenFrameNumberNotMeet();
@ -236,7 +268,9 @@ public Q_SLOTS:
void onFocus2(int command);
void onAbout();
void onDark();
void recordDarkFinish();
void onReference();
void recordWhiteFinish();
void onStartRecordStep1();
void onStartRecordStep2(int lineNumber);
void onCreateTab(int trackNumber);
@ -255,7 +289,12 @@ public Q_SLOTS:
//<2F><><EFBFBD><EFBFBD>
void deleteMotor();
void newMotor();
void timerEvent(QTimerEvent *event);
void setMotorParamMicroscope(VinceControl* motor);
void setXMotorParamFromCfgFile(VinceControl* motor);
void setYMotorParamFromCfgFile(VinceControl* motor);
void onxMotorLeft();
@ -290,14 +329,6 @@ public Q_SLOTS:
void ontimerTestRangeOfxMotor();
void ontimerTestRangeOfyMotor();
//<2F>ɼ<EFBFBD><C9BC>߹滮
void onAddRecordLine_btn();
void onRemoveRecordLine_btn();
void onGenerateRecordLine_btn();
void onDeleteRecordLine_btn();
void onSaveRecordLine2File_btn();
void onReadRecordLineFile_btn();
void ontimerMoveXmotor();
void ontimerMoveYmotor();
@ -311,19 +342,20 @@ public Q_SLOTS:
void onCopyFinished();
void onLampPowerOpen_btn();
void onLampPowerClose_btn();
void onMotorPowerOpen_btn();
void onMotorPowerClose_btn();
void requestFinished(QNetworkReply* reply);
void recordFromRobotArm(int fileCounter);
void recordHyperSpecImg(int status);
void createOneMotorScenario();
signals:
void StartFocusSignal();
void StartLoopSignal();
void StartRecordSignal();
void CopyFileThreadSignal(QString, QString);
void BroadcastXMotorPosSignal(long long, int);
void RecordWhiteSignal();
void RecordDarlSignal();
};

File diff suppressed because it is too large Load Diff

View File

@ -55,16 +55,17 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<IncludePath>D:\cpp_library\vincecontrol_vs2017;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;$(IncludePath)</IncludePath>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;$(LibraryPath)</LibraryPath>
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;$(IncludePath)</IncludePath>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<IncludePath>D:\cpp_library\vincecontrol_vs2017;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;$(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;$(LibraryPath)</LibraryPath>
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;$(IncludePath)</IncludePath>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -72,7 +73,8 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.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;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
@ -84,7 +86,7 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
@ -103,19 +105,30 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="aboutWindow.cpp" />
<ClCompile Include="adjustTable.cpp" />
<ClCompile Include="Corning410Imager.cpp" />
<ClCompile Include="hppaConfigFile.cpp" />
<ClCompile Include="ImagerOperationBase.cpp" />
<ClCompile Include="imager_base.cpp" />
<ClCompile Include="irisximeaimager.cpp" />
<ClCompile Include="OneMotorControl.cpp" />
<ClCompile Include="PathPlan.cpp" />
<ClCompile Include="path_tc.cpp" />
<ClCompile Include="PowerControl.cpp" />
<ClCompile Include="QDoubleSlider.cpp" />
<ClCompile Include="QMotorDoubleSlider.cpp" />
<ClCompile Include="QYMotorDoubleSlider.cpp" />
<ClCompile Include="resononImager.cpp" />
<ClCompile Include="ResononNirImager.cpp" />
<ClCompile Include="RgbCameraOperation.cpp" />
<ClCompile Include="RobotArmControl.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="utility_tc.cpp" />
<QtRcc Include="HPPA.qrc" />
<QtUic Include="about.ui" />
<QtUic Include="adjustTable.ui" />
<QtUic Include="FocusDialog.ui" />
<QtUic Include="HPPA.ui" />
<QtMoc Include="HPPA.h" />
@ -129,6 +142,10 @@
<ClCompile Include="imagerSimulatioin.cpp" />
<ClCompile Include="ImageViewer.cpp" />
<ClCompile Include="main.cpp" />
<QtUic Include="oneMotorControl.ui" />
<QtUic Include="PathPlan.ui" />
<QtUic Include="PowerControl.ui" />
<QtUic Include="RobotArmControl.ui" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="fileOperation.h" />
@ -140,16 +157,26 @@
<QtMoc Include="image2display.h" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="adjustTable.h" />
<QtMoc Include="PowerControl.h" />
<QtMoc Include="PathPlan.h" />
<QtMoc Include="RobotArmControl.h" />
<QtMoc Include="Corning410Imager.h" />
<ClInclude Include="imager_base.h" />
<ClInclude Include="irisximeaimager.h" />
<QtMoc Include="OneMotorControl.h" />
<ClInclude Include="utility_tc.h" />
<QtMoc Include="aboutWindow.h" />
<ClInclude Include="hppaConfigFile.h" />
<ClInclude Include="imageProcessor.h" />
<ClInclude Include="ImageReaderWriter.h" />
<QtMoc Include="ImagerOperationBase.h" />
<ClInclude Include="path_tc.h" />
<ClInclude Include="ResononNirImager.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
<QtMoc Include="RgbCameraOperation.h" />
<QtMoc Include="resononImager.h" />
<QtMoc Include="QYMotorDoubleSlider.h" />
<QtMoc Include="QMotorDoubleSlider.h" />
<QtMoc Include="QDoubleSlider.h" />
<QtMoc Include="ImageViewer.h" />

View File

@ -21,6 +21,12 @@
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
</Filter>
<Filter Include="Header Files\motor">
<UniqueIdentifier>{eadfac5f-f4f9-49e2-9f99-0849bf074cf8}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\motor">
<UniqueIdentifier>{4672856c-86fb-46e3-94ff-0a296dcc6111}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<QtRcc Include="HPPA.qrc">
@ -70,9 +76,6 @@
<ClCompile Include="QMotorDoubleSlider.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="QYMotorDoubleSlider.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="resononImager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -91,6 +94,39 @@
<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>
<ClCompile Include="adjustTable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PowerControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PathPlan.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RobotArmControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Corning410Imager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="imager_base.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="irisximeaimager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="OneMotorControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="fileOperation.h">
@ -117,9 +153,6 @@
<QtMoc Include="QMotorDoubleSlider.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="QYMotorDoubleSlider.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="resononImager.h">
<Filter>Header Files</Filter>
</QtMoc>
@ -129,6 +162,27 @@
<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>
<QtMoc Include="PowerControl.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="PathPlan.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="RobotArmControl.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="Corning410Imager.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="OneMotorControl.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<ClInclude Include="imageProcessor.h">
@ -149,6 +203,18 @@
<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>
<ClInclude Include="imager_base.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="irisximeaimager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtUic Include="FocusDialog.ui">
@ -157,6 +223,21 @@
<QtUic Include="about.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="adjustTable.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="PowerControl.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="PathPlan.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="RobotArmControl.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="oneMotorControl.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

View File

@ -37,6 +37,7 @@ ImageViewer::ImageViewer(QWidget* pParent) :QGraphicsView(pParent)
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameShape(QFrame::NoFrame);
}
ImageViewer::~ImageViewer()

View File

@ -0,0 +1,442 @@
#include "ImagerOperationBase.h"
ImagerOperationBase::ImagerOperationBase()
{
m_iFrameCounter = 1;
m_bRecordControlState = true;
m_FileName2Save = "tmp_image";
m_FileSavedCounter = 1;
m_RgbImage = new CImage();
buffer = nullptr;
dark = nullptr;
white = nullptr;
m_HasDark = false;
m_HasWhite = false;
m_bFocusControlState = false;
}
ImagerOperationBase::~ImagerOperationBase()
{
}
void ImagerOperationBase::connect_imager(int frameNumber)
{
connectImager();
setIntegrationTime(1);
setFramerate(30.0);
//set_gain(0);
//m_ResononNirImager.set_spectral_bin(2);
set_buffer();
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), frameNumber);
m_iFrameNumber = frameNumber;
emit testImagerStatus();
//std::cout << "------------------------------------------------------" << std::endl;
}
double ImagerOperationBase::auto_exposure()
{
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<C7B0><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double x = 1 / getFramerate() * 1000;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
setIntegrationTime(x);
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ѭ<EFBFBD><D1AD>Ѱ<EFBFBD><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
imagerStartCollect();
while (true)
{
getFrame(buffer);
if (GetMaxValue(buffer, m_FrameSize) >= 4094)
{
setIntegrationTime(getIntegrationTime() * 0.95);
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
}
else
{
break;
}
}
imagerStopCollect();
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << getIntegrationTime() << std::endl;
return getIntegrationTime();
}
void ImagerOperationBase::focus()
{
m_iFocusFrameCounter = 1;
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
double tmpFrmerate = getFramerate();
double tmpIntegrationTime = getIntegrationTime();
setFramerate(5);
auto_exposure();
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
imagerStartCollect();
//emit SpectralSignal(1);
m_bFocusControlState = true;
while (m_bFocusControlState)
{
getFrame(buffer);
//m_RgbImage->FillFocusGrayImage(buffer);
m_RgbImage->FillFocusGrayQImage(buffer);
emit SpectralSignal(1);
++m_iFocusFrameCounter;
}
emit SpectralSignal(0);
imagerStopCollect();
setFramerate(tmpFrmerate);
setIntegrationTime(tmpIntegrationTime);
}
void ImagerOperationBase::record_dark()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
imagerStartCollect();
unsigned int* dark_tmp = new unsigned int[m_FrameSize];
std::fill(dark_tmp, dark_tmp + m_FrameSize, 0);
int counter = 50;
for (size_t i = 0; i < counter; i++)
{
getFrame(dark);
for (size_t j = 0; j < m_FrameSize; j++)
{
dark_tmp[j] = dark[j] + dark_tmp[j];
}
}
for (size_t j = 0; j < m_FrameSize; j++)
{
dark[j] = (unsigned short)(dark_tmp[j] / counter);
}
delete[] dark_tmp;
imagerStopCollect();
m_HasDark = true;
emit RecordDarlFinishSignal();
}
void ImagerOperationBase::record_white()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
imagerStartCollect();
unsigned int* white_tmp = new unsigned int[m_FrameSize];
std::fill(white_tmp, white_tmp + m_FrameSize, 0);
int counter = 50;
for (size_t i = 0; i < counter; i++)
{
getFrame(white);
for (size_t j = 0; j < m_FrameSize; j++)
{
white_tmp[j] = white[j] + white_tmp[j];
}
}
for (size_t j = 0; j < m_FrameSize; j++)
{
white[j] = (unsigned short)(white_tmp[j] / counter);
}
delete[] white_tmp;
imagerStopCollect();
//<2F>װ<EFBFBD><D7B0>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD>
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
if (white[i] < dark[i])
{
white[i] = 0;
}
else
{
white[i] = white[i] - dark[i];
}
}
}
m_HasWhite = true;
emit RecordWhiteFinishSignal();
}
void ImagerOperationBase::start_record()
{
using namespace std;
//std::cout << "------------------------------------------------------" << std::endl;
m_iFrameCounter = 0;
m_RgbImage->m_iFrameCounter = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<62><CDBC><EFBFBD>ĵ<EFBFBD>0<EFBFBD><30>
m_bRecordControlState = true;
//<2F>ж<EFBFBD><D0B6>ڴ<EFBFBD>buffer<65>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (buffer == 0)
{
std::cerr << "Error: memory could not be allocated for datacube";
exit(EXIT_FAILURE);
}
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
size_t x;
double pixelValueTmp;
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
imagerStartCollect();
while (m_bRecordControlState)
{
m_iFrameCounter++;
getFrame(buffer);
long long timeOs = getNanosecondsSinceMidnight();
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
if (buffer[i] < dark[i])
{
buffer[i] = 0;
}
else
{
buffer[i] = buffer[i] - dark[i];
}
}
}
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (m_HasWhite)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (white[i] != 0)
{
pixelValueTmp = buffer[i];
buffer[i] = (pixelValueTmp / white[i]) * 10000;
}
else
{
buffer[i] = 0;
}
}
}
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
fprintf(hTimesFile, "%d\n", timeOs);
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
//std::cout << "<22><>" << m_iFrameCounter << "֡д<D6A1><D0B4>" << x << "<22><>unsigned short<72><74>" << std::endl;
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
if (m_iFrameCounter % (int)getFramerate() == 0)
{
emit PlotSignal(m_iFrameCounter);
}
if (m_iFrameCounter >= m_iFrameNumber)
{
break;
}
}
imagerStopCollect();
m_bRecordControlState = false;
WriteHdr();
m_FileSavedCounter++;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//m_RgbImage
emit PlotSignal(-1);//<2F><>1<EFBFBD><31><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ<EFBFBD><C8AB>2<EFBFBD><32>ʹ<EFBFBD>û<EFBFBD>е<EFBFBD>۲ɼ<DBB2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ʼ<E4BFAA>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><E1B5BC><EFBFBD>ϴβɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>źŵ<C5BA><C5B5>õIJۺ<C4B2><DBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>˼<EFBFBD><CBBC>ݣ<EFBFBD>ע<EFBFBD>͵<EFBFBD>
if (m_iFrameCounter >= m_iFrameNumber)
{
emit RecordFinishedSignal_WhenFrameNumberMeet();
}
else
{
emit RecordFinishedSignal_WhenFrameNumberNotMeet();
}
//QThread::msleep(1001);
fclose(m_fImage);
fclose(hTimesFile);
}
void ImagerOperationBase::setFrameNumber(int FrameNumber)
{
m_iFrameNumber = FrameNumber;
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), FrameNumber);
}
void ImagerOperationBase::setFileName2Save(string FileName)
{
m_FileName2Save = FileName;
m_FileSavedCounter = 1;
}
void ImagerOperationBase::setFocusControlState(bool FocusControlState)
{
m_bFocusControlState = FocusControlState;
}
int ImagerOperationBase::GetFrameSize(int& iWidth, int& iHeight)
{
/*using namespace GENAPI_NAMESPACE;
using namespace std;
INodeMap& nodemap = m_phCamera->GetNodeMap();
iWidth = (int)CIntegerPtr(nodemap.GetNode("Width"))->GetValue();
iHeight = (int)CIntegerPtr(nodemap.GetNode("Height"))->GetValue();*/
iWidth = getSampleCount();
iHeight = getBandCount();
return 0;
}
CImage* ImagerOperationBase::getRgbImage() const
{
return m_RgbImage;
}
cv::Mat* ImagerOperationBase::getMatRgbImage() const
{
return m_RgbImage->m_matRgbImage;
}
cv::Mat* ImagerOperationBase::getMatFocusGrayImage() const
{
return m_RgbImage->m_matFocusGrayImage;
}
QImage ImagerOperationBase::getQImageFocusGrayImage() const
{
return *m_RgbImage->m_qimageFocusGrayImage;
}
bool ImagerOperationBase::getRecordControlState() const
{
return m_bRecordControlState;
}
void ImagerOperationBase::setRecordControlState(bool RecordControlState)
{
m_bRecordControlState = RecordControlState;
}
int ImagerOperationBase::getFrameCounter() const
{
return m_iFrameCounter;
}
int ImagerOperationBase::getFocusFrameCounter() const
{
return m_iFocusFrameCounter;
}
void ImagerOperationBase::set_buffer()
{
//<2F><><EFBFBD><EFBFBD>
if (buffer != nullptr)
{
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
free(buffer);
}
m_FrameSize = getBandCount() * getSampleCount();
//std::cout << "m_FrameSize<7A><65>СΪ" << m_FrameSize << std::endl;
buffer = new unsigned short[m_FrameSize];
dark = new unsigned short[m_FrameSize];
white = new unsigned short[m_FrameSize];
std::cout << "buffer<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << buffer << std::endl;
std::cout << "dark<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << dark << std::endl;
std::cout << "white<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << white << std::endl;
}
void ImagerOperationBase::WriteHdr()
{
//write an ENVI compatible header file
using namespace std;
string hdrPath = removeFileExtension(m_FileName2Save2) + ".hdr";
std::ofstream outfile(hdrPath.c_str());
outfile << "ENVI\n";
outfile << "interleave = bil\n";
outfile << "data type = 12\n";
outfile << "bit depth = 12\n";
outfile << "samples = " << getSampleCount() << "\n";
outfile << "bands = " << getBandCount() << "\n";
outfile << "lines = " << m_iFrameCounter << "\n";
outfile << "framerate = " << getFramerate() << "\n";
outfile << "shutter = " << getIntegrationTime() << "\n";
outfile << "gain = " << getGain() << "\n";
outfile << "wavelength = {";
outfile << std::setprecision(5);
int start = getStartBand();
int end = getEndBand();
for (int i = start; i < end - 1; i++)
{
outfile << getWavelengthAtBand(i) << ", ";
}
outfile << getWavelengthAtBand(end - 1) << "}\n";
outfile.close();
}
unsigned short ImagerOperationBase::GetMaxValue(unsigned short* dark, int number)
{
unsigned short max = 0;
for (size_t i = 0; i < number; i++)
{
if (dark[i] > max)
{
max = dark[i];
}
}
//std::cout << "<22><>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
return max;
}

107
HPPA/ImagerOperationBase.h Normal file
View File

@ -0,0 +1,107 @@
#pragma once
#include <QObject>
#include <QString>
#include "image2display.h"
#include "fileOperation.h"
#include <string>
#include <opencv2/core/core.hpp>
#include "ImagerOperationBase.h"
#include "utility_tc.h"
class ImagerOperationBase :public QObject
{
Q_OBJECT
public:
ImagerOperationBase();
~ImagerOperationBase();
virtual double getWavelengthAtBand(int band) = 0;
virtual int getBandCount() = 0;
virtual int getSampleCount() = 0;
virtual double getFramerate() = 0;
virtual double getIntegrationTime() = 0;
virtual double getGain() = 0;
virtual void setFramerate(const double frames_per_second) = 0;
virtual void setIntegrationTime(const double milliseconds) = 0;
virtual void setGain(const double gain) = 0;
virtual int getStartBand() = 0;
virtual int getEndBand() = 0;
virtual void connectImager(const char* camera_sn = NULL) = 0;
virtual void disconnectImager() = 0;
virtual void imagerStartCollect() = 0;
virtual void imagerStopCollect() = 0;
virtual unsigned short* getFrame(unsigned short* buffer) = 0;
virtual void setSpectraBin(int new_spectral_bin) = 0;
CImage* getRgbImage() const;
cv::Mat* getMatRgbImage() const;
cv::Mat* getMatFocusGrayImage() const;
QImage getQImageFocusGrayImage() const;
bool getRecordControlState() const;
void setRecordControlState(bool RecordControlState);
int getFrameCounter() const;
int getFocusFrameCounter() const;
unsigned short* buffer;//<2F><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>д<EFBFBD>뵽Ӳ<EBB5BD><D3B2><EFBFBD><EFBFBD>
void set_buffer();
void setFileName2Save(string FileName);
void setFrameNumber(int FrameNumber);
void setFocusControlState(bool FocusControlState);
int GetFrameSize(int& iWidth, int& iHeight);
protected:
CImage* m_RgbImage;//<2F><>ʾ<EFBFBD><CABE>rgbͼ<62><CDBC>
bool m_bRecordControlState;//<2F>ɼ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
int m_iFrameCounter;//<2F><>¼<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
int m_iFocusFrameCounter;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
int m_FrameSize;//<2F><>ʾһ֡<D2BB><D6A1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD>ֵ<EFBFBD><D6B5>m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
int m_iFrameNumber;//<2F><>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
string m_FileName2Save;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
string m_FileName2Save2;
int m_FileSavedCounter;//<2F><><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD>
bool m_HasDark;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
bool m_HasWhite;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰װ<CBB0>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
unsigned short* dark;//<2F><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned short* white;//<2F><EFBFBD>װ<EFBFBD>
bool m_bFocusControlState;//<2F><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
virtual void WriteHdr();
unsigned short GetMaxValue(unsigned short* dark, int number);
private:
public slots:
virtual void connect_imager(int frameNumber);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
virtual double auto_exposure();
virtual void focus();
virtual void start_record();
virtual void record_dark();
virtual void record_white();
signals:
void PlotSignal(int);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA>-1<><31><EFBFBD>˴βɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
void RecordFinishedSignal_WhenFrameNumberMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72>û<EFBFBD>вɼ<D0B2><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>;ֹͣ<CDA3>ɼ<EFBFBD>
void SpectralSignal(int);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9>ף<EFBFBD><D7A3><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
void RecordWhiteFinishSignal();
void RecordDarlFinishSignal();
void testImagerStatus();//<2F><>ʾ<EFBFBD><CABE><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};

133
HPPA/OneMotorControl.cpp Normal file
View File

@ -0,0 +1,133 @@
#include "OneMotorControl.h"
OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
{
ui.setupUi(this);
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
}
OneMotorControl::~OneMotorControl()
{
m_motorThread.quit();
m_motorThread.wait();
}
void OneMotorControl::onConnectMotor()
{
try
{
FileOperation* fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryOfExe();
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile.cfg";
m_multiAxisController = new IrisMultiMotorController(configFilePath);
}
catch (std::exception const& e)
{
QMessageBox msgBox;
msgBox.setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
msgBox.exec();
}
m_multiAxisController->moveToThread(&m_motorThread);
m_motorThread.start();
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(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
connect(this, SIGNAL(recordHyperSpecImgOneMotorSignal(int, double, double)), m_multiAxisController, SLOT(recordHyperSpecImgOneMotor(int, double, double)));
connect(m_multiAxisController, SIGNAL(startRecordLineSignal(int)), this, SIGNAL(startRecordLineSignal(int)));
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
emit testConnectivitySignal(0, 1000);
}
void OneMotorControl::display_x_loc(std::vector<double> loc)
{
double tmp = round(loc[0] * 100) / 100;
this->ui.realTimeLoc_lineEdit->setText(QString::number(tmp));
}
void OneMotorControl::display_motors_connectivity(std::vector<int> connectivity)
{
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
if (connectivity[0])
{
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
}
else
{
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
}
}
void OneMotorControl::zeroStart()
{
zeroStartSignal(0);
}
void OneMotorControl::onx_rangeMeasurement()
{
double s0 = ui.speed_lineEdit->text().toDouble();
emit rangeMeasurement(0, s0, 1000);
}
void OneMotorControl::onxMove2Loc()
{
double s = ui.speed_lineEdit->text().toDouble();
double l = ui.move2loc_lineEdit->text().toDouble();
emit move2LocSignal(0, l, s, 1000);
}
void OneMotorControl::onxMotorRight()
{
double s = ui.speed_lineEdit->text().toDouble();
emit moveSignal(0, false, s, 1000);
}
void OneMotorControl::onxMotorLeft()
{
double s = ui.speed_lineEdit->text().toDouble();
emit moveSignal(0, true, s, 1000);
}
void OneMotorControl::onxMotorStop()
{
emit stopSignal(0);
}
void OneMotorControl::moveMotorAndRecordHyperSpecImg(int updateIntervalMs)
{
double runSpeed = ui.speed_lineEdit->text().toDouble();
double returnSpeed = ui.return_speed_lineEdit->text().toDouble();
emit recordHyperSpecImgOneMotorSignal(updateIntervalMs, runSpeed, returnSpeed);
}
void OneMotorControl::moveMotor2StartPosAndStopRecord()
{
m_multiAxisController->cancelRecord();
}

53
HPPA/OneMotorControl.h Normal file
View File

@ -0,0 +1,53 @@
#pragma once
#include <QThread>
#include <QMessageBox>
#include "ui_oneMotorControl.h"
#include "IrisMultiMotorController.h"
#include "fileOperation.h"
class OneMotorControl : public QDialog
{
Q_OBJECT
public:
OneMotorControl(QWidget* parent = nullptr);
~OneMotorControl();
void moveMotorAndRecordHyperSpecImg(int updateIntervalMs);
void moveMotor2StartPosAndStopRecord();
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();
signals:
void moveSignal(int, bool, double, int);
void move2LocSignal(int, double, double, int);
void move2LocSignal(const std::vector<double>, const std::vector<double>, int);
void stopSignal(int);
void rangeMeasurement(int, double, int);
void zeroStartSignal(int);
void testConnectivitySignal(int, int);
void recordHyperSpecImgOneMotorSignal(int updateIntervalMs, double runSpeed, double returnSpeed);
void startRecordLineSignal(int);
private:
Ui::OneMotorControl_UI ui;
QThread m_motorThread;
IrisMultiMotorController* m_multiAxisController;
};

308
HPPA/PathPlan.cpp Normal file
View File

@ -0,0 +1,308 @@
#include "PathPlan.h"
#include <iostream>
#include <QMessageBox>
#include <QFileDialog>
#include <fileOperation.h>
PathPlan::PathPlan(VinceControl* xMotor, VinceControl* yMotor, QMotorDoubleSlider* xSlider, QMotorDoubleSlider* ySlider, QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
m_xMotor = xMotor;
m_yMotor = yMotor;
m_xSlider = xSlider;
m_ySlider = ySlider;
ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
ui.recordLine_tableWidget->setStyleSheet("selection-background-color:rgb(255,209,128)");//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
ui.recordLine_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>λ
//ui.recordLine_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ģʽ<C4A3><CABD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//QHeaderView* headerView = ui.recordLine_tableWidget->verticalHeader();
//headerView->setHidden(true);//ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>к<EFBFBD>
ui.recordLine_tableWidget->setColumnCount(2);
ui.recordLine_tableWidget->setHorizontalHeaderLabels(QStringList() << "yPosition" << "xMaxPosition");
connect(ui.addRecordLine_btn, SIGNAL(clicked()), this, SLOT(onAddRecordLine_btn()));
connect(ui.removeRecordLine_btn, SIGNAL(clicked()), this, SLOT(onRemoveRecordLine_btn()));
connect(ui.generateRecordLine_btn, SIGNAL(clicked()), this, SLOT(onGenerateRecordLine_btn()));
connect(ui.deleteRecordLine_btn, SIGNAL(clicked()), this, SLOT(onDeleteRecordLine_btn()));
connect(ui.saveRecordLine2File_btn, SIGNAL(clicked()), this, SLOT(onSaveRecordLine2File_btn()));
connect(ui.readRecordLineFile_btn, SIGNAL(clicked()), this, SLOT(onReadRecordLineFile_btn()));
}
PathPlan::~PathPlan()
{}
void PathPlan::setMotor(VinceControl* xMotor, VinceControl* yMotor)
{
m_xMotor = xMotor;
m_yMotor = yMotor;
}
QTableWidget* PathPlan::getRecordLineTableWidget()
{
return ui.recordLine_tableWidget;
}
void PathPlan::onAddRecordLine_btn()
{
//׼<><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ByteBack MotorState = m_yMotor->GetState();
double currentPosOfYmotor = m_ySlider->getDistanceFromPulse(MotorState.Location);
double maxRangeOfXmotro = m_xSlider->maximum();
//<2F><>ȡѡ<C8A1><D1A1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
int currentRow = ui.recordLine_tableWidget->currentRow();
std::cout << "currentRow<EFBFBD><EFBFBD>" << currentRow << std::endl;
QTableWidgetItem* Item1 = new QTableWidgetItem(QString::number(currentPosOfYmotor, 10, 2));
QTableWidgetItem* Item2 = new QTableWidgetItem(QString::number(maxRangeOfXmotro, 10, 2));
Item1->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
Item2->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
if (currentRow == -1)//<2F><>û<EFBFBD><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʱ
{
int RowCount = ui.recordLine_tableWidget->rowCount();//Returns the number of rows. <20><>1<EFBFBD><31>ʼ<EFBFBD><CABC>
ui.recordLine_tableWidget->insertRow(RowCount);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3>β<EFBFBD><CEB2>Ǵ<EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
ui.recordLine_tableWidget->setItem(RowCount, 0, Item1);
ui.recordLine_tableWidget->setItem(RowCount, 1, Item2);
}
else
{
ui.recordLine_tableWidget->insertRow(currentRow + 1);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3>β<EFBFBD><CEB2>Ǵ<EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
ui.recordLine_tableWidget->setItem(currentRow + 1, 0, Item1);
ui.recordLine_tableWidget->setItem(currentRow + 1, 1, Item2);
}
}
void PathPlan::onRemoveRecordLine_btn()
{
int rowIndex = ui.recordLine_tableWidget->currentRow();
if (rowIndex != -1)
ui.recordLine_tableWidget->removeRow(rowIndex);
}
void PathPlan::onGenerateRecordLine_btn()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double height = ui.height_lineEdit->text().toDouble();
double fov = ui.fov_lineEdit->text().toDouble();
double swath = (height * tan(fov / 2 * PI / 180)) * 2;//tan<61><6E><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD>
ui.swath_lineEdit->setText(QString::number(swath));
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
double xMotorRange = m_xSlider->maximum();
double yMotorRange = m_ySlider->maximum();
//ȷ<><C8B7><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC>ߣ<EFBFBD><DFA3><EFBFBD>ʽ<EFBFBD><CABD>numberOfRecordLine_tmp * swath - repetitiveLength<74><68>numberOfRecordLine_tmp - 1<><31> = overallLength
double overallLength = yMotorRange + swath;
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble() / 100;
double repetitiveLength = repetitiveRate * swath;
double offset = ui.offset_lineEdit->text().toDouble();
double numberOfRecordLine_tmp = (overallLength - repetitiveLength - offset) / (swath - repetitiveLength);
double tmp = numberOfRecordLine_tmp - (int)numberOfRecordLine_tmp;
int numberOfRecordLine;
double threshold = ui.LastLineThreshold_lineEdit->text().toDouble();//<2F><>numberOfRecordLine_tmpΪС<CEAA><D0A1>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
if (tmp > threshold)
{
numberOfRecordLine = (int)numberOfRecordLine_tmp + 1;
//std::cout << "<22><><EFBFBD>ڣ<EFBFBD>" << threshold << std::endl;
}
else
{
numberOfRecordLine = (int)numberOfRecordLine_tmp;
}
//ȥ<><C8A5>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
int rowCount = ui.recordLine_tableWidget->rowCount();
for (size_t i = 0; i < rowCount; i++)
{
ui.recordLine_tableWidget->removeRow(0);
}
//<2F><>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ɼ<EFBFBD><C9BC>ߣ<EFBFBD>
QTableWidgetItem* tmpItem;
for (size_t i = 0; i < numberOfRecordLine; i++)
{
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
int RowCount = ui.recordLine_tableWidget->rowCount();
ui.recordLine_tableWidget->insertRow(RowCount);
//<2F><><EFBFBD><EFBFBD>yPosition
if (tmp > threshold && i == numberOfRecordLine - 1)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>е<EFBFBD>yPosition
{
tmpItem = new QTableWidgetItem(QString::number(yMotorRange, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
}
else
{
double x = swath * i - i * repetitiveLength + offset;
tmpItem = new QTableWidgetItem(QString::number(x, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
}
//<2F><><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>λ<EFBFBD><CEBB> <20><> ֵ<><D6B5><EFBFBD><EFBFBD>Ϊx<CEAA><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
tmpItem = new QTableWidgetItem(QString::number(xMotorRange, 10, 2));
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, 1, tmpItem);
}
}
void PathPlan::onDeleteRecordLine_btn()
{
int rowCount = ui.recordLine_tableWidget->rowCount();
for (size_t i = 0; i < rowCount; i++)
{
ui.recordLine_tableWidget->removeRow(0);
}
}
void PathPlan::onSaveRecordLine2File_btn()
{
//ȷ<><C8B7><EFBFBD>ɼ<EFBFBD><C9BC>ߴ<EFBFBD><DFB4><EFBFBD>
if (ui.recordLine_tableWidget->rowCount() <= 0)
{
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ켣<EFBFBD><EFBFBD>"));
return;
}
double height = ui.height_lineEdit->text().toDouble();
double fov = ui.fov_lineEdit->text().toDouble();
double swath = ui.swath_lineEdit->text().toDouble();
double offset = ui.offset_lineEdit->text().toDouble();
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble();
double LastLineThreshold = ui.LastLineThreshold_lineEdit->text().toDouble();
FileOperation* fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryOfExe();
QString RecordLineFilePath = QFileDialog::getSaveFileName(this, tr("Save RecordLine File"),
QString::fromStdString(directory),
tr("RecordLineFile (*.RecordLine)"));
if (RecordLineFilePath.isEmpty())
{
return;
}
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "wb+");
fwrite(&height, sizeof(double), 1, RecordLineFileHandle);
fwrite(&fov, sizeof(double), 1, RecordLineFileHandle);
fwrite(&swath, sizeof(double), 1, RecordLineFileHandle);
fwrite(&offset, sizeof(double), 1, RecordLineFileHandle);
fwrite(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
fwrite(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
double number = ui.recordLine_tableWidget->rowCount() * ui.recordLine_tableWidget->columnCount();
fwrite(&number, sizeof(double), 1, RecordLineFileHandle);
double* data = new double[number];
//double data[number];
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
{
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
{
data[i * ui.recordLine_tableWidget->columnCount() + j] = ui.recordLine_tableWidget->item(i, j)->text().toDouble();
}
}
fwrite(data, sizeof(double), number, RecordLineFileHandle);
fclose(RecordLineFileHandle);
delete[] data;
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
}
void PathPlan::onReadRecordLineFile_btn()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
FileOperation* fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryOfExe();
//string RecordLineFilePath = directory + "\\test.RecordLine";
QString RecordLineFilePath = QFileDialog::getOpenFileName(this, tr("Open RecordLine File"),
QString::fromStdString(directory),
tr("RecordLineFile (*.RecordLine)"));
if (RecordLineFilePath.isEmpty())
{
return;
}
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "rb");
double height, fov, swath, offset, repetitiveRate, LastLineThreshold, number;
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
fread(&height, sizeof(double), 1, RecordLineFileHandle);
fread(&fov, sizeof(double), 1, RecordLineFileHandle);
fread(&swath, sizeof(double), 1, RecordLineFileHandle);
fread(&offset, sizeof(double), 1, RecordLineFileHandle);
fread(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
fread(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
fread(&number, sizeof(double), 1, RecordLineFileHandle);
double* data = new double[number];
for (size_t i = 0; i < number; i++)
{
fread(data + i, sizeof(double), 1, RecordLineFileHandle);
//std::cout << *(data + i) << std::endl;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д
ui.height_lineEdit->setText(QString::number(height));
ui.fov_lineEdit->setText(QString::number(fov));
ui.swath_lineEdit->setText(QString::number(swath));
ui.offset_lineEdit->setText(QString::number(offset));
ui.repetitiveRate_lineEdit->setText(QString::number(repetitiveRate));
ui.LastLineThreshold_lineEdit->setText(QString::number(LastLineThreshold));
//<2F><>tableWidget<65><74><EFBFBD>Ӳɼ<D3B2><C9BC><EFBFBD>
//<2F><>1<EFBFBD><31>ȥ<EFBFBD><C8A5>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
int rowCount = ui.recordLine_tableWidget->rowCount();
for (size_t i = 0; i < rowCount; i++)
{
ui.recordLine_tableWidget->removeRow(0);
}
//<2F><>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ɼ<EFBFBD><C9BC>ߣ<EFBFBD>
int RecordLineCount = number / ui.recordLine_tableWidget->columnCount();
for (size_t i = 0; i < RecordLineCount; i++)
{
ui.recordLine_tableWidget->insertRow(0);
}
//<2F><>3<EFBFBD><33><EFBFBD><EFBFBD>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
{
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
{
QTableWidgetItem* tmp = new QTableWidgetItem(QString::number(data[i * ui.recordLine_tableWidget->columnCount() + j], 10, 5));
tmp->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui.recordLine_tableWidget->setItem(i, j, tmp);
}
}
fclose(RecordLineFileHandle);
delete[] data;
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
}

37
HPPA/PathPlan.h Normal file
View File

@ -0,0 +1,37 @@
#pragma once
#include <QDialog>
#include "ui_PathPlan.h"
#include "vincecontrol.h"
#include <QMotorDoubleSlider.h>
#define PI 3.1415926
class PathPlan : public QDialog
{
Q_OBJECT
public:
PathPlan(VinceControl* xMotor, VinceControl* yMotor, QMotorDoubleSlider* xSlider, QMotorDoubleSlider* ySlider, QWidget* parent = nullptr);
~PathPlan();
void setMotor(VinceControl* xMotor, VinceControl* yMotor);
QTableWidget* getRecordLineTableWidget();
private:
Ui::PathPlanClass ui;
VinceControl* m_xMotor;
VinceControl* m_yMotor;
QMotorDoubleSlider* m_xSlider;
QMotorDoubleSlider* m_ySlider;
public Q_SLOTS:
void onAddRecordLine_btn();
void onRemoveRecordLine_btn();
void onGenerateRecordLine_btn();
void onDeleteRecordLine_btn();
void onSaveRecordLine2File_btn();
void onReadRecordLineFile_btn();
};

356
HPPA/PathPlan.ui Normal file
View File

@ -0,0 +1,356 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PathPlanClass</class>
<widget class="QDialog" name="PathPlanClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>566</width>
<height>273</height>
</rect>
</property>
<property name="windowTitle">
<string>PathPlan</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>108</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>高度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="height_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>100</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="generateRecordLine_btn">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>生成轨迹</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveRecordLine2File_btn">
<property name="text">
<string>保存轨迹</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>108</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>视场角</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fov_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>17.6</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteRecordLine_btn">
<property name="text">
<string>删除轨迹</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="readRecordLineFile_btn">
<property name="text">
<string>读取轨迹</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>108</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>偏移</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="offset_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>幅宽</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="swath_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addRecordLine_btn">
<property name="text">
<string>添加</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>108</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>重复率(%)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="repetitiveRate_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>阈值</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="LastLineThreshold_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0.7</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeRecordLine_btn">
<property name="text">
<string>移除</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QTableWidget" name="recordLine_tableWidget"/>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

55
HPPA/PowerControl.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "PowerControl.h"
PowerControl::PowerControl(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.lamp_power_open_btn, SIGNAL(clicked()), this, SLOT(onLampPowerOpen_btn()));
connect(ui.lamp_power_close_btn, SIGNAL(clicked()), this, SLOT(onLampPowerClose_btn()));
connect(ui.motor_power_open_btn, SIGNAL(clicked()), this, SLOT(onMotorPowerOpen_btn()));
connect(ui.motor_power_close_btn, SIGNAL(clicked()), this, SLOT(onMotorPowerClose_btn()));
}
PowerControl::~PowerControl()
{}
void PowerControl::getRequest(QString str)
{
QNetworkRequest request;
QNetworkAccessManager* naManager = new QNetworkAccessManager(this);
QMetaObject::Connection connRet = QObject::connect(naManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
Q_ASSERT(connRet);
request.setUrl(QUrl(str));
QNetworkReply* reply = naManager->get(request);
}
void PowerControl::onLampPowerOpen_btn()//onLampPowerOpen_btn
{
QString xx = "http://192.168.1.3/setshutter?Portname=3&Value=1";
getRequest(xx);
}
void PowerControl::onLampPowerClose_btn()//onLampPowerClose_btn
{
QString xx = "http://192.168.1.3/setshutter?Portname=3&Value=0";
getRequest(xx);
}
void PowerControl::onMotorPowerOpen_btn()
{
QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=1";
getRequest(xx);
emit powerOpened();
}
void PowerControl::onMotorPowerClose_btn()
{
QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=0";
getRequest(xx);
emit powerClosed();
}

33
HPPA/PowerControl.h Normal file
View File

@ -0,0 +1,33 @@
#pragma once
#include <QDialog>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include "ui_PowerControl.h"
class PowerControl : public QDialog
{
Q_OBJECT
public:
PowerControl(QWidget *parent = nullptr);
~PowerControl();
public Q_SLOTS:
void onLampPowerOpen_btn();
void onLampPowerClose_btn();
void onMotorPowerOpen_btn();
void onMotorPowerClose_btn();
signals:
void powerOpened();
void powerClosed();
private:
Ui::PowerControlClass ui;
void getRequest(QString str);
};

126
HPPA/PowerControl.ui Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PowerControlClass</class>
<widget class="QDialog" name="PowerControlClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>294</width>
<height>119</height>
</rect>
</property>
<property name="windowTitle">
<string>PowerControl</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<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>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>卤素灯</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="lamp_power_open_btn">
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="lamp_power_close_btn">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>马 达</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="motor_power_open_btn">
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="motor_power_close_btn">
<property name="text">
<string>关闭</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>42</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -9,24 +9,33 @@ QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pPa
setOrientation(Qt::Horizontal);
setFocusPolicy(Qt::NoFocus);
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile;
configfile.setConfigfilePath(HPPACfgFile);
if (!configfile.isConfigfileExist())
configfile.createConfigFile();
configfile.parseConfigfile();
float Lead_x;//<2F><><EFBFBD><EFBFBD>
float StepAnglemar_x;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float ScaleFactor_x;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int SubdivisionMultiples_x;//ϸ<><CFB8><EFBFBD><EFBFBD>
configfile.getXMotorParm(StepAnglemar_x, Lead_x, SubdivisionMultiples_x, ScaleFactor_x);
m_Multiplier = 0;
}
void QMotorDoubleSlider::setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam)
{
//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
//m_Multiplier(0.00054496986),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD>޸<EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD>׼ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
//m_Multiplier(0.00054496986)//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
m_Multiplier = Lead_x / (360 / StepAnglemar_x * SubdivisionMultiples_x) * ScaleFactor_x;
m_Multiplier = lead / (360 / stepAnglemar * getValidSubdivision(subdivisionParam)) * scaleFactor;
}
int QMotorDoubleSlider::getValidSubdivision(int subdivisionParam)
{
if (subdivisionParam == 2)
return 4;
else if (subdivisionParam == 3)
return 8;
else if (subdivisionParam == 4)
return 16;
else if (subdivisionParam == 5)
return 32;
else if (subdivisionParam == 6)
return 64;
else if (subdivisionParam == 7)
return 128;
else if (subdivisionParam == 8)
return 256;
}
//<2F><><EFBFBD><EFBFBD><E2B7A2>

View File

@ -12,8 +12,10 @@ class QMotorDoubleSlider : public QSlider
public:
QMotorDoubleSlider(QWidget* pParent = NULL);
void setMultiplier(float lead, float stepAnglemar, float scaleFactor, int subdivisionParam);
int getValidSubdivision(int subdivisionParam);
double m_Multiplier;
double m_Multiplier;//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
void setRange(double Min, double Max);
void setMinimum(double Min);
@ -25,17 +27,15 @@ public:
long getPositionPulse(double position);//<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
double getDistanceFromPulse(int pulse);
public slots:
public slots:
void notifyValueChanged(int value);//<2F>ź<EFBFBD>valueChanged(int)<29><>wrap
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
private slots:
signals :
signals:
void valueChanged(double Value);
void rangeChanged(double Min, double Max);
private:
};
#endif
#endif

View File

@ -1,101 +0,0 @@
#include "stdafx.h"
#include "QYMotorDoubleSlider.h"
QYMotorDoubleSlider::QYMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
{
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
setSingleStep(1);
setOrientation(Qt::Horizontal);
setFocusPolicy(Qt::NoFocus);
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile;
configfile.setConfigfilePath(HPPACfgFile);
if (!configfile.isConfigfileExist())
configfile.createConfigFile();
configfile.parseConfigfile();
float StepAnglemar_y;
float Lead_y;
float ScaleFactor_y;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int SubdivisionMultiples_y;
configfile.getYMotorParm(StepAnglemar_y, Lead_y, SubdivisionMultiples_y, ScaleFactor_y);
//m_Multiplier(0.000108993972),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD>޸<EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD>׼ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
//m_Multiplier(0.000108993972)//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
m_Multiplier = Lead_y / (360 / StepAnglemar_y * SubdivisionMultiples_y) * ScaleFactor_y;
}
//<2F><><EFBFBD><EFBFBD><E2B7A2>
void QYMotorDoubleSlider::notifyValueChanged(int Value)
{
emit valueChanged((double)Value * m_Multiplier);//////////
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void QYMotorDoubleSlider::setValue(double Value, bool BlockSignals)
{
QSlider::blockSignals(BlockSignals);
QSlider::setValue(Value / m_Multiplier);////////////
if (!BlockSignals)
emit valueChanged(Value);
QSlider::blockSignals(false);
}
void QYMotorDoubleSlider::setRange(double Min, double Max)
{
QSlider::setRange(Min / m_Multiplier, Max / m_Multiplier);//////
emit rangeChanged(Min, Max);
}
void QYMotorDoubleSlider::setMinimum(double Min)
{
QSlider::setMinimum(Min / m_Multiplier);//////
emit rangeChanged(minimum(), maximum());
}
double QYMotorDoubleSlider::minimum() const
{
return QSlider::minimum() * m_Multiplier;/////
}
void QYMotorDoubleSlider::setMaximum(double Max)
{
QSlider::setMaximum(Max / m_Multiplier);//////
emit rangeChanged(minimum(), maximum());
}
double QYMotorDoubleSlider::maximum() const
{
return QSlider::maximum() * m_Multiplier;///////
}
double QYMotorDoubleSlider::value() const
{
int Value = QSlider::value();
return (double)Value * m_Multiplier;//////
}
double QYMotorDoubleSlider::OriginalValue() const
{
int Value = QSlider::value();
return (double)Value;
}
long QYMotorDoubleSlider::getPositionPulse(double position)
{
return position / m_Multiplier;
}
double QYMotorDoubleSlider::getDistanceFromPulse(int pulse)
{
return pulse * m_Multiplier;
}

View File

@ -1,41 +0,0 @@
#ifndef Q_YMOTOR_DOUBLE_SLIDER_H
#define Q_YMOTOR_DOUBLE_SLIDER_H
#include <QtGui/QtGui>
#include <QSlider>
#include "hppaConfigFile.h"
#include "path_tc.h"
class QYMotorDoubleSlider : public QSlider//QYMotorDoubleSlider
{
Q_OBJECT
public:
QYMotorDoubleSlider(QWidget* pParent = NULL);
double m_Multiplier;//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
void setRange(double Min, double Max);
void setMinimum(double Min);
double minimum() const;
void setMaximum(double Max);
double maximum() const;
double value() const;
double OriginalValue() const;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫʵ<D2AA>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>
long getPositionPulse(double position);//<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EBB7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
double getDistanceFromPulse(int pulse);
public slots:
void notifyValueChanged(int value);//<2F>ź<EFBFBD>valueChanged(int)<29><>wrap
void setValue(double Value, bool BlockSignals = true);//QSlider::setValue<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wrap
private slots:
signals :
void valueChanged(double Value);
void rangeChanged(double Min, double Max);
private:
};
#endif

418
HPPA/ResononNirImager.cpp Normal file
View File

@ -0,0 +1,418 @@
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <exception>
#include "ResononNirImager.h"
ResononNirImager::ResononNirImager()
{
}
ResononNirImager::~ResononNirImager()
{
if (buffer != nullptr)
{
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
free(buffer);
free(dark);
free(white);
}
}
void ResononNirImager::reConnectImage()
{
disconnectImager();
connectImager();
}
double ResononNirImager::getFramerate()
{
return m_ResononNirImager.get_framerate();
}
double ResononNirImager::getIntegrationTime()
{
return m_ResononNirImager.get_integration_time();
}
double ResononNirImager::getGain()
{
//return m_ResononNirImager.get_gain();
return 0.0;//nir<69><72>֧<EFBFBD><D6A7>gian
}
void ResononNirImager::setGain(const double gain)
{
//m_ResononNirImager.set_gain(gain);//nir<69><72>֧<EFBFBD><D6A7>gian
}
void ResononNirImager::setFramerate(const double frames_per_second)
{
m_ResononNirImager.set_framerate(frames_per_second);
m_RgbImage->m_iFramerate = frames_per_second;
}
void ResononNirImager::setIntegrationTime(const double milliseconds)
{
m_ResononNirImager.set_integration_time(milliseconds);
}
int ResononNirImager::getStartBand()
{
return m_ResononNirImager.get_start_band();
}
int ResononNirImager::getEndBand()
{
return m_ResononNirImager.get_end_band();
}
void ResononNirImager::connectImager(const char* camera_sn)
{
m_ResononNirImager.connect();
}
void ResononNirImager::disconnectImager()
{
m_ResononNirImager.disconnect();
}
void ResononNirImager::imagerStartCollect()
{
m_ResononNirImager.start();
}
void ResononNirImager::imagerStopCollect()
{
m_ResononNirImager.stop();
}
unsigned short* ResononNirImager::getFrame(unsigned short* buffer)
{
m_ResononNirImager.get_frame(buffer);
return buffer;
}
void ResononNirImager::setSpectraBin(int new_spectral_bin)
{
}
double ResononNirImager::auto_exposure()
{
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<C7B0><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double x = 1 / getFramerate() * 1000;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
reConnectImage();
setIntegrationTime(x);
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ѭ<EFBFBD><D1AD>Ѱ<EFBFBD><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
imagerStartCollect();
while (true)
{
getFrame(buffer);
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
{
setIntegrationTime(getIntegrationTime() * 0.8);
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
}
else
{
break;
}
}
reConnectImage();
//imagerStopCollect();
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << getIntegrationTime() << std::endl;
return getIntegrationTime();
}
double ResononNirImager::getWavelengthAtBand(int band)
{
return m_ResononNirImager.get_wavelength_at_band(band);
}
int ResononNirImager::getBandCount()
{
return m_ResononNirImager.get_band_count();
}
int ResononNirImager::getSampleCount()
{
return m_ResononNirImager.get_sample_count();
}
void ResononNirImager::focus()
{
m_iFocusFrameCounter = 1;
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
double tmpFrmerate = getFramerate();
double tmpIntegrationTime = getIntegrationTime();
setFramerate(5);
auto_exposure();
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
reConnectImage();
imagerStartCollect();
//emit SpectralSignal(1);
m_bFocusControlState = true;
while (m_bFocusControlState)
{
getFrame(buffer);
//m_RgbImage->FillFocusGrayImage(buffer);
m_RgbImage->FillFocusGrayQImage(buffer);
emit SpectralSignal(1);
++m_iFocusFrameCounter;
}
emit SpectralSignal(0);
imagerStopCollect();
reConnectImage();
setIntegrationTime(tmpIntegrationTime);
setFramerate(tmpFrmerate);//<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFA3AC><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
void ResononNirImager::record_dark()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
reConnectImage();
imagerStartCollect();
unsigned int* dark_tmp = new unsigned int[m_FrameSize];
std::fill(dark_tmp, dark_tmp + m_FrameSize, 0);
int counter = 50;
for (size_t i = 0; i < counter; i++)
{
getFrame(dark);
for (size_t j = 0; j < m_FrameSize; j++)
{
dark_tmp[j] = dark[j] + dark_tmp[j];
}
}
for (size_t j = 0; j < m_FrameSize; j++)
{
dark[j] = (unsigned short)(dark_tmp[j] / counter);
}
delete[] dark_tmp;
imagerStopCollect();
m_HasDark = true;
emit RecordDarlFinishSignal();
}
void ResononNirImager::record_white()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
reConnectImage();
imagerStartCollect();
unsigned int* white_tmp = new unsigned int[m_FrameSize];
std::fill(white_tmp, white_tmp + m_FrameSize, 0);
int counter = 50;
for (size_t i = 0; i < counter; i++)
{
getFrame(white);
for (size_t j = 0; j < m_FrameSize; j++)
{
white_tmp[j] = white[j] + white_tmp[j];
}
}
for (size_t j = 0; j < m_FrameSize; j++)
{
white[j] = (unsigned short)(white_tmp[j] / counter);
}
delete[] white_tmp;
imagerStopCollect();
//<2F>װ<EFBFBD><D7B0>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD>
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
if (white[i] < dark[i])
{
white[i] = 0;
}
else
{
white[i] = white[i] - dark[i];
}
}
}
m_HasWhite = true;
emit RecordWhiteFinishSignal();
}
void ResononNirImager::start_record()
{
using namespace std;
//std::cout << "------------------------------------------------------" << std::endl;
m_iFrameCounter = 0;
m_RgbImage->m_iFrameCounter = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<62><CDBC><EFBFBD>ĵ<EFBFBD>0<EFBFBD><30>
m_bRecordControlState = true;
//<2F>ж<EFBFBD><D0B6>ڴ<EFBFBD>buffer<65>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (buffer == 0)
{
std::cerr << "Error: memory could not be allocated for datacube";
exit(EXIT_FAILURE);
}
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
size_t x;
double pixelValueTmp;
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
reConnectImage();//nir<69>ڶ<EFBFBD><DAB6>βɼ<CEB2>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>imagerStartCollect()<29><EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
imagerStartCollect();
while (m_bRecordControlState)
{
m_iFrameCounter++;
getFrame(buffer);
long long timeOs = getNanosecondsSinceMidnight();
//qDebug() << "time ns-------------------: " << timeOs;
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
if (buffer[i] < dark[i])
{
buffer[i] = 0;
}
else
{
buffer[i] = buffer[i] - dark[i];
}
}
}
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (m_HasWhite)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (white[i] != 0)
{
pixelValueTmp = buffer[i];
buffer[i] = (pixelValueTmp / white[i]) * 10000;
}
else
{
buffer[i] = 0;
}
}
}
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
fprintf(hTimesFile, "%lld\n", timeOs);
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
//std::cout << "<22><>" << m_iFrameCounter << "֡д<D6A1><D0B4>" << x << "<22><>unsigned short<72><74>" << std::endl;
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
if (m_iFrameCounter % (int)getFramerate() == 0)
{
emit PlotSignal(m_iFrameCounter);
}
if (m_iFrameCounter >= m_iFrameNumber)
{
break;
//qDebug() << "<22><><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>";
}
}
imagerStopCollect();
m_bRecordControlState = false;
WriteHdr();
m_FileSavedCounter++;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//m_RgbImage
emit PlotSignal(-1);//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
if (m_iFrameCounter >= m_iFrameNumber)
{
emit RecordFinishedSignal_WhenFrameNumberMeet();
}
else
{
emit RecordFinishedSignal_WhenFrameNumberNotMeet();
}
//QThread::msleep(1001);
fclose(m_fImage);
fclose(hTimesFile);
}
void ResononNirImager::WriteHdr()
{
//write an ENVI compatible header file
using namespace std;
string hdrPath = removeFileExtension(m_FileName2Save2) + ".hdr";
std::ofstream outfile(hdrPath.c_str());
outfile << "ENVI\n";
outfile << "interleave = bil\n";
outfile << "data type = 12\n";
outfile << "bit depth = 12\n";
outfile << "samples = " << getSampleCount() << "\n";
outfile << "bands = " << getBandCount() << "\n";
outfile << "lines = " << m_iFrameCounter << "\n";
outfile << "framerate = " << getFramerate() << "\n";
outfile << "shutter = " << getIntegrationTime() << "\n";
outfile << "gain = " << getGain() << "\n";
outfile << "wavelength = {";
outfile << std::setprecision(5);
int num_bands = getBandCount();
for (int i = 0; i < num_bands - 1; i++)
{
outfile << getWavelengthAtBand(i) << ", ";
}
outfile << getWavelengthAtBand(num_bands - 1) << "}\n";
outfile.close();
}

53
HPPA/ResononNirImager.h Normal file
View File

@ -0,0 +1,53 @@
#pragma once
#include <string>
#include <opencv2/core/core.hpp>
#include "ImagerOperationBase.h"
#include "resonon_imager_allied.h"
#include "image2display.h"
#include "fileOperation.h"
#include "utility_tc.h"
class ResononNirImager :public ImagerOperationBase
{
public:
ResononNirImager();
~ResononNirImager();
Resonon::PikaAllied m_ResononNirImager;//
double getWavelengthAtBand(int band);
int getBandCount();
int getSampleCount();
double getFramerate();
double getIntegrationTime();
double getGain();
void setFramerate(const double frames_per_second);
void setIntegrationTime(const double milliseconds);
void setGain(const double gain);
int getStartBand();
int getEndBand();
void connectImager(const char* camera_sn = NULL);
void disconnectImager();
void imagerStartCollect();
void imagerStopCollect();
unsigned short* getFrame(unsigned short* buffer);
void setSpectraBin(int new_spectral_bin);
void WriteHdr();
protected:
private:
void reConnectImage();
public slots:
double auto_exposure();
void focus();
void record_dark();
void record_white();
void start_record();
signals:
};

639
HPPA/RobotArmControl.cpp Normal file
View File

@ -0,0 +1,639 @@
#include "RobotArmControl.h"
RobotArmControl::RobotArmControl(QWidget* parent): QDialog(parent)
{
ui.setupUi(this);
robotController = new RobotController(this);
connect(ui.get_task_list_btn, SIGNAL(clicked()), this, SLOT(getTaskList()));
connect(ui.get_pose_btn, SIGNAL(clicked()), this, SLOT(getPose()));
connect(ui.connect2arm_btn, SIGNAL(clicked()), this, SLOT(connectRobotArm()));
connect(ui.execute_task_btn, SIGNAL(clicked()), this, SLOT(executeTaskWithoutHyperImager()));
connect(ui.pause_task_btn, SIGNAL(clicked()), this, SLOT(pauseTask()));
connect(ui.continue_task_btn, SIGNAL(clicked()), this, SLOT(continueTask()));
robotMonitor = new EC8056;
connect(robotMonitor, &EC8056::dataReceived, this, &RobotArmControl::monitorRobotArm);
m_pModel = new QStringListModel(ui.taskList_listView);
ui.taskList_listView->setModel(m_pModel);
}
RobotArmControl::~RobotArmControl()
{
}
void RobotArmControl::monitorRobotArm(const ECData& data)
{
double x = data.machinePose[0];
double y = data.machinePose[1];
double z = data.machinePose[2];
ui.pose_x_label->setText(QString::number(x));
ui.pose_y_label->setText(QString::number(y));
ui.pose_z_label->setText(QString::number(z));
}
void RobotArmControl::onCommandResponse(QString str, const QJsonObject& response)
{
//qDebug() << "response:" << response;
QString re;
if (response.contains("result"))
{
re = response["result"].toVariant().toString();
ui.textEdit->append(str + " Result: " + re);
}
else if (response.contains("error"))
{
//auto delete11 = response["error"].toObject();
//qDebug() << "response[\"error\"]:" << delete11;
auto errorStr = response["error"].toObject()["message"].toString();
ui.textEdit->append(str + " Error: " + errorStr);
}
}
void RobotArmControl::getTaskList()
{
FileOperation* fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryOfExe();
QString pythonScript = QString::fromStdString(directory) + "\\get_jbi_filename.py";
QProcess process;
process.start("python.exe", QStringList() << pythonScript);
process.waitForFinished();
QString output = process.readAllStandardOutput();
QStringList files;
//files.append("tc20250324down.jbi");
//files.append("tc20250324circle.jbi");
//files.append("tc20250324side.jbi");
QStringList lines = output.split('\n', QString::SkipEmptyParts);
for (const QString& line : lines)
{
files.append(line.trimmed());
}
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//for (size_t i = 0; i < files.length(); i++)
//{
// int row = m_pModel->rowCount();
// m_pModel->insertRow(row);
// QModelIndex index = m_pModel->index(row);
// m_pModel->setData(index, files[i]);
//}
m_pModel->setStringList(files);
}
void RobotArmControl::getPose()
{
QJsonObject response;
bool x = robotController->getRobotPose(response);
onCommandResponse("getPose", response);
}
void RobotArmControl::connectRobotArm()
{
bool re = robotController->connectToRobot("192.168.1.100");
robotMonitor->connectToHost("192.168.1.100");
}
void RobotArmControl::executeTaskWithHyperImager()
{
QModelIndex index = ui.taskList_listView->currentIndex();
if (-1 == index.row())
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>
ui.textEdit->append("Please select file on the left!");
return;
}
QString fileName = index.data(Qt::DisplayRole).toString();
QJsonObject response;
bool x;
x = robotController->checkJbiExist(fileName, response);
onCommandResponse("checkJbiExist", response);
if (!x)
{
return;
}
x = robotController->setServoStatus(1, response);
onCommandResponse("setServoStatus", response);
if (!x)
{
return;
}
x = robotController->runJbi(fileName, response, true);
onCommandResponse("runJbi", response);
if (!x)
{
return;
}
}
void RobotArmControl::executeTaskWithoutHyperImager()
{
QModelIndex index = ui.taskList_listView->currentIndex();
if (-1 == index.row())
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>
ui.textEdit->append("Please select file on the left!");
return;
}
QString fileName = index.data(Qt::DisplayRole).toString();
QJsonObject response;
bool x;
x = robotController->checkJbiExist(fileName, response);
onCommandResponse("checkJbiExist", response);
if (!x)
{
return;
}
x = robotController->setServoStatus(1, response);
onCommandResponse("setServoStatus", response);
if (!x)
{
return;
}
x = robotController->runJbi(fileName, response, false);
onCommandResponse("runJbi", response);
if (!x)
{
return;
}
}
void RobotArmControl::pauseTask()
{
QJsonObject response;
bool x;
x = robotController->pauseTask(response);
onCommandResponse("pauseTask", response);
}
void RobotArmControl::continueTask()
{
QJsonObject response;
bool x;
x = robotController->continueTask(response);
onCommandResponse("continueTask", response);
}
RobotController::RobotController(QObject* parent) : QObject(parent), socket(new QTcpSocket(this))
{
//connect(socket, &QTcpSocket::readyRead, this, &RobotController::onReadyRead);
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(getPoint()));
}
RobotController::~RobotController()
{
disconnectFromRobot();
}
bool RobotController::connectToRobot(const QString& ip, quint16 port)
{
socket->setProxy(QNetworkProxy::NoProxy);
socket->connectToHost(ip, port);
if (!socket->waitForConnected(3000)) {
qDebug() << "Connection failed:" << socket->errorString();
return false;
}
qDebug() << "Connected successfully!";
return true;
}
void RobotController::disconnectFromRobot()
{
if (socket->isOpen())
{
socket->close();
}
}
bool RobotController::processResponse(QJsonObject response, QString& result)
{
//qDebug() << "response:" << response;
if (response.contains("result"))
{
result = response["result"].toVariant().toString();
//qDebug() << "result1:" << result;
return true;
}
else if (response.contains("error"))
{
result = response["error"].toObject()["message"].toString();
//qDebug() << "result2:" << result;
return false;
}
}
bool RobotController::processResponse_getJbiState(QJsonObject response, QString& result)
{
//qDebug() << "response:" << response;
if (response.contains("result"))
{
QString resultStr = response["result"].toString();
QJsonDocument resultDoc = QJsonDocument::fromJson(resultStr.toUtf8());
QJsonObject resultObj = resultDoc.object();
//qDebug() << "resultObj:" << resultObj;
int runState = resultObj["runState"].toInt();
//qDebug() << "runState:" << runState;
result = QString::number(runState);
//qDebug() << "result:" << result;
return true;
}
else if (response.contains("error"))
{
result = response["error"].toObject()["message"].toString();
return false;
}
}
void RobotController::getPoint()
{
QJsonObject response;
getJbiState(response);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
QString result;
bool x = processResponse_getJbiState(response, result);
//qDebug() << "getJbiState:" << result;
if (result.toInt() != 3)
{
m_timer->stop();
m_iCurrentJbiJobLine = 0;
m_iFileCounter = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
emit hsiRecordSignal(-1);
return;
}
QJsonObject response2;
getCurrentJobLine(response2);
QString result2;
bool x2 = processResponse(response2, result2);
int m_iCurrentJbiJobLine_tmp = result2.toInt();
if (m_iCurrentJbiJobLine_tmp != m_iCurrentJbiJobLine)
{
m_iFileCounter++;
qDebug() << "Changed! CurrentJobLine:" << m_iCurrentJbiJobLine_tmp;
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
emit hsiRecordSignal(-1);
m_iCurrentJbiJobLine = m_iCurrentJbiJobLine_tmp;
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD>
emit hsiRecordSignal(m_iFileCounter);
}
}
void RobotController::sendCommand(const QString& cmd, const QJsonValue& params, int id)
{
QJsonObject request;
request["method"] = cmd;
request["params"] = params;
request["jsonrpc"] = "2.0";
request["id"] = id;
QJsonDocument doc(request);
QByteArray data = doc.toJson(QJsonDocument::Compact) + "\n";
//qDebug() << "send command:" << data.constData();
socket->write(data);
socket->waitForBytesWritten();
}
bool RobotController::onReadyRead(QJsonObject& re)
{
QByteArray data = socket->readAll();
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull() && doc.isObject())
{
re = doc.object();
//qDebug() << "Received all:" << re;
if (re.contains("result"))
{
//qDebug() << "Received result:" << re["result"].toVariant();
return true;
}
else if (re.contains("error"))
{
//qDebug() << "Received error:" << re["error"];
return false;
}
//emit commandResponse(true, doc.object());
}
else
{
//emit commandResponse(false, QJsonObject());
re = QJsonObject();
return false;
}
}
bool RobotController::getRobotPose(QJsonObject& re)
{
sendCommand("getRobotPose");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::getRobotState(QJsonObject& re)
{
sendCommand("getRobotState");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::getJbiState(QJsonObject& re)
{
sendCommand("getJbiState");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::getCurrentJobLine(QJsonObject& re)
{
sendCommand("getCurrentJobLine");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::getRobotMode(QJsonObject& re)
{
sendCommand("getRobotMode");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
{
QJsonObject paramsRunJbi;
paramsRunJbi["filename"] = jbiFilename;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>
sendCommand("checkJbiExist", paramsRunJbi);
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::setServoStatus(int status, QJsonObject& re)
{
QJsonObject params_set_servo_status;
params_set_servo_status["status"] = status;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>
sendCommand("set_servo_status", params_set_servo_status);
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi)
{
QJsonObject paramsRunJbi;
paramsRunJbi["filename"] = jbiFilename;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>
sendCommand("runJbi", paramsRunJbi);
socket->waitForReadyRead(m_iTimeout);
if (isRecordHsi)
{
m_timer->start(1000);
}
return onReadyRead(re);
}
bool RobotController::pauseTask(QJsonObject& re)
{
sendCommand("pause");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::run(QJsonObject& re)
{
sendCommand("run");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::continueTask(QJsonObject& re)
{
sendCommand("run");
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
bool RobotController::setRobotPowerStatus(int status, QJsonObject& re)
{
sendCommand("set_robot_power_status", QJsonArray{ status });
socket->waitForReadyRead(m_iTimeout);
return onReadyRead(re);
}
EC8056::EC8056(QObject* parent) : QObject(parent), socket(new QTcpSocket(this))
{
connect(socket, &QTcpSocket::readyRead, this, &EC8056::onReadyRead);
/*connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::errorOccurred),
this, &EC8056::onSocketError);*/
//connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
// this, SLOT(onSocketError(QAbstractSocket::SocketError)));
}
void EC8056::connectToHost(const QString& host, quint16 port)
{
socket->setProxy(QNetworkProxy::NoProxy);
socket->connectToHost(QHostAddress(host), port);
if (!socket->waitForConnected(3000)) {
qDebug() << "Connection failed:" << socket->errorString();
return;
}
qDebug() << "Connected successfully!";
}
quint8 EC8056::readUInt8(const QByteArray& buf, int& offset)
{
return static_cast<quint8>(buf[offset++]);
}
quint32 EC8056::readUInt32(const QByteArray& buf, int& offset)
{
quint32 val;
memcpy(&val, buf.constData() + offset, sizeof(val));
offset += sizeof(val);
return qFromBigEndian(val);
}
qint32 EC8056::readInt32(const QByteArray& buf, int& offset)
{
qint32 val;
memcpy(&val, buf.constData() + offset, sizeof(val));
offset += sizeof(val);
return qFromBigEndian(val);
}
quint64 EC8056::readUInt64(const QByteArray& buf, int& offset)
{
quint64 val;
memcpy(&val, buf.constData() + offset, sizeof(val));
offset += sizeof(val);
return qFromBigEndian(val);
}
double EC8056::readDouble(const QByteArray& buf, int& offset)
{
QByteArray b = buf.mid(offset, sizeof(double));
offset += sizeof(double);
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)
std::reverse(b.begin(), b.end());
double val;
memcpy(&val, b.constData(), sizeof(double));
return val;
}
void EC8056::onReadyRead()
{
buffer.append(socket->readAll());
if (buffer.size() < 1024)
return;
int offset = 0;
ECData data;
data.msgSize = readUInt32(buffer, offset);
offset = 1020;
data.matchingWord = readUInt32(buffer, offset);
if ((data.msgSize == 1024)/* && (data.matchingWord == 3967833836)*/)
{
offset = 0;
data.msgSize = readUInt32(buffer, offset);
data.timeStamp = readUInt64(buffer, offset);
data.auto_cycle = readUInt8(buffer, offset);
for (int i = 0; i < 8; ++i) data.machinePos[i] = readDouble(buffer, offset);
for (int i = 0; i < 6; ++i) data.machinePose[i] = readDouble(buffer, offset);
for (int i = 0; i < 6; ++i) data.machineUserPose[i] = readDouble(buffer, offset);
for (int i = 0; i < 8; ++i) data.torque[i] = readDouble(buffer, offset);
data.robotState = readUInt32(buffer, offset);
data.servoReady = readUInt32(buffer, offset);
data.can_motor_run = readUInt32(buffer, offset);
for (int i = 0; i < 8; ++i) data.motor_speed[i] = readInt32(buffer, offset);
data.robotMode = readUInt32(buffer, offset);
for (int i = 0; i < 3; ++i) data.analog_ioInput[i] = readDouble(buffer, offset);
for (int i = 0; i < 5; ++i) data.analog_ioOutput[i] = readDouble(buffer, offset);
data.digital_ioInput = readUInt64(buffer, offset);
data.digital_ioOutput = readUInt64(buffer, offset);
data.collision = readUInt8(buffer, offset);
for (int i = 0; i < 6; ++i) data.machineFlangePose[i] = readDouble(buffer, offset);
for (int i = 0; i < 6; ++i) data.machineUserFlangePose[i] = readDouble(buffer, offset);
data.emergencyStopState = readUInt8(buffer, offset);
data.tcpSpeed = readDouble(buffer, offset);
for (int i = 0; i < 8; ++i) data.joIntSpeed[i] = readDouble(buffer, offset);
data.tcpAcc = readDouble(buffer, offset);
for (int i = 0; i < 8; ++i) data.joIntAcc[i] = readDouble(buffer, offset);
for (int i = 0; i < 6; ++i) data.joIntTemperature[i] = readDouble(buffer, offset);
for (int i = 0; i < 6; ++i) data.joIntTorque[i] = readDouble(buffer, offset);
for (int i = 0; i < 6; ++i) data.extJoIntTorques[i] = readDouble(buffer, offset);
for (int i = 0; i < 6; ++i) data.exTcpForceIntool[i] = readDouble(buffer, offset);
data.dragState = readUInt8(buffer, offset);
data.sensor_connected_state = readUInt8(buffer, offset);
data.reserved = readUInt8(buffer, offset);
data.matchingWord = readUInt32(buffer, offset);
/*if (data.msgSize != 1024 || data.matchingWord != 0xec8056ec) {
buffer.clear();
emit errorOccurred("Invalid packet received");
return;
}*/
emit dataReceived(data);
}
buffer.clear();
}
void EC8056::onSocketError(QAbstractSocket::SocketError socketError)
{
Q_UNUSED(socketError)
emit errorOccurred(socket->errorString());
}

164
HPPA/RobotArmControl.h Normal file
View File

@ -0,0 +1,164 @@
#pragma once
#include <qdialog.h>
#include <QTcpSocket>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QDebug>
#include <QThread>
#include <QNetworkProxy>
#include <QtEndian>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QAuthenticator>
#include <QDebug>
#include <QRegularExpression>
#include <QProcess>
#include <QStringListModel>
#include <QTimer>
#include "ui_RobotArmControl.h"
#include "fileOperation.h"
struct ECData
{
quint32 msgSize;
quint64 timeStamp;
quint8 auto_cycle;
double machinePos[8];//<2F>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD>
double machinePose[6];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double machineUserPose[6];//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
double torque[8];//<2F>ؽڶ<DAB6><EEB6A8><EFBFBD>ذٷֱ<D9B7>
quint32 robotState;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
quint32 servoReady;//<2F>ŷ<EFBFBD>ʹ<EFBFBD><CAB9>״̬
quint32 can_motor_run;//ͬ<><CDAC>״̬
qint32 motor_speed[8];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
quint32 robotMode;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
double analog_ioInput[3];//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double analog_ioOutput[5];//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
quint64 digital_ioInput;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<DDB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
quint64 digital_ioOutput;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<DDB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
quint8 collision;//<2F><>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>״̬
double machineFlangePose[6];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<C2B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
double machineUserFlangePose[6];//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<C2B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
quint8 emergencyStopState;//<2F><>ǰ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڼ<EFBFBD>ͣ״̬
double tcpSpeed;//tcp<63>˶<EFBFBD><CBB6>ٶ<EFBFBD>
double joIntSpeed[8];//<2F>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>¸<EFBFBD><C2B8>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>ٶ<EFBFBD>
double tcpAcc;//tcp<63><70><EFBFBD>ٶ<EFBFBD>
double joIntAcc[8];//<2F>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>¸<EFBFBD><C2B8>ؽڼ<D8BD><DABC>ٶ<EFBFBD>
double joIntTemperature[6];//<2F><EFBFBD>
double joIntTorque[6];//<2F><><EFBFBD><EFBFBD>Ť<EFBFBD><C5A4>
double extJoIntTorques[6];//<2F>ⲿ<EFBFBD>ؽ<EFBFBD>Ť<EFBFBD><C5A4>ֵ
double exTcpForceIntool[6];//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µ<EFBFBD><C2B5>ⲿĩ<E2B2BF><C4A9><EFBFBD><EFBFBD>/<2F><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>ֵ
quint8 dragState;//<2F>϶<EFBFBD>ʹ<EFBFBD><CAB9>״̬
quint8 sensor_connected_state;//<2F><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
quint8 reserved;
quint32 matchingWord;
};
class EC8056 : public QObject
{
Q_OBJECT
public:
explicit EC8056(QObject* parent = nullptr);
void connectToHost(const QString& host, quint16 port= 8056);
signals:
void dataReceived(const ECData& data);
void errorOccurred(const QString& error);
private slots:
void onReadyRead();
void onSocketError(QAbstractSocket::SocketError socketError);
private:
QTcpSocket* socket;
QByteArray buffer;
double readDouble(const QByteArray& buf, int& offset);
quint64 readUInt64(const QByteArray& buf, int& offset);
quint32 readUInt32(const QByteArray& buf, int& offset);
qint32 readInt32(const QByteArray& buf, int& offset);
quint8 readUInt8(const QByteArray& buf, int& offset);
};
class RobotController : public QObject
{
Q_OBJECT
public:
explicit RobotController(QObject* parent = nullptr);
~RobotController();
bool connectToRobot(const QString& ip, quint16 port = 8055);
void disconnectFromRobot();
void sendCommand(const QString& cmd, const QJsonValue& params = QJsonArray(), int id = 1);
bool processResponse(QJsonObject response, QString& re);
bool processResponse_getJbiState(QJsonObject response, QString& result);
bool getRobotPose(QJsonObject& re);
bool getRobotState(QJsonObject& re);//ֹͣ״̬ 0<><30><EFBFBD><EFBFBD>ͣ״̬ 1<><31><EFBFBD><EFBFBD>ͣ״̬ 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 4<><34><EFBFBD><EFBFBD>ײ״̬ 5
bool getJbiState(QJsonObject& re);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
bool getCurrentJobLine(QJsonObject& re);
bool getRobotMode(QJsonObject& re);//ʾ<><CABE>ģʽ 0<><30><EFBFBD>Զ<EFBFBD>ģʽ 1<><31>Զ<EFBFBD><D4B6>ģʽ 2
bool checkJbiExist(const QString& jbiFilename, QJsonObject& re);
bool setServoStatus(int status, QJsonObject& re);
bool runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi);
bool pauseTask(QJsonObject& re);
bool run(QJsonObject& re);
bool continueTask(QJsonObject& re);
bool setRobotPowerStatus(int status, QJsonObject& re);
bool onReadyRead(QJsonObject& re);
private:
QTcpSocket* socket;
QTimer* m_timer;
int m_iTimeout = 3000;
int m_iCurrentJbiJobLine = 0;
int m_iFileCounter = 0;
signals:
void commandResponse(bool success, const QJsonObject& response);
void hsiRecordSignal(int);
private slots:
void getPoint();
};
class RobotArmControl : public QDialog
{
Q_OBJECT
public:
RobotArmControl(QWidget* parent = nullptr);
~RobotArmControl();
RobotController* robotController;
void onCommandResponse(QString str, const QJsonObject& response);
public Q_SLOTS:
void getTaskList();
void getPose();
void connectRobotArm();
void executeTaskWithHyperImager();
void executeTaskWithoutHyperImager();
void pauseTask();
void continueTask();
void monitorRobotArm(const ECData& data);
signals:
//void Opened();
//void Closed();
private:
Ui::RobotArmControl_UI ui;
EC8056* robotMonitor;
QStringListModel* m_pModel;
};

138
HPPA/RobotArmControl.ui Normal file
View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RobotArmControl_UI</class>
<widget class="QDialog" name="RobotArmControl_UI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>364</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="1">
<widget class="QPushButton" name="pause_task_btn">
<property name="text">
<string>暂停任务</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="connect2arm_btn">
<property name="text">
<string>连接机械臂</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="execute_task_btn">
<property name="text">
<string>执行任务</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="get_pose_btn">
<property name="text">
<string>获取pose</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="continue_task_btn">
<property name="text">
<string>继续任务</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QTextEdit" name="textEdit"/>
</item>
<item row="0" column="0" rowspan="6">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<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>
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="get_task_list_btn">
<property name="text">
<string>获取任务列表</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QListView" name="taskList_listView"/>
</item>
</layout>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QLabel" name="pose_z_label">
<property name="text">
<string>z</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="pose_x_label">
<property name="text">
<string>x</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="pose_y_label">
<property name="text">
<string>y</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>753</width>
<height>490</height>
<width>629</width>
<height>463</height>
</rect>
</property>
<property name="windowTitle">
@ -25,7 +25,7 @@
<rect>
<x>90</x>
<y>250</y>
<width>578</width>
<width>434</width>
<height>134</height>
</rect>
</property>
@ -65,12 +65,12 @@
<rect>
<x>270</x>
<y>150</y>
<width>108</width>
<width>141</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>版本1.5</string>
<string>版本1.9.0</string>
</property>
</widget>
<widget class="QLabel" name="label_4">

87
HPPA/adjustTable.cpp Normal file
View File

@ -0,0 +1,87 @@
#include "adjustTable.h"
adjustTable::adjustTable(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.objective_table1_up_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable1Up_btn()));
connect(ui.objective_table1_down_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable1Down_btn()));
connect(ui.objective_table1_stop_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable1Stop_btn()));
connect(ui.objective_table2_up_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Up_btn()));
connect(ui.objective_table2_down_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Down_btn()));
connect(ui.objective_table2_stop_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Stop_btn()));
connect(ui.objective_table252_up_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable252Up_btn()));
connect(ui.objective_table252_down_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable252Down_btn()));
connect(ui.objective_table252_stop_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable252Stop_btn()));
}
adjustTable::~adjustTable()
{}
void adjustTable::getRequest(QString str)
{
QNetworkRequest request;
QNetworkAccessManager* naManager = new QNetworkAccessManager(this);
QMetaObject::Connection connRet = QObject::connect(naManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
Q_ASSERT(connRet);
request.setUrl(QUrl(str));
QNetworkReply* reply = naManager->get(request);
}
void adjustTable::onObjectivTable1Up_btn()
{
QString xx = "http://192.168.1.253/set_up";
getRequest(xx);
}
void adjustTable::onObjectivTable1Down_btn()
{
QString xx = "http://192.168.1.253/set_down";
getRequest(xx);
}
void adjustTable::onObjectivTable1Stop_btn()
{
QString xx = "http://192.168.1.253/stopnow";
getRequest(xx);
}
void adjustTable::onObjectivTable2Up_btn()
{
QString xx = "http://192.168.1.254/set_up";
getRequest(xx);
}
void adjustTable::onObjectivTable2Down_btn()
{
QString xx = "http://192.168.1.254/set_down";
getRequest(xx);
}
void adjustTable::onObjectivTable2Stop_btn()
{
QString xx = "http://192.168.1.254/stopnow";
getRequest(xx);
}
void adjustTable::onObjectivTable252Up_btn()
{
QString xx = "http://192.168.1.252/set_up";
getRequest(xx);
}
void adjustTable::onObjectivTable252Down_btn()
{
QString xx = "http://192.168.1.252/set_down";
getRequest(xx);
}
void adjustTable::onObjectivTable252Stop_btn()
{
QString xx = "http://192.168.1.252/stopnow";
getRequest(xx);
}

35
HPPA/adjustTable.h Normal file
View File

@ -0,0 +1,35 @@
#pragma once
#include <QDialog>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include "ui_adjustTable.h"
class adjustTable : public QDialog
{
Q_OBJECT
public:
adjustTable(QWidget *parent = nullptr);
~adjustTable();
public Q_SLOTS:
void onObjectivTable1Up_btn();
void onObjectivTable1Down_btn();
void onObjectivTable1Stop_btn();
void onObjectivTable2Up_btn();
void onObjectivTable2Down_btn();
void onObjectivTable2Stop_btn();
void onObjectivTable252Up_btn();
void onObjectivTable252Down_btn();
void onObjectivTable252Stop_btn();
private:
Ui::adjustTableClass ui;
void getRequest(QString str);
};

166
HPPA/adjustTable.ui Normal file
View File

@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>adjustTableClass</class>
<widget class="QDialog" name="adjustTableClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>687</width>
<height>389</height>
</rect>
</property>
<property name="windowTitle">
<string>adjustTable</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>252号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QPushButton" name="objective_table252_up_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" 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="QPushButton" name="objective_table252_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>下降</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="objective_table252_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>停止</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>253号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QPushButton" name="objective_table1_up_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" 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="QPushButton" name="objective_table1_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>下降</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="objective_table1_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>停止</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>254号升降台</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QPushButton" name="objective_table2_up_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" 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="QPushButton" name="objective_table2_down_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>下降</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="objective_table2_stop_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>停止</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -17,7 +17,7 @@ public:
~FileOperation();
string getDirectoryOfExe();//getDirectoryOfExe
string getDirectoryFromString(string directory="C:/HPPA_image");
string getDirectoryFromString(string directory="C:\\HPPA_image");

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "focusWindow.h"
focusWindow::focusWindow(QWidget *parent, ResononImager * imager)
focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
{
ui.setupUi(this);
@ -77,12 +77,12 @@ bool test(void *pCaller, int *x, int *y, void **pvdata)
{
focusWindow *p = (focusWindow *)pCaller;
p->m_Imager->GetImageSize(*x, *y);
p->m_Imager->GetFrameSize(*x, *y);
USHORT *pusData = new USHORT[(*x)*(*y)];
p->m_Imager->m_ResononImager.start();
p->m_Imager->m_ResononImager.get_frame(pusData);
p->m_Imager->m_ResononImager.stop();
p->m_Imager->imagerStartCollect();
p->m_Imager->getFrame(pusData);
p->m_Imager->imagerStopCollect();
BYTE *pbData = (BYTE*)pusData;

View File

@ -25,6 +25,7 @@
#include "hppaConfigFile.h"
#include "path_tc.h"
#include "ImagerOperationBase.h"
class focusWindow:public QDialog
{
@ -32,10 +33,10 @@ class focusWindow:public QDialog
public:
focusWindow(QWidget *parent = Q_NULLPTR);
focusWindow(QWidget *parent, ResononImager * imager);
focusWindow(QWidget *parent, ImagerOperationBase* imager);
~focusWindow();
ResononImager * m_Imager;
ImagerOperationBase* m_Imager;
private:

View File

@ -155,7 +155,7 @@ bool Configfile::getAutoFocusRange(int& max, int& min)
return true;
}
bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor)
bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange)
{
const Setting& root = cfg.getRoot();
@ -170,6 +170,7 @@ bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
if (!(x.lookupValue("StepAnglemar", StepAnglemar)
&& x.lookupValue("Lead", Lead) && x.lookupValue("SubdivisionMultiples", SubdivisionMultiples)
&& x.lookupValue("ScaleFactor", ScaleFactor)
&& x.lookupValue("MaxRange", MaxRange)
))
{
return false;
@ -184,7 +185,7 @@ bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
return true;
}
bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor)
bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange)
{
const Setting& root = cfg.getRoot();
@ -199,6 +200,7 @@ bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
if (!(y.lookupValue("StepAnglemar", StepAnglemar)
&& y.lookupValue("Lead", Lead) && y.lookupValue("SubdivisionMultiples", SubdivisionMultiples)
&& y.lookupValue("ScaleFactor", ScaleFactor)
&& y.lookupValue("MaxRange", MaxRange)
))
{
return false;
@ -213,6 +215,43 @@ bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& Subdivisio
return true;
}
bool Configfile::setMaxRange(float maxRange, QString x_y)
{
const Setting& root = cfg.getRoot();
try
{
Setting& _maxRange = root["motionPlatform"][x_y.toStdString()]["MaxRange"];
_maxRange = maxRange;
writeConfig2File();
return true;
}
catch (const SettingNotFoundException& nfex)
{
cerr << "No 'MaxRange' setting in configuration file." << endl;
return false;
}
}
bool Configfile::writeConfig2File()
{
try
{
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
bool ret = createDir(fileInfo[0]);
cfg.writeFile(m_configfilePath.c_str());
// cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
}
catch (const FileIOException& fioex)
{
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
return false;
}
return true;
}
bool Configfile::getSN(string &SN)
{
try
@ -264,12 +303,14 @@ bool Configfile::createConfigFile()
Setting& x_StepAnglemar = x.add("StepAnglemar", Setting::TypeFloat) = 1.8;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Setting& x_Lead = x.add("Lead", Setting::TypeFloat) = 13.5;//<2F><><EFBFBD>̣<EFBFBD><CCA3><EFBFBD>λ<EFBFBD><CEBB>cm
Setting& x_SubdivisionMultiples = x.add("SubdivisionMultiples", Setting::TypeInt) = 128;//ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>
Setting& x_SubdivisionMultiples = x.add("SubdivisionMultiples", Setting::TypeInt) = 7;//ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>
Setting& x_ScaleFactor = x.add("ScaleFactor", Setting::TypeFloat) = 1.0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Setting& x_MaxRange = x.add("MaxRange", Setting::TypeFloat) = 120.0;
Setting& y_StepAnglemar = y.add("StepAnglemar", Setting::TypeFloat) = 1.8;
Setting& y_Lead = y.add("Lead", Setting::TypeFloat) = 13.5;
Setting& y_SubdivisionMultiples = y.add("SubdivisionMultiples", Setting::TypeInt) = 128;
Setting& y_SubdivisionMultiples = y.add("SubdivisionMultiples", Setting::TypeInt) = 7;
Setting& y_ScaleFactor = y.add("ScaleFactor", Setting::TypeFloat) = 0.2;
Setting& y_MaxRange = y.add("MaxRange", Setting::TypeFloat) = 120.0;
// Write out the new configuration.
try
@ -356,3 +397,529 @@ bool Configfile::updateConfigFile()
return true;
}
CorningConfigfile::CorningConfigfile()
{
}
void CorningConfigfile::setConfigfilePath(string configfilePath)
{
m_configfilePath = configfilePath;
}
bool CorningConfigfile::isConfigfileExist()
{
QFileInfo info(QString::fromStdString(m_configfilePath));
return info.exists();
}
bool CorningConfigfile::parseConfigfile()
{
// Read the file. If there is an error, report it and exit.
try
{
cfg.readFile(m_configfilePath);
return true;
}
catch (const FileIOException& fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
return false;
}
catch (const ParseException& pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
return false;
}
}
bool CorningConfigfile::getSpectralBin(int& spectralBin)
{
try
{
spectralBin = cfg.lookup("spectralBin");
return true;
}
catch (const SettingNotFoundException& nfex)
{
cerr << "No 'spectralBin' setting in configuration file." << endl;
return false;
}
}
bool CorningConfigfile::getspatialBin(int& spatialBin)
{
try
{
spatialBin = cfg.lookup("spatialBin");
return true;
}
catch (const SettingNotFoundException& nfex)
{
cerr << "No 'spatialBin' setting in configuration file." << endl;
return false;
}
}
bool CorningConfigfile::getEffectiveWindow(int& width, int& offsetx, int& height, int& offsety)
{
const Setting& root = cfg.getRoot();
try
{
int spatialBin;
int spectralBin;
getspatialBin(spatialBin);
getSpectralBin(spectralBin);
string spatialBinString;
if (spatialBin == 1)
{
spatialBinString = "bin1";
}
else
{
spatialBinString = "bin2";
}
const Setting& spatialArgument = root["effective_window"][spatialBinString]["spatial"];
if (!(spatialArgument.lookupValue("width", width)
&& spatialArgument.lookupValue("offsetx", offsetx)))
{
return false;
}
string spectralBinString;
if (spectralBin == 1)
{
spectralBinString = "bin1";
}
else
{
spectralBinString = "bin2";
}
const Setting& spectralArgument = root["effective_window"][spectralBinString]["spectral"];
if (!(spectralArgument.lookupValue("height", height)
&& spectralArgument.lookupValue("offsety", offsety)))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool CorningConfigfile::getEffectiveWindowRoi(int& width, int& offsetx)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& effective_window = root["effective_window_roi"];
int count = effective_window.getLength();
int spatialBin;
getspatialBin(spatialBin);
string spatialBinString;
if (spatialBin == 1)
{
spatialBinString = "spatialBin1";
}
else
{
spatialBinString = "spatialBin2";
}
const Setting& window = effective_window[spatialBinString];
string name = window.getName();
if (!(window.lookupValue("width", width)
&& window.lookupValue("offsetx", offsetx)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool CorningConfigfile::getPushFlowParam(int& flowSwitch, int& rgbHeight, int& framerateVideo)
{
Setting& root = cfg.getRoot();
if (!root.exists("push_flow_param"))
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Setting& push_flow_param = root.add("push_flow_param", Setting::TypeGroup);
push_flow_param.add("flow_switch", Setting::TypeInt) = 0;
push_flow_param.add("rgb_height", Setting::TypeInt) = 720;
push_flow_param.add("framerate_video", Setting::TypeInt) = 5;
// <20><><EFBFBD><EFBFBD><EFBFBD>޸ĺ<DEB8><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ļ<EFBFBD>
try
{
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
bool ret = createDir(fileInfo[0]);
cfg.writeFile(m_configfilePath.c_str());
std::cout << "Config item 'push_flow_param' added." << std::endl;
flowSwitch = 0;
rgbHeight = 720;
framerateVideo = 5;
return true;
}
catch (const libconfig::FileIOException& fioex)
{
std::cerr << "I/O error while writing file." << std::endl;
return false;
}
}
else
{
try
{
const Setting& push_flow_param = root["push_flow_param"];
if (!(push_flow_param.lookupValue("rgb_height", rgbHeight)
&& push_flow_param.lookupValue("framerate_video", framerateVideo)
&& push_flow_param.lookupValue("flow_switch", flowSwitch)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
}
bool CorningConfigfile::getWindowOffsety_HeightOfSpectral(int& offsety, int& height, string spectralBinString)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& spectralArgument = root["effective_window"][spectralBinString]["spectral"];
if (!(spectralArgument.lookupValue("height", height)
&& spectralArgument.lookupValue("offsety", offsety)))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool CorningConfigfile::getGainOffset(float& gain, float& offset)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& gainOffset = root["gainOffset"];
int count = gainOffset.getLength();
int spectralBin;
getSpectralBin(spectralBin);
string spectralBinString;
if (spectralBin == 1)
{
spectralBinString = "spectralBin1";
}
else
{
spectralBinString = "spectralBin2";
}
const Setting& gainOffsetSetting = gainOffset[spectralBinString];
string name = gainOffsetSetting.getName();
if (!(gainOffsetSetting.lookupValue("gain", gain)
&& gainOffsetSetting.lookupValue("offset", offset)))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool CorningConfigfile::getGainOffsetOfSpectralBin1(float& gain, float& offset)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& gainOffset = root["gainOffset"];
int count = gainOffset.getLength();
string spectralBinString = "spectralBin1";
const Setting& gainOffsetSetting = gainOffset[spectralBinString];
string name = gainOffsetSetting.getName();
if (!(gainOffsetSetting.lookupValue("gain", gain)
&& gainOffsetSetting.lookupValue("offset", offset)))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool CorningConfigfile::getSN(QString& SN)
{
try
{
std::string SN_tem = cfg.lookup("SN");
SN = QString::fromStdString(SN_tem);
return true;
}
catch (const SettingNotFoundException& nfex)
{
cerr << "No 'spectralBin' setting in configuration file." << endl;
return false;
}
}
bool CorningConfigfile::getBufferPolicy(int& bufferPolicy)
{
const Setting& root = cfg.getRoot();
const Setting& ximeadll = root["ximeadll"];
try
{
if (!(ximeadll.lookupValue("buffer_policy", bufferPolicy)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
cerr << "No 'spectralBin' setting in configuration file." << endl;
return false;
}
return true;
}
bool CorningConfigfile::getAcqBufferSize(int& acqBufferSize)
{
const Setting& root = cfg.getRoot();
const Setting& ximeadll = root["ximeadll"];
try
{
if (!(ximeadll.lookupValue("acq_buffer_size", acqBufferSize)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
cerr << "No 'spectralBin' setting in configuration file." << endl;
return false;
}
return true;
}
bool CorningConfigfile::createConfigFile()
{
using namespace std;
using namespace libconfig;
Config cfg;
Setting& root = cfg.getRoot();
// Add some settings to the configuration.
Setting& SN = root.add("SN", Setting::TypeString) = "0098";
Setting& spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
Setting& SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
Setting& effective_window = root.add("effective_window", Setting::TypeGroup);
Setting& effective_window_Bin1 = effective_window.add("bin1", Setting::TypeGroup);
Setting& effective_window_Bin1_spatial = effective_window_Bin1.add("spatial", Setting::TypeGroup);
Setting& effective_window_Bin1_Spectral = effective_window_Bin1.add("spectral", Setting::TypeGroup);
Setting& effective_window_Bin2 = effective_window.add("bin2", Setting::TypeGroup);
Setting& effective_window_Bin2_spatial = effective_window_Bin2.add("spatial", Setting::TypeGroup);
Setting& effective_window_Bin2_Spectral = effective_window_Bin2.add("spectral", Setting::TypeGroup);
effective_window_Bin1_spatial.add("width", Setting::TypeInt) = 1368;
effective_window_Bin1_spatial.add("offsetx", Setting::TypeInt) = 288;
effective_window_Bin1_Spectral.add("height", Setting::TypeInt) = 300;
effective_window_Bin1_Spectral.add("offsety", Setting::TypeInt) = 348;
effective_window_Bin2_spatial.add("width", Setting::TypeInt) = 688;
effective_window_Bin2_spatial.add("offsetx", Setting::TypeInt) = 144;
effective_window_Bin2_Spectral.add("height", Setting::TypeInt) = 150;
effective_window_Bin2_Spectral.add("offsety", Setting::TypeInt) = 174;
Setting& effective_window_roi = root.add("effective_window_roi", Setting::TypeGroup);
Setting& effective_window_roi_spatialBin1 = effective_window_roi.add("spatialBin1", Setting::TypeGroup);
Setting& effective_window_roi_spatialBin2 = effective_window_roi.add("spatialBin2", Setting::TypeGroup);
effective_window_roi_spatialBin1.add("width", Setting::TypeInt) = 1364;
effective_window_roi_spatialBin1.add("offsetx", Setting::TypeInt) = 14;
// effective_window_roi_Bin1.add("height", Setting::TypeInt) = 300;
// effective_window_roi_Bin1.add("offsety", Setting::TypeInt) = 348;
effective_window_roi_spatialBin2.add("width", Setting::TypeInt) = 682;
effective_window_roi_spatialBin2.add("offsetx", Setting::TypeInt) = 15;
// effective_window_roi_Bin2.add("height", Setting::TypeInt) = 151;
// effective_window_roi_Bin2.add("offsety", Setting::TypeInt) = 174;
Setting& gainOffset = root.add("gainOffset", Setting::TypeGroup);
Setting& gainOffsetSpectralBin1 = gainOffset.add("spectralBin1", Setting::TypeGroup);
Setting& gainOffsetSpectralBin2 = gainOffset.add("spectralBin2", Setting::TypeGroup);
gainOffsetSpectralBin1.add("gain", Setting::TypeFloat) = 2.00313433;
gainOffsetSpectralBin1.add("offset", Setting::TypeFloat) = -300.46283157590585;
gainOffsetSpectralBin2.add("gain", Setting::TypeFloat) = 4.00626868;
gainOffsetSpectralBin2.add("offset", Setting::TypeFloat) = -299.46126663407176;
Setting& ximeadll = root.add("ximeadll", Setting::TypeGroup);
ximeadll.add("buffer_policy", Setting::TypeInt) = 0;
ximeadll.add("acq_buffer_size", Setting::TypeInt) = 400;
Setting& push_flow_param = root.add("push_flow_param", Setting::TypeGroup);
push_flow_param.add("flow_switch", Setting::TypeInt) = 1;
push_flow_param.add("rgb_height", Setting::TypeInt) = 720;
push_flow_param.add("framerate_video", Setting::TypeInt) = 5;
// Write out the new configuration.
try
{
cfg.writeFile(m_configfilePath.c_str());
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
}
catch (const FileIOException& fioex)
{
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
return true;
}
return true;
}
bool CorningConfigfile::updateConfigFile()
{
using namespace std;
using namespace libconfig;
static const char* output_file = "updated.cfg";
Config cfg;
cfg.setOptions(Config::OptionFsync
| Config::OptionSemicolonSeparators
| Config::OptionColonAssignmentForGroups
| Config::OptionOpenBraceOnSeparateLine);
// Read the file. If there is an error, report it and exit.
try
{
cfg.readFile("example.cfg");
}
catch (const FileIOException& fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
return false;
}
catch (const ParseException& pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
return false;
}
// Find the 'movies' setting. Add intermediate settings if they don't yet
// exist.
Setting& root = cfg.getRoot();
if (!root.exists("inventory"))
root.add("inventory", Setting::TypeGroup);
Setting& inventory = root["inventory"];
if (!inventory.exists("movies"))
inventory.add("movies", Setting::TypeList);
Setting& movies = inventory["movies"];
// Create the new movie entry.
Setting& movie = movies.add(Setting::TypeGroup);
movie.add("title", Setting::TypeString) = "Buckaroo Banzai";
movie.add("media", Setting::TypeString) = "DVD";
movie.add("price", Setting::TypeFloat) = 12.99;
movie.add("qty", Setting::TypeInt) = 20;
// Write out the updated configuration.
try
{
cfg.writeFile(output_file);
cerr << "Updated configuration successfully written to: " << output_file
<< endl;
}
catch (const FileIOException& fioex)
{
cerr << "I/O error while writing file: " << output_file << endl;
return false;
}
return true;
}

View File

@ -16,6 +16,8 @@
#include <QCoreApplication>
#include <QDir>
#include "utility_tc.h"
using namespace std;
using namespace libconfig;
@ -35,8 +37,40 @@ public:
bool getFitParams(float& fa, float& fb);
bool getAutoFocusRange(int& max, int& min);
bool getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor);
bool getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor);
bool getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange);
bool getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor, float& MaxRange);
bool setMaxRange(float maxRange, QString x_y);
bool writeConfig2File();
bool createConfigFile();
bool updateConfigFile();
private:
string m_configfilePath;
Config cfg;
};
class CorningConfigfile
{
public:
CorningConfigfile();
void setConfigfilePath(string configfilePath);
bool isConfigfileExist();
bool parseConfigfile();
bool getSpectralBin(int& spectralBin);
bool getspatialBin(int& spatialBin);
bool getEffectiveWindow(int& width, int& offsetx, int& height, int& offsety);
bool getEffectiveWindowRoi(int& width, int& offsetx);
bool getWindowOffsety_HeightOfSpectral(int& offsety, int& height, string spectralBinString);//spectralBinString = "bin1"<22><><EFBFBD>ߡ<EFBFBD>bin2<6E><32>
bool getGainOffset(float& gain, float& offset);
bool getGainOffsetOfSpectralBin1(float& gain, float& offset);
bool getSN(QString& SN);
bool getBufferPolicy(int& bufferPolicy);
bool getAcqBufferSize(int& acqBufferSize);
bool getPushFlowParam(int& flowSwitch, int& rgbHeight, int& framerateVideo);
bool createConfigFile();
bool updateConfigFile();

View File

@ -113,8 +113,9 @@ void CImage::FillRgbImage(unsigned short *datacube)
//m_QRgbImage->save(QString::fromStdString(rgbFilePathNoStrech), "PNG");
//ImageProcessor imageProcessor;
//cv::imwrite(rgbFilePathNoStrech, *m_matRgbImage);
//cv::imwrite(rgbFilePathStrech, CStretch(*m_matRgbImage, 0.01));
//cv::imwrite(rgbFilePathStrech, imageProcessor.CStretch(*m_matRgbImage, 0.02));
}
}
@ -171,7 +172,7 @@ void CImage::FillFocusGrayQImage(unsigned short * datacube)
}
}
m_qimageFocusGrayImage->save("D:/delete/2222222222/test.bmp");
//m_qimageFocusGrayImage->save("D:/delete/2222222222/test.bmp");

View File

@ -11,6 +11,7 @@
#include "QImage"
#include "fileOperation.h"
#include "imageProcessor.h"
class CImage :public QObject

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "imageProcessor.h"
#include <algorithm>
ImageProcessor::ImageProcessor()
{
@ -14,8 +15,10 @@ std::vector<cv::Point2f> ImageProcessor::CHistogram(const cv::Mat img)
cv::Mat mimg = img.clone();
int rows = mimg.rows;
int cols = mimg.cols;
int maxValue = *std::max_element(mimg.begin<unsigned short>(), mimg.end<unsigned short>());
maxValue = 65535;
//ͳ<><CDB3>ÿ<EFBFBD><C3BF><EFBFBD>Ҷȳ<D2B6><C8B3>ֵĴ<D6B5><C4B4><EFBFBD>
std::vector<long int> hisnum(4096, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::vector<long int> hisnum(maxValue, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i(0); i < rows; ++i)
{
//std::cout << "i<><69>" << i << std::endl;
@ -27,7 +30,7 @@ std::vector<cv::Point2f> ImageProcessor::CHistogram(const cv::Mat img)
//<2F>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD>ڿ۳<DABF><DBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>Ϊ<EFBFBD><CEAA>ֵ
//<2F><><EFBFBD><EFBFBD>mat<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪCV_16UC3<43><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>ֵʱ<D6B5><CAB1><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>Ϊ65535
if (gv > 4096)
if (gv >= maxValue)
{
++hisnum[0];
}
@ -35,8 +38,6 @@ std::vector<cv::Point2f> ImageProcessor::CHistogram(const cv::Mat img)
{
++hisnum[gv];
}
}
}
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD>Ƶ<EFBFBD><C6B5>

165
HPPA/imager_base.cpp Normal file
View File

@ -0,0 +1,165 @@
#include "imager_base.h"
Iris::ImagerBase::ImagerBase()
{
}
Iris::ImagerBase::~ImagerBase()
{
}
void Iris::ImagerBase::set_spectral_bin(int new_spectral_bin)
{
}
int Iris::ImagerBase::get_spectral_bin()
{
return 1;
}
int Iris::ImagerBase::get_min_spectral_bin()
{
return 1;
}
int Iris::ImagerBase::get_max_spectral_bin()
{
return 1;
}
int Iris::ImagerBase::get_start_band()
{
return 1;
}
void Iris::ImagerBase::set_start_band(int band)
{
}
int Iris::ImagerBase::get_min_start_band()
{
return 1;
}
int Iris::ImagerBase::get_max_start_band()
{
return 1;
}
int Iris::ImagerBase::get_inc_start_band()
{
return 1;
}
int Iris::ImagerBase::get_end_band()
{
return 1;
}
void Iris::ImagerBase::set_end_band(int band)
{
}
int Iris::ImagerBase::get_min_end_band()
{
return 1;
}
int Iris::ImagerBase::get_max_end_band()
{
return 1;
}
int Iris::ImagerBase::get_inc_end_band()
{
return 1;
}
int Iris::ImagerBase::get_start_sample()
{
return 1;
}
void Iris::ImagerBase::set_start_sample(int sample)
{
}
int Iris::ImagerBase::get_min_start_sample()
{
return 1;
}
int Iris::ImagerBase::get_max_start_sample()
{
return 1;
}
int Iris::ImagerBase::get_inc_start_sample()
{
return 1;
}
int Iris::ImagerBase::get_end_sample()
{
return 1;
}
void Iris::ImagerBase::set_end_sample(int sample)
{
}
int Iris::ImagerBase::get_min_end_sample()
{
return 1;
}
int Iris::ImagerBase::get_max_end_sample()
{
return 1;
}
int Iris::ImagerBase::get_inc_end_sample()
{
return 1;
}
void Iris::ImagerBase::set_gain(const double gain)
{
}
double Iris::ImagerBase::get_gain()
{
return 1;
}
double Iris::ImagerBase::get_min_gain()
{
return 1;
}
double Iris::ImagerBase::get_max_gain()
{
return 1;
}
void Iris::ImagerBase::set_internal_trigger()
{
}
void Iris::ImagerBase::set_external_trigger(unsigned int signal_line, bool rising_edge)
{
}
bool Iris::ImagerBase::is_trigger_external()
{
return true;
}

93
HPPA/imager_base.h Normal file
View File

@ -0,0 +1,93 @@
/*
* Iris API
*
* By using this API, the user agrees to the terms and conditions as stated in the
* document "Terms of Use", located on the Resonon website
* at: http://www.resonon.com/downloads/Resonon_API_Terms_of_Use.pdf.
*
*/
#ifndef __GUARD_Iris_IMAGER_BASE_H
#define __GUARD_Iris_IMAGER_BASE_H
#include <stdexcept>
#include <cstdint>
//#include "irisximeaimager_global.h"
/**
* The Iris namespace contains all public classes.
*/
namespace Iris
{
/**
* An abstract base class which provides a common interface for all imagers.
*/
class ImagerBase
{
public:
ImagerBase();
virtual ~ImagerBase();
virtual void connect(const char * camera_sn=NULL)=0;
virtual void disconnect()=0;
virtual void start()=0;
virtual void stop()=0;
virtual void get_imager_type(char *buffer, int buffer_size)=0;
virtual void get_serial_number(char *buffer, int buffer_size)=0;
virtual void get_camera_serial_number(char *buffer, int buffer_size)=0;
virtual void generate_configuration_report(char *buffer, int buffer_size)=0;
virtual float get_coeff_a()=0;
virtual float get_coeff_b()=0;
virtual float get_coeff_c()=0;
virtual double get_wavelength_at_band(const int band)=0;
int get_nearest_band_to_wavelength(const double wavelength);
virtual int get_frame_buffer_size_in_bytes()=0;
virtual unsigned short* get_frame(unsigned short* buffer)=0;
virtual std::uint64_t get_last_timestamp()=0;
virtual std::uint64_t ticks_per_second()=0;
virtual void set_spectral_bin(int new_spectral_bin);
virtual int get_spectral_bin();
virtual int get_min_spectral_bin();
virtual int get_max_spectral_bin();
virtual int get_band_count()=0;
virtual int get_start_band();
virtual void set_start_band(int band);
virtual int get_min_start_band();
virtual int get_max_start_band();
virtual int get_inc_start_band();
virtual int get_end_band();
virtual void set_end_band(int band);
virtual int get_min_end_band();
virtual int get_max_end_band();
virtual int get_inc_end_band();
virtual int get_sample_count()=0;
virtual int get_start_sample();
virtual void set_start_sample(int sample);
virtual int get_min_start_sample();
virtual int get_max_start_sample();
virtual int get_inc_start_sample();
virtual int get_end_sample();
virtual void set_end_sample(int sample);
virtual int get_min_end_sample();
virtual int get_max_end_sample();
virtual int get_inc_end_sample();
virtual void set_framerate(const double frames_per_second)=0;
virtual double get_framerate()=0;
virtual double get_min_framerate()=0;
virtual double get_max_framerate()=0;
virtual double get_min_integration_time()=0;
virtual double get_max_integration_time()=0;
virtual void set_integration_time(const double milliseconds)=0;
virtual double get_integration_time()=0;
virtual void set_gain(const double gain);
virtual double get_gain();
virtual double get_min_gain();
virtual double get_max_gain();
virtual void set_internal_trigger();
virtual void set_external_trigger(unsigned int signal_line, bool rising_edge=true);
virtual bool is_trigger_external();
};
} //end namespace Iris
#endif //end ifndef __GUARD_Iris_IMAGER_BASE_H

565
HPPA/irisximeaimager.cpp Normal file
View File

@ -0,0 +1,565 @@
#include "irisximeaimager.h"
using namespace Iris;
void Iris::IrisXimeaImager::setGainOffset(float gain, float offset)
{
m_fGain = gain;
m_fOffset = offset;
}
bool Iris::IrisXimeaImager::setSpectralBin(int spectralBin)
{
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_SELECTOR, XI_BIN_SELECT_HOST_CPU));//用XI_BIN_SELECT_HOST_CPU默认为XI_BIN_SELECT_SENSOR(会报错)不可用XI_BIN_SELECT_DEVICE_FPGA
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL_MODE, XI_BIN_MODE_AVERAGE));
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, spectralBin));
printf("Iris::IrisXimeaImager::setSpectralBin----2 设置bin模式为XI_PRM_BINNING_SELECTOR XI_BIN_MODE_AVERAGE \n");
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_SELECTOR, XI_DEC_SELECT_SENSOR));
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_VERTICAL, spectralBin));
m_iSpectralBin = spectralBin;
return true;
}
bool Iris::IrisXimeaImager::setSpatialBin(int spatialBin)
{
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_SELECTOR, XI_BIN_SELECT_HOST_CPU));//用XI_BIN_SELECT_HOST_CPU默认为XI_BIN_SELECT_SENSOR(会报错)不可用XI_BIN_SELECT_DEVICE_FPGA
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL_MODE, XI_BIN_MODE_AVERAGE));
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, spatialBin));
printf("Iris::IrisXimeaImager::setSpatialBin----2 设置bin模式为XI_PRM_BINNING_SELECTOR XI_BIN_MODE_AVERAGE \n");
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_SELECTOR, XI_DEC_SELECT_SENSOR));
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_HORIZONTAL, spatialBin));
m_iSpatialBin = spatialBin;
return true;
}
int Iris::IrisXimeaImager::getSpectralBin()
{
int spectralBin = 0;
CE(xiGetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, &spectralBin));
// CE(xiGetParamInt(m_xiH, XI_PRM_DECIMATION_VERTICAL, &spectralBin));
return spectralBin;
}
int Iris::IrisXimeaImager::getSpatialBin()
{
int spatialBin = 0;
CE(xiGetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, &spatialBin));
// CE(xiGetParamInt(m_xiH, XI_PRM_DECIMATION_HORIZONTAL, &spatialBin));
return spatialBin;
}
void Iris::IrisXimeaImager::setEffectiveWindow(int OffsetX, int width, int OffsetY, int height)
{
CE(xiSetParamInt(m_xiH, XI_PRM_WIDTH, width));
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_X, OffsetX));
CE(xiSetParamInt(m_xiH, XI_PRM_HEIGHT, height));
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_Y, OffsetY));
m_iEffectiveWindow_OffsetX = OffsetX;
m_iEffectiveWindow_width = width;
m_iEffectiveWindow_OffsetY = OffsetY;
m_iEffectiveWindow_height = height;
}
void Iris::IrisXimeaImager::setEffectiveWindowRoi(int OffsetX, int width)
{
m_iEffectiveWindowRoi_OffsetX = OffsetX;
m_iEffectiveWindowRoi_width = width;
}
int Iris::IrisXimeaImager::getBufferSizeOfOneFrame()
{
// if(m_xiH==NULL)
// return 0;
//
// start();
//
// //清空image缓存
// memset(&m_image, 0, sizeof(m_image));
// m_image.size = sizeof(XI_IMG);
//
// CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
//
// stop();
//
// return static_cast<int>(m_image.bp_size);
// //比实际大小m_iEffectiveWindow_height * m_iEffectiveWindow_width * 2why
// int value = 0;
// xiGetParamInt(m_xiH, XI_PRM_IMAGE_PAYLOAD_SIZE, &value);
return m_iEffectiveWindow_height * m_iEffectiveWindow_width * 2;
}
float Iris::IrisXimeaImager::getTemperature()
{
float temperature = 0.0;
CE(xiGetParamFloat(m_xiH, XI_PRM_TEMP, &temperature));
return temperature;
}
void Iris::IrisXimeaImager::setBufferPolicy(int bufferPolicy)
{
if (bufferPolicy==0)
{
xiSetParamInt(m_xiH, XI_PRM_BUFFER_POLICY, XI_BP_UNSAFE);
printf("Iris::IrisXimeaImager::connect---- XI_PRM_BUFFER_POLICY: XI_BP_UNSAFE\n");
}
else if (bufferPolicy==1)
{
xiSetParamInt(m_xiH, XI_PRM_BUFFER_POLICY, XI_BP_SAFE);
printf("Iris::IrisXimeaImager::connect---- XI_PRM_BUFFER_POLICY: XI_BP_SAFE\n");
}
}
void Iris::IrisXimeaImager::setAcqBufferSize(int acqBufferSize)
{
XI_RETURN stat = XI_OK;
// set unit to 1 MiB
xiSetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE_UNIT, 1024*1024);
int value = 0;
xiGetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, &value);
printf("Iris::IrisXimeaImager::connect---- XI_PRM_ACQ_BUFFER_SIZE: %d MiB.\n", value);
xiSetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, acqBufferSize);
xiGetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, &value);
printf("Iris::IrisXimeaImager::connect---- XI_PRM_ACQ_BUFFER_SIZE: %d MiB.\n", value);
// set maximum number of queue
int number_of_field_buffers = 0;
xiGetParamInt(m_xiH, XI_PRM_BUFFERS_QUEUE_SIZE XI_PRM_INFO_MAX, &number_of_field_buffers);
printf("Iris::IrisXimeaImager::connect---- XI_PRM_BUFFERS_QUEUE_SIZE XI_PRM_INFO_MAX: %d.\n", number_of_field_buffers);
HandleResult(stat,"xiGetParam (number_of_field_buffers maximum)");
xiSetParamInt(m_xiH, XI_PRM_BUFFERS_QUEUE_SIZE, number_of_field_buffers);
HandleResult(stat,"xiSetParam (number_of_field_buffers)");
}
Iris::IrisXimeaImager::IrisXimeaImager()
{
m_xiH=NULL;
//std::cout<<"ximeaControlDll 版本:"<< "21." <<std::endl;
}
Iris::IrisXimeaImager::~IrisXimeaImager()
{
}
void Iris::IrisXimeaImager::connect(const char *camera_serial_number)
{
printf("Iris::IrisXimeaImager::connect----1 打开相机(xiOpenDevice)\n");
CE(xiOpenDevice(0, &m_xiH));//没有插上ximea相机,这句代码都过不去
//add-----------------------------------------------------------------------------------------------------------------------
XI_RETURN stat = XI_OK;
int payload=0;
stat = xiGetParamInt(m_xiH, XI_PRM_IMAGE_PAYLOAD_SIZE, &payload);
HandleResult(stat,"xiGetParam (payload)");
int transport_buffer_size_default = 0;
int transport_buffer_size_increment = 0;
int transport_buffer_size_minimum = 0;
// get default transport buffer size - that should be OK on all controllers
stat = xiGetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE, &transport_buffer_size_default);
HandleResult(stat,"xiGetParamInt (transport buffer size)");
stat = xiGetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE XI_PRM_INFO_INCREMENT, &transport_buffer_size_increment);
HandleResult(stat,"xiGetParamInt (transport buffer size increment)");
stat = xiGetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE XI_PRM_INFO_MIN, &transport_buffer_size_minimum);
HandleResult(stat,"xiGetParamInt (transport buffer size minimum)");
// check if payload size is less than default transport buffer size
if(payload < transport_buffer_size_default + transport_buffer_size_increment)
{
// use optimized transport buffer size, as nearest increment to payload
int transport_buffer_size = payload;
if (transport_buffer_size_increment)
{
// round up to nearest increment
int remainder = transport_buffer_size % transport_buffer_size_increment;
if (remainder)
transport_buffer_size += transport_buffer_size_increment - remainder;
}
// check the minimum
if (transport_buffer_size < transport_buffer_size_minimum)
transport_buffer_size = transport_buffer_size_minimum;
stat = xiSetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE, transport_buffer_size);
HandleResult(stat,"xiSetParam (transport buffer size)");
}
//add---------------------------------------------------------------------------------------------------------------------------------------------------------------
// set unit to 1 MiB
xiSetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE_UNIT, 1024*1024);
int value = 0;
xiGetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, &value);
printf("Iris::IrisXimeaImager::connect---- XI_PRM_ACQ_BUFFER_SIZE: %d MiB.\n", value);
int NUM_THREADS = 0;
xiGetParamInt(m_xiH, XI_PRM_PROC_NUM_THREADS, &NUM_THREADS);
printf("Iris::IrisXimeaImager::connect---- XI_PRM_PROC_NUM_THREADS默认值为%d\n", NUM_THREADS);
xiSetParamInt(m_xiH, XI_PRM_PROC_NUM_THREADS, 8);
//设置数据格式
printf("Iris::IrisXimeaImager::connect----2 设置数据格式(xiSetParamInt)\n");
CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_RAW16));//Default value: XI_MONO8
// //设置packing, 使用xiGetImage接收影像时不执行unpacking
// CE(xiSetParamInt(m_xiH, XI_PRM_OUTPUT_DATA_BIT_DEPTH, 12));//set 12 bit transport data width
// CE(xiSetParamInt(m_xiH, XI_PRM_OUTPUT_DATA_PACKING, XI_ON));//enable packing
// //使用xiGetImage接收影像时不执行unpacking
// CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_FRM_TRANSPORT_DATA));//in this case, the function xiGetImage just set pointer to transport-buffer without any processing
//判断数据格式设置是否成功
int dataFortmat;
CE(xiGetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, &dataFortmat));
if(dataFortmat==XI_RAW16)
{
printf("Iris::IrisXimeaImager::connect----当前数据格式设置成功, 设置为: XI_RAW16\n");
}
else if(dataFortmat==XI_FRM_TRANSPORT_DATA)
{
printf("Iris::IrisXimeaImager::connect----当前数据格式设置成功, 设置为: XI_FRM_TRANSPORT_DATA\n");
}
else
{
printf("Iris::IrisXimeaImager::connect----2 数据格式设置失败!\n");
printf("Iris::IrisXimeaImager::connect----当前数据格式为:%d\n",dataFortmat);
}
}
void Iris::IrisXimeaImager::disconnect()
{
printf("Closing camera...\n");
CE(xiCloseDevice(m_xiH));
m_xiH=NULL;
}
void Iris::IrisXimeaImager::start()
{
CE(xiStartAcquisition(m_xiH));
}
void Iris::IrisXimeaImager::stop()
{
//printf("Stopping acquisition...\n");
CE(xiStopAcquisition(m_xiH));
}
void Iris::IrisXimeaImager::get_imager_type(char *buffer, int buffer_size)
{
}
void Iris::IrisXimeaImager::get_serial_number(char *buffer, int buffer_size)
{
}
void Iris::IrisXimeaImager::get_camera_serial_number(char *buffer, int buffer_size)
{
}
void Iris::IrisXimeaImager::generate_configuration_report(char *buffer, int buffer_size)
{
}
float Iris::IrisXimeaImager::get_coeff_a()
{
return 0;
}
float Iris::IrisXimeaImager::get_coeff_b()
{
return 0;
}
float Iris::IrisXimeaImager::get_coeff_c()
{
return 0;
}
double Iris::IrisXimeaImager::get_wavelength_at_band(const int band)
{
//sn008
float a=1.999564;
float b=-279.893;
//
float wavelength=band*m_fGain + m_fOffset;
return wavelength;
}
int Iris::IrisXimeaImager::get_frame_buffer_size_in_bytes()
{
return 0;
}
unsigned short *Iris::IrisXimeaImager::get_frame(unsigned short *buffer)
{
//清空image缓存
memset(&m_image, 0, sizeof(m_image));
m_image.size = sizeof(XI_IMG);
CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
//方法1:memcpy
memcpy(buffer,m_image.bp,m_image.bp_size);
// //方法2:此做法是错误的,虽然是指针,也是传值!
// buffer = (unsigned short *)m_image.bp;
// for(int i=0;i<m_iEffectiveWindow_height;i++)
// {
// memcpy(buffer+i*m_iEffectiveWindowRoi_width, (unsigned short *)m_image.bp + i*m_iEffectiveWindow_width + m_iEffectiveWindowRoi_OffsetX, m_iEffectiveWindowRoi_width*2);
// }
//强制将指针从高精度uint64_t*转换到低精度unsigned short *),会有精度降低的问题???????????????????????????????????????????????????
return (unsigned short *)&m_timestampOfCamera;
}
uint64_t Iris::IrisXimeaImager::get_last_timestamp()
{
return 0;
}
uint64_t Iris::IrisXimeaImager::ticks_per_second()
{
return 0;
}
void Iris::IrisXimeaImager::set_spectral_bin(int new_spectral_bin)
{
}
int Iris::IrisXimeaImager::get_spectral_bin()
{
return 0;
}
int Iris::IrisXimeaImager::get_min_spectral_bin()
{
return 0;
}
int Iris::IrisXimeaImager::get_max_spectral_bin()
{
return 0;
}
int Iris::IrisXimeaImager::get_band_count()
{
return m_iEffectiveWindow_height;
}
int Iris::IrisXimeaImager::get_start_band()
{
int WindowStartLine;
CE(xiGetParamInt(m_xiH, XI_PRM_OFFSET_Y, &WindowStartLine));
return WindowStartLine;
}
void Iris::IrisXimeaImager::set_start_band(int band)
{
}
int Iris::IrisXimeaImager::get_min_start_band()
{
return 0;
}
int Iris::IrisXimeaImager::get_max_start_band()
{
return 0;
}
int Iris::IrisXimeaImager::get_inc_start_band()
{
return 0;
}
int Iris::IrisXimeaImager::get_end_band()
{
int height;
CE(xiGetParamInt(m_xiH, XI_PRM_HEIGHT, &height));
return get_start_band()+height;
}
void Iris::IrisXimeaImager::set_end_band(int band)
{
}
int Iris::IrisXimeaImager::get_min_end_band()
{
return 0;
}
int Iris::IrisXimeaImager::get_max_end_band()
{
return 0;
}
int Iris::IrisXimeaImager::get_inc_end_band()
{
return 0;
}
int Iris::IrisXimeaImager::get_sample_count()
{
return m_iEffectiveWindow_width;
}
int Iris::IrisXimeaImager::get_start_sample()
{
return 0;
}
void Iris::IrisXimeaImager::set_start_sample(int sample)
{
}
int Iris::IrisXimeaImager::get_min_start_sample()
{
return 0;
}
int Iris::IrisXimeaImager::get_max_start_sample()
{
return 0;
}
int Iris::IrisXimeaImager::get_inc_start_sample()
{
return 0;
}
int Iris::IrisXimeaImager::get_end_sample()
{
return 0;
}
void Iris::IrisXimeaImager::set_end_sample(int sample)
{
}
int Iris::IrisXimeaImager::get_min_end_sample()
{
return 0;
}
int Iris::IrisXimeaImager::get_max_end_sample()
{
return 0;
}
int Iris::IrisXimeaImager::get_inc_end_sample()
{
return 0;
}
void Iris::IrisXimeaImager::set_framerate(const double frames_per_second)
{
CE(xiSetParamInt(m_xiH, XI_PRM_ACQ_TIMING_MODE, XI_ACQ_TIMING_MODE_FRAME_RATE_LIMIT));
CE(xiSetParamFloat(m_xiH, XI_PRM_FRAMERATE, frames_per_second));
}
double Iris::IrisXimeaImager::get_framerate()
{
float framerate;
CE(xiGetParamFloat(m_xiH, XI_PRM_FRAMERATE, &framerate));
return framerate;
}
double Iris::IrisXimeaImager::get_min_framerate()
{
return 0;
}
double Iris::IrisXimeaImager::get_max_framerate()
{
return 0;
}
double Iris::IrisXimeaImager::get_min_integration_time()
{
return 0;
}
double Iris::IrisXimeaImager::get_max_integration_time()
{
return 0;
}
void Iris::IrisXimeaImager::set_integration_time(const double microsecond)
{
CE(xiSetParamInt(m_xiH, XI_PRM_EXPOSURE, microsecond));//time_in_us(microseconds)
}
double Iris::IrisXimeaImager::get_integration_time()
{
float exposureTime;
CE(xiGetParamFloat(m_xiH, XI_PRM_EXPOSURE, &exposureTime));//time_in_us(microseconds)
return exposureTime;
}
void Iris::IrisXimeaImager::set_gain(const double gain)
{
CE(xiSetParamFloat(m_xiH, XI_PRM_GAIN, gain));//gain_in_db
}
double Iris::IrisXimeaImager::get_gain()
{
float gain;
CE(xiGetParamFloat(m_xiH, XI_PRM_GAIN, &gain));
return gain;
}
double Iris::IrisXimeaImager::get_min_gain()
{
return 0;
}
double Iris::IrisXimeaImager::get_max_gain()
{
return 0;
}
void Iris::IrisXimeaImager::set_internal_trigger()
{
}
void Iris::IrisXimeaImager::set_external_trigger(unsigned int signal_line, bool rising_edge)
{
}
bool Iris::IrisXimeaImager::is_trigger_external()
{
return 0;
}

123
HPPA/irisximeaimager.h Normal file
View File

@ -0,0 +1,123 @@
#ifndef IRISXIMEAIMAGER_H
#define IRISXIMEAIMAGER_H
#include <memory.h>
#include <exception>
#include <iostream>
//#include "irisximeaimager_global.h"
#include "imager_base.h"
#ifdef WIN32
#include <xiApi.h> // Windows
#else
#include <m3api/xiApi.h> // Linux, OSX
#endif
#define CE(func) {XI_RETURN stat = (func); if (XI_OK!=stat) {printf("Error:%d returned from function:"#func"\n",stat);throw stat;}}
#define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)\n",place,res);}
namespace Iris
{
class IrisXimeaImager:public ImagerBase
{
public:
HANDLE m_xiH;
void setGainOffset(float gain, float offset);
bool setSpectralBin(int spectralBin);
bool setSpatialBin(int spatialBin);
int getSpectralBin();
int getSpatialBin();
void setEffectiveWindow(int OffsetX, int width, int OffsetY, int height);
void setEffectiveWindowRoi(int OffsetX, int width);
int getBufferSizeOfOneFrame();
float getTemperature();
XI_IMG m_image; // image buffer
void setBufferPolicy(int bufferPolicy);//0:XI_BP_UNSAFE; 1:XI_BP_SAFE;
void setAcqBufferSize(int acqBufferSize);//单位MiB
public:
//继承基类的
IrisXimeaImager();//11111111111111111111
virtual ~IrisXimeaImager();
void connect(const char * camera_serial_number=NULL);//111111111111111111111111111111111
void disconnect();//111111111111111111111111111111
void start();//111111111111111111111
void stop();//1111111111111111111111
void get_imager_type(char *buffer, int buffer_size);
void get_serial_number(char *buffer, int buffer_size);
void get_camera_serial_number(char *buffer, int buffer_size);
void generate_configuration_report(char *buffer, int buffer_size);
float get_coeff_a();
float get_coeff_b();
float get_coeff_c();
double get_wavelength_at_band(const int band);//11111111111111111111
int get_frame_buffer_size_in_bytes();
unsigned short* get_frame(unsigned short* buffer);//11111111111111111111111
std::uint64_t get_last_timestamp();
std::uint64_t ticks_per_second();
void set_spectral_bin(int new_spectral_bin);//11111111111111111111111111111111
int get_spectral_bin();
int get_min_spectral_bin();
int get_max_spectral_bin();
int get_band_count();//11111111111111111111
int get_start_band();//对应上一版本api的函数:get_window_start_band
void set_start_band(int band);
int get_min_start_band();
int get_max_start_band();
int get_inc_start_band();
int get_end_band();//对应上一版本api的函数:get_window_end_band
void set_end_band(int band);
int get_min_end_band();
int get_max_end_band();
int get_inc_end_band();
int get_sample_count();//11111111111111111
int get_start_sample();
void set_start_sample(int sample);
int get_min_start_sample();
int get_max_start_sample();
int get_inc_start_sample();
int get_end_sample();
void set_end_sample(int sample);
int get_min_end_sample();
int get_max_end_sample();
int get_inc_end_sample();
void set_framerate(const double frames_per_second);//11111111111111111111111111111111
double get_framerate();//1111111111111111111111
double get_min_framerate();
double get_max_framerate();
double get_min_integration_time();
double get_max_integration_time();
void set_integration_time(const double microsecond);//111111111111111111111
double get_integration_time();//1111111111111111111111111111111
void set_gain(const double gain);//111111111111
double get_gain();//111111111111
double get_min_gain();
double get_max_gain();
void set_internal_trigger();
void set_external_trigger(unsigned int signal_line, bool rising_edge=true);
bool is_trigger_external();
protected:
private:
uint64_t m_timestampOfCamera;
int m_iSpectralBin;
int m_iSpatialBin;
int m_iEffectiveWindow_OffsetX;
int m_iEffectiveWindow_width;
int m_iEffectiveWindow_OffsetY;
int m_iEffectiveWindow_height;
int m_iEffectiveWindowRoi_OffsetX;
int m_iEffectiveWindowRoi_width;
float m_fGain;
float m_fOffset;
};
}
#endif // IRISXIMEAIMAGER_H

285
HPPA/oneMotorControl.ui Normal file
View File

@ -0,0 +1,285 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OneMotorControl_UI</class>
<widget class="QDialog" name="OneMotorControl_UI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>544</width>
<height>346</height>
</rect>
</property>
<property name="windowTitle">
<string>一轴马达控制</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>实时位置</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>运行速度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>返回速度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="realTimeLoc_lineEdit">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="speed_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>0.1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="return_speed_lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="move2loc_lineEdit">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="connect_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>连接</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="zero_start_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>归零</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="rangeMeasurement_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>量程测量</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="move2loc_pushButton">
<property name="text">
<string>移动至</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>161</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="left_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>←0</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="right_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>→</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<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>
<widget class="QLabel" name="motor_state_label">
<property name="text">
<string>马达状态</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>191</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,30 +1,11 @@
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <exception>
#include "resononImager.h"
ResononImager::ResononImager()
ResononPicaLImager::ResononPicaLImager()
{
m_iFrameCounter = 1;
m_bRecordControlState = true;
m_FileName2Save = "tmp_image";
m_FileSavedCounter = 1;
m_RgbImage = new CImage();
buffer = nullptr;
dark = nullptr;
white = nullptr;
m_HasDark = false;
m_HasWhite = false;
m_bFocusControlState = false;
}
ResononImager::~ResononImager()
ResononPicaLImager::~ResononPicaLImager()
{
if (buffer != nullptr)
{
@ -35,425 +16,90 @@ ResononImager::~ResononImager()
}
}
CImage * ResononImager::getRgbImage() const
double ResononPicaLImager::getFramerate()
{
return m_RgbImage;
return m_ResononPicaLImager.get_framerate();
}
cv::Mat * ResononImager::getMatRgbImage() const
double ResononPicaLImager::getIntegrationTime()
{
return m_RgbImage->m_matRgbImage;
return m_ResononPicaLImager.get_integration_time();
}
cv::Mat * ResononImager::getMatFocusGrayImage() const
double ResononPicaLImager::getGain()
{
return m_RgbImage->m_matFocusGrayImage;
return m_ResononPicaLImager.get_gain();
}
QImage ResononImager::getQImageFocusGrayImage() const
void ResononPicaLImager::setGain(const double gain)
{
return *m_RgbImage->m_qimageFocusGrayImage;
m_ResononPicaLImager.set_gain(gain);
}
bool ResononImager::getRecordControlState() const
void ResononPicaLImager::setFramerate(const double frames_per_second)
{
return m_bRecordControlState;
}
void ResononImager::setRecordControlState(bool RecordControlState)
{
m_bRecordControlState = RecordControlState;
}
int ResononImager::getFrameCounter() const
{
return m_iFrameCounter;
}
int ResononImager::getFocusFrameCounter() const
{
return m_iFocusFrameCounter;
}
void ResononImager::WriteHdr()
{
//write an ENVI compatible header file
using namespace std;
FileOperation * fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryFromString();
string hdrPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".hdr";
std::ofstream outfile(hdrPath.c_str());
outfile << "ENVI\n";
outfile << "interleave = bil\n";
outfile << "data type = 12\n";
outfile << "bit depth = 12\n";
outfile << "samples = " << m_ResononImager.get_sample_count() << "\n";
outfile << "bands = " << m_ResononImager.get_band_count() << "\n";
outfile << "lines = " << m_iFrameCounter << "\n";
outfile << "framerate = " << m_ResononImager.get_framerate() << "\n";
outfile << "shutter = " << m_ResononImager.get_integration_time() << "\n";
outfile << "gain = " << m_ResononImager.get_gain() << "\n";
outfile << "wavelength = {";
outfile << std::setprecision(5);
int start = m_ResononImager.get_start_band();
int end = m_ResononImager.get_end_band();
for (int i = start; i < end - 1; i++)
{
outfile << m_ResononImager.get_wavelength_at_band(i) << ", ";
}
outfile << m_ResononImager.get_wavelength_at_band(end - 1) << "}\n";
outfile.close();
}
unsigned short ResononImager::GetMaxValue(unsigned short * dark, int number)
{
unsigned short max = 0;
for (size_t i = 0; i < number; i++)
{
if (dark[i]>max)
{
max = dark[i];
}
}
//std::cout << "<22><>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
return max;
}
void ResononImager::connect_imager(int frameNumber)
{
m_ResononImager.connect();
set_framerate(30.0);
set_integration_time(1);
set_gain(0);
m_ResononImager.set_spectral_bin(2);
//m_ResononImager.set_spatial_bin(2);
set_buffer();
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), frameNumber);
m_iFrameNumber = frameNumber;
emit testImagerStatus();
//std::cout << "------------------------------------------------------" << std::endl;
}
void ResononImager::start_record()
{
using namespace std;
//std::cout << "------------------------------------------------------" << std::endl;
m_iFrameCounter = 0;
m_RgbImage->m_iFrameCounter = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rgbͼ<62><CDBC><EFBFBD>ĵ<EFBFBD>0<EFBFBD><30>
m_bRecordControlState = true;
//<2F>ж<EFBFBD><D0B6>ڴ<EFBFBD>buffer<65>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (buffer == 0)
{
std::cerr << "Error: memory could not be allocated for datacube";
exit(EXIT_FAILURE);
}
FileOperation * fileOperation = new FileOperation();
string directory = fileOperation->getDirectoryFromString();
string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter);
m_fImage = fopen(imgPath.c_str(), "w+b");
size_t x;
double pixelValueTmp;
m_ResononImager.start();
while (m_bRecordControlState)
{
m_iFrameCounter++;
m_ResononImager.get_frame(buffer);
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
if (buffer[i] < dark[i])
{
buffer[i] = 0;
}
else
{
buffer[i] = buffer[i] - dark[i];
}
}
}
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (m_HasWhite)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壩Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (white[i] != 0)
{
pixelValueTmp = buffer[i];
buffer[i] = (pixelValueTmp / white[i]) * 10000;
}
else
{
buffer[i] = 0;
}
}
}
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
//std::cout << "<22><>" << m_iFrameCounter << "֡д<D6A1><D0B4>" << x << "<22><>unsigned short<72><74>" << std::endl;
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
if (m_iFrameCounter % (int)m_ResononImager.get_framerate() == 0)
{
emit PlotSignal();
}
if (m_iFrameCounter >= m_iFrameNumber)
{
break;
}
}
m_ResononImager.stop();
m_bRecordControlState = false;
WriteHdr();
m_FileSavedCounter++;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//m_RgbImage
emit PlotSignal();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
if (m_iFrameCounter >= m_iFrameNumber)
{
emit RecordFinishedSignal_WhenFrameNumberMeet();
}
else
{
emit RecordFinishedSignal_WhenFrameNumberNotMeet();
}
//QThread::msleep(1001);
fclose(m_fImage);
}
void ResononImager::record_dark()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
m_ResononImager.start();
m_ResononImager.get_frame(dark);
m_ResononImager.stop();
m_HasDark = true;
}
void ResononImager::record_white()
{
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ壡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
m_ResononImager.start();
m_ResononImager.get_frame(white);
m_ResononImager.stop();
//<2F>װ<EFBFBD><D7B0>۰<EFBFBD><DBB0><EFBFBD><EFBFBD><EFBFBD>
if (m_HasDark)
{
for (size_t i = 0; i < m_FrameSize; i++)
{
if (white[i] < dark[i])
{
white[i] = 0;
}
else
{
white[i] = white[i] - dark[i];
}
}
}
m_HasWhite = true;
}
double ResononImager::get_framerate()
{
return m_ResononImager.get_framerate();
}
double ResononImager::get_integration_time()
{
return m_ResononImager.get_integration_time();
}
double ResononImager::get_gain()
{
return m_ResononImager.get_gain();
}
void ResononImager::set_framerate(const double frames_per_second)
{
m_ResononImager.set_framerate(frames_per_second);
m_ResononPicaLImager.set_framerate(frames_per_second);
m_RgbImage->m_iFramerate = frames_per_second;
}
void ResononImager::set_integration_time(const double milliseconds)
void ResononPicaLImager::setIntegrationTime(const double milliseconds)
{
m_ResononImager.set_integration_time(milliseconds);
m_ResononPicaLImager.set_integration_time(milliseconds);
}
void ResononImager::set_gain(const double gain)
int ResononPicaLImager::getStartBand()
{
m_ResononImager.set_gain(gain);
return m_ResononPicaLImager.get_start_band();
}
void ResononImager::set_buffer()
int ResononPicaLImager::getEndBand()
{
//<2F><><EFBFBD><EFBFBD>
if (buffer != nullptr)
{
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
free(buffer);
}
m_FrameSize = m_ResononImager.get_band_count()*m_ResononImager.get_sample_count();
//std::cout << "m_FrameSize<7A><65>СΪ" << m_FrameSize << std::endl;
buffer = new unsigned short[m_FrameSize];
dark = new unsigned short[m_FrameSize];
white = new unsigned short[m_FrameSize];
std::cout << "buffer<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << buffer << std::endl;
std::cout << "dark<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << dark << std::endl;
std::cout << "white<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ" << white << std::endl;
return m_ResononPicaLImager.get_end_band();
}
void ResononImager::setFrameNumber(int FrameNumber)
void ResononPicaLImager::connectImager(const char* camera_sn)
{
m_iFrameNumber = FrameNumber;
m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), FrameNumber);
m_ResononPicaLImager.connect();
}
double ResononImager::auto_exposure()
void ResononPicaLImager::disconnectImager()
{
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD>ڵ<EFBFBD>ǰ֡<C7B0><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double x = 1 / m_ResononImager.get_framerate()*1000;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
m_ResononImager.set_integration_time(x);
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ѭ<EFBFBD><D1AD>Ѱ<EFBFBD><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
m_ResononImager.start();
while (true)
{
m_ResononImager.get_frame(buffer);
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
{
set_integration_time(get_integration_time()*0.8);
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
}
else
{
break;
}
}
m_ResononImager.stop();
//std::cout << "<22>Զ<EFBFBD><D4B6>ع⣺" << get_integration_time() << std::endl;
return get_integration_time();
m_ResononPicaLImager.disconnect();
}
void ResononImager::setFocusControlState(bool FocusControlState)
void ResononPicaLImager::imagerStartCollect()
{
m_bFocusControlState = FocusControlState;
m_ResononPicaLImager.start();
}
void ResononImager::setFileName2Save(string FileName)
void ResononPicaLImager::imagerStopCollect()
{
m_FileName2Save = FileName;
m_FileSavedCounter = 1;
m_ResononPicaLImager.stop();
}
double ResononImager::getWavelengthAtBand(int band)
unsigned short* ResononPicaLImager::getFrame(unsigned short* buffer)
{
return m_ResononImager.get_wavelength_at_band(band);
m_ResononPicaLImager.get_frame(buffer);
return buffer;
}
int ResononImager::getBandCount()
void ResononPicaLImager::setSpectraBin(int new_spectral_bin)
{
return m_ResononImager.get_band_count();
}
int ResononImager::getSampleCount()
double ResononPicaLImager::getWavelengthAtBand(int band)
{
return m_ResononImager.get_sample_count();
return m_ResononPicaLImager.get_wavelength_at_band(band);
}
int ResononImager::GetImageSize(int &iWidth, int &iHeight)
int ResononPicaLImager::getBandCount()
{
/*using namespace GENAPI_NAMESPACE;
using namespace std;
INodeMap& nodemap = m_phCamera->GetNodeMap();
iWidth = (int)CIntegerPtr(nodemap.GetNode("Width"))->GetValue();
iHeight = (int)CIntegerPtr(nodemap.GetNode("Height"))->GetValue();*/
iWidth = getSampleCount();
iHeight = getBandCount();
return 0;
return m_ResononPicaLImager.get_band_count();
}
void ResononImager::focus()
int ResononPicaLImager::getSampleCount()
{
m_iFocusFrameCounter = 1;
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
double tmpFrmerate = m_ResononImager.get_framerate();
double tmpIntegrationTime = m_ResononImager.get_integration_time();
m_ResononImager.set_framerate(5);
auto_exposure();
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << m_ResononImager.get_integration_time() << std::endl;
m_ResononImager.start();
//emit SpectralSignal(1);
m_bFocusControlState = true;
while (m_bFocusControlState)
{
m_ResononImager.get_frame(buffer);
//m_RgbImage->FillFocusGrayImage(buffer);
m_RgbImage->FillFocusGrayQImage(buffer);
emit SpectralSignal(1);
++m_iFocusFrameCounter;
}
emit SpectralSignal(0);
m_ResononImager.stop();
m_ResononImager.set_framerate(tmpFrmerate);
m_ResononImager.set_integration_time(tmpIntegrationTime);
return m_ResononPicaLImager.get_sample_count();
}

View File

@ -4,94 +4,45 @@
#include <string>
#include <opencv2/core/core.hpp>
#include "ImagerOperationBase.h"
#include "resonon_imager_basler.h"
#include "image2display.h"
#include "fileOperation.h"
class ResononImager:public QObject
class ResononPicaLImager:public ImagerOperationBase
{
Q_OBJECT
public:
ResononImager();
~ResononImager();
ResononPicaLImager();
~ResononPicaLImager();
Resonon::PikaBasler m_ResononImager;//
CImage* getRgbImage() const;
cv::Mat * getMatRgbImage() const;
cv::Mat * getMatFocusGrayImage() const;
QImage getQImageFocusGrayImage() const;
bool getRecordControlState() const;
void setRecordControlState(bool RecordControlState);
int getFrameCounter() const;
int getFocusFrameCounter() const;
unsigned short * buffer;//<2F><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>д<EFBFBD>뵽Ӳ<EBB5BD><D3B2><EFBFBD><EFBFBD>
void set_buffer();
void setFrameNumber(int FrameNumber);
double auto_exposure();
void setFocusControlState(bool FocusControlState);
void setFileName2Save(string FileName);
Resonon::PikaBasler m_ResononPicaLImager;//
double getWavelengthAtBand(int band);
int getBandCount();
int getSampleCount();
int GetImageSize(int &iWidth, int &iHeight);
double getFramerate();
double getIntegrationTime();
double getGain();
void setFramerate(const double frames_per_second);
void setIntegrationTime(const double milliseconds);
void setGain(const double gain);
int getStartBand();
int getEndBand();
void connectImager(const char* camera_sn = NULL);
void disconnectImager();
void imagerStartCollect();
void imagerStopCollect();
unsigned short* getFrame(unsigned short* buffer);
void setSpectraBin(int new_spectral_bin);
protected:
private:
CImage* m_RgbImage;//<2F><>ʾ<EFBFBD><CABE>rgbͼ<62><CDBC>
int m_iFrameNumber;//<2F><>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>
int m_iFrameCounter;//<2F><>¼<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
int m_iFocusFrameCounter;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1>
bool m_bRecordControlState;//<2F>ɼ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
bool m_bFocusControlState;//<2F><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
string m_FileName2Save;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
int m_FileSavedCounter;//<2F><><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD>
unsigned short * dark;//<2F><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned short * white;//<2F><EFBFBD>װ<EFBFBD>
FILE *m_fImage;//<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ӳ<EFBFBD>̵<EFBFBD><CCB5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
int m_FrameSize;//<2F><>ʾһ֡<D2BB><D6A1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD>ֵ<EFBFBD><D6B5>m_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
bool m_HasDark;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
bool m_HasWhite;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰װ<CBB0>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
void WriteHdr();
unsigned short GetMaxValue(unsigned short * dark, int number);
public slots:
void connect_imager(int frameNumber);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
void start_record();
void record_dark();
void record_white();
void focus();
double get_framerate();
double get_integration_time();
double get_gain();
void set_framerate(const double frames_per_second);
void set_integration_time(const double milliseconds);
void set_gain(const double gain);
signals:
void PlotSignal();//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ź<EFBFBD>
void RecordFinishedSignal_WhenFrameNumberMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72>û<EFBFBD>вɼ<D0B2><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>;ֹͣ<CDA3>ɼ<EFBFBD>
void SpectralSignal(int);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9>ף<EFBFBD><D7A3><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
void testImagerStatus();//<2F><>ʾ<EFBFBD><CABE><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};
#endif

159
HPPA/utility_tc.cpp Normal file
View File

@ -0,0 +1,159 @@
#include "utility_tc.h"
#include <QDir>
QString formatTimeStr(char * format)
{
//获取系统时间
time_t timer;//time_t就是long int 类型
struct tm *tblock;
timer = time(NULL);//返回秒数(精度为秒)从1970-1-1,00:00:00 可以当成整型输出或用于其它函数
tblock = localtime(&timer);
//printf("Local time is: %s\n", asctime(tblock));
//格式化时间为需要的格式
char timeStr_tmp[256] = { 0 };
strftime(timeStr_tmp, sizeof(timeStr_tmp), format, tblock);//
QString timeStr2(timeStr_tmp);
// qDebug() << "time is:" << timeStr2;
return timeStr2;
}
QString getFileNameBaseOnTime()
{
using namespace std;
//获取系统时间
time_t timer;//time_t就是long int 类型
struct tm *tblock;
timer = time(NULL);//返回秒数(精度为秒)从1970-1-1,00:00:00 可以当成整型输出或用于其它函数
tblock = localtime(&timer);
//printf("Local time is: %s\n", asctime(tblock));
//格式化时间为需要的格式
char fileNameTmp[256] = { 0 };
char dirNameTmp[256] = { 0 };
strftime(fileNameTmp, sizeof(fileNameTmp), "%Y%m%d_%H%M%S", tblock);
strftime(dirNameTmp, sizeof(dirNameTmp), "%Y%m%d", tblock);
QString fileName(fileNameTmp);
QString dirName(dirNameTmp);
// QString fileName=QString::number(tblock->tm_year+1900)+QString::number(tblock->tm_mon+1)+QString::number(tblock->tm_mday)+"_"+QString::number(tblock->tm_hour)+QString::number(tblock->tm_min);//
//设置文件绝对路径
QDir path("/media/nvme");
if(!path.exists(dirName))
{
path.mkdir(dirName);
}
path.cd(dirName);
QString absoluteFilePath=path.path()+"/"+fileName;
// printf("absoluteFilePath is: %s\n", absoluteFilePath.c_str());
// qDebug() << "absoluteFilePath is:" << absoluteFilePath;
return absoluteFilePath;
}
void bubbleSort(unsigned short * a, int n)
{
// //排序实现1
// for(int i=0;i<numberOfPixel;i++)
// for(int j=1;j<numberOfPixel-i;j++)
// if(a[j-1]>a[j])
// swap(a+j-1,a+j);
//排序实现2
int j,k,flag;
flag = n;
while(flag>0)
{
k=flag;
flag=0;
for(j=1;j<k;j++)
if(a[j-1]>a[j])
{
swap(a+j-1,a+j);
flag=j;
}
}
}
void swap(unsigned short * a, unsigned short * b)
{
int tmp;
tmp=*a;
*a=*b;
*b=tmp;
}
bool createDir(QString fullPath)
{
QDir dir(fullPath);
if (dir.exists()) {
return true;
} else {
bool ok = dir.mkpath(fullPath);//创建多级目录
return ok;
}
}
std::string removeFileExtension(std::string filename)
{
size_t lastDot = filename.find_last_of(".");
if (lastDot == std::string::npos) {
// 如果没有找到后缀,返回原字符串
return filename;
}
return filename.substr(0, lastDot);
}
QList<QString> getFileInfo(QString file)
{
QFileInfo fileInfo = QFileInfo(file);
QString fileName, fileSuffix, filePath;
filePath = fileInfo.absolutePath();//绝对路径
fileName = fileInfo.fileName();//文件名
fileSuffix = fileInfo.suffix();//文件后缀
// qDebug() << fileName <<endl
// << fileSuffix<< endl
// << filePath<< endl;
QList<QString> result;
result.append(filePath);
result.append(fileName);
result.append(fileSuffix);
return result;
}
long long getNanosecondsSinceMidnight()
{
// 获取当前系统时间
auto now = std::chrono::system_clock::now();
// 转换为 time_t秒级别的时间戳
std::time_t t = std::chrono::system_clock::to_time_t(now);
std::tm local_tm = *std::localtime(&t); // 获取本地时间结构
// 将时间结构调整到当天 00:00:00
local_tm.tm_hour = 0;
local_tm.tm_min = 0;
local_tm.tm_sec = 0;
local_tm.tm_isdst = -1; // 让 mktime 自动判断夏令时
// 获取当天 00:00:00 的时间点
auto midnight = std::chrono::system_clock::from_time_t(std::mktime(&local_tm));
// 计算从当天 00:00:00 到现在的时间差
auto nanoseconds_since_midnight = std::chrono::duration_cast<std::chrono::nanoseconds>(now - midnight);
// 返回纳秒数
return nanoseconds_since_midnight.count();
}

28
HPPA/utility_tc.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef UTILITY_TC_H
#define UTILITY_TC_H
#include <iostream>
#include <ctime>
#include <string>
#include <QString>
#include <QDebug>
#include <chrono>
QString getFileNameBaseOnTime();
QString formatTimeStr(char * format);
//https://blog.csdn.net/MoreWindows/article/details/6657829
void bubbleSort(unsigned short * a, int n);
void swap(unsigned short * a, unsigned short * b);
bool createDir(QString fullPath);
std::string removeFileExtension(std::string filename);
QList<QString> getFileInfo(QString file);
long long getNanosecondsSinceMidnight();
#endif // UTILITY_TC_H

28
readme.txt Normal file
View File

@ -0,0 +1,28 @@
1、HPPA拼接
每条航线的开始帧的位置不一样,无法直接将相邻航线拼接一起,否则航向有错位。
1.1 步骤
1采集每帧的同时获取线性平台的位置并写入文件
2根据位置信息匹配帧号然后进行拼接
1.2 存在的问题及解决办法
1马达库不知道是否能够支持20hz及以上的访问频率
或者按照一定频率采集线性平台位置,通过时间进行插值获取每帧位置;
2列之间的重叠
通过一个可调参数进行旁向拼接设置;
1.3 拼接后裁剪
1.4 根据每个像素的xy坐标进行拼接放弃
2、bug修复
1反射率图像条纹白板和暗电流都采集30帧进行平均
2轨迹2位小数
3速度输入接受小数
3、hppa升降桌无线控制模块
如果没有配置过那么默认ip为http://192.168.1.254且默认wifi以iris1开头默认wifi密码为123456789。
配置网页为http://192.168.1.254/wificonfig.html配置密码是licahk*******
如果已经配置为252那么可用下面网址控制
http://192.168.1.252/stopnow
http://192.168.1.252/set_up
http://192.168.1.252/set_down
http://192.168.1.252/wificonfig.html