4)+HJ
od|N$m>wl<2zWL8L{|3JKH}K8Bfp7i|eDiPMn|}lU-~Ai-f7Rljq5uE@
literal 0
HcmV?d00001
diff --git a/HPPA/HPPA.qrc b/HPPA/HPPA.qrc
new file mode 100644
index 0000000..5285ca9
--- /dev/null
+++ b/HPPA/HPPA.qrc
@@ -0,0 +1,5 @@
+
+
+ HPPA.ico
+
+
diff --git a/HPPA/HPPA.rc b/HPPA/HPPA.rc
new file mode 100644
index 0000000000000000000000000000000000000000..510337bc270b49746d0d565a0ccf08960760d259
GIT binary patch
literal 3224
zcmd5;+iuf95IxTb{$X)mT0t8wU(j3#7HJyQNd!`)s7h*xl$+uNgvtYNd^MDF*4f61
z?EvA$TG_KZJF`1G_xoRElwoj*F@{)Tj)-4~6>&Y{BCK(P30GA-<1qM$Tg><^iC+a6H<>Xt(W3I$0vA}TAU?I7g|1@eStOt
zbkIc&KCUppHR{CHIB%he55xrgU!p=xlXG{!WGLQn(m80*pkDTM98ybjO!@v5wIe-r
z`0Drk`+Rkk@0333#J}RVZ;?OS;EUC7%(tum;%UrD6nn>-x{@b_eD`s_;WY2gEf#dr
z8Jx9#+@9e3U2ygI{;c)0cbZ}8C=oYftCOcY@iW2+we*Ib6UR-!80j*Cs`Q-!J*df{
zbH8zzT+R;9xTc>D$oG~Jc4}{J65ArSOW3f!=rA#zJhe{hI-c|FfOHk!7W3>=D29E;
zaGMl9<@L!`+k0ES)pb*kFMIdERV_EO*4U
zBvI{@JmS%*6ApDGUpKo`!nhtvVxKw8XBJcMpols&9Ni(Bl{i
zS^o9+S-w~vm6XQ$j)Tevp?z;&oleJ4^1NcrUCcQ6za5)$+To7P>9JUPNJ=9K^K<5m
OzOR@}_h)Il>!jaxP=TKS
literal 0
HcmV?d00001
diff --git a/HPPA/HPPA.ui b/HPPA/HPPA.ui
new file mode 100644
index 0000000..8941a7a
--- /dev/null
+++ b/HPPA/HPPA.ui
@@ -0,0 +1,1765 @@
+
+
+ HPPAClass
+
+
+
+ 0
+ 0
+ 1136
+ 605
+
+
+
+ Hyper Plant Phenotypic Analysis
+
+
+
+ :/HPPA/HPPA.ico:/HPPA/HPPA.ico
+
+
+ background-color: rgb(240, 240, 240);
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ false
+
+
+ border-size:1px;
+
+
+
+
+
+
-
+
+
+ 打开摄像头
+
+
+
+ -
+
+
+ 关闭摄像头
+
+
+
+ -
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Plain
+
+
+ 摄像头关闭!
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::Box
+
+
+ QFrame::Raised
+
+
+
+
+
+
+
+
+ 1
+ 0
+
+
+
+ 0
+
+
+
+ Tab 1
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+
+
+
+ Tab 2
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ background-color: rgb(240, 240, 240);
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Vertical
+
+
+
+
+ 0
+ 1
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ 0
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ 3
+
+
+
+ camera
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 16777215
+
+
+
+ 帧率
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 100
+ 16777215
+
+
+
+ 积分时间
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 0
+
+
+
+
+ 100
+ 16777215
+
+
+
+ gain
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ background-color: rgb(255, 255, 255);
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ stage
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QGroupBox{border:none}
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 19
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 19
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ ↓0
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 19
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ →
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 马达量程检测
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 66
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ ←0
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 84
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 归零
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ ↑
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ #QGroupBox{border:none}
+
+
+ x马达
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 20
+
+
+
+
+ 100
+ 20
+
+
+
+ 速度
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+ 1
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 17
+
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 37
+ 17
+
+
+
+
+ -
+
+
+
+ 16777215
+ 33
+
+
+
+ 3
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 0
+
+
+
+
+ 100
+ 20
+
+
+
+ 位置
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 20
+
+
+
+
+ 16777215
+ 33
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 14
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 17
+
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 128
+ 17
+
+
+
+
+ -
+
+
+ nan
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ y马达
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 100
+ 0
+
+
+
+ 位置
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 21
+
+
+
+
+ 16777215
+ 33
+
+
+
+ background-color: rgb(255, 255, 255);
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 100
+ 20
+
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 146
+ 20
+
+
+
+
+ -
+
+
+ nan
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+ 轨迹规划
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 高度
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 100
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ 生成轨迹
+
+
+
+ -
+
+
+ 保存轨迹
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 视场角
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 17.6
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ 删除轨迹
+
+
+
+ -
+
+
+ 读取轨迹
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 偏移
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 幅宽
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+
+ -
+
+
+ 添加
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 65
+ 0
+
+
+
+ 重复率(%)
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ 0
+
+
+ Qt::AlignCenter
+
+
+ false
+
+
+
+ -
+
+
+ 阈值
+
+
+
+ -
+
+
+ 0.7
+
+
+ Qt::AlignCenter
+
+
+ false
+
+
+
+ -
+
+
+ 移除
+
+
+
+
+
+ -
+
+
+
+
+
+
+ 电源控制
+
+
+ -
+
+
-
+
+
+ 卤素灯
+
+
+
+ -
+
+
+ 打开
+
+
+
+ -
+
+
+ 关闭
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+ 马 达
+
+
+
+ -
+
+
+ 打开
+
+
+
+ -
+
+
+ 关闭
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 254
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+
+
+
+ TopToolBarArea
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ exit
+
+
+
+
+ open
+
+
+ open
+
+
+
+
+ preference...
+
+
+
+
+ 采集
+
+
+
+
+ 调焦
+
+
+
+
+ 曝光
+
+
+
+
+ 暗电流
+
+
+
+
+ 白板
+
+
+
+
+ 连接相机
+
+
+
+
+ 打开文件夹
+
+
+
+
+ Pika L
+
+
+
+
+ Corning 410
+
+
+
+
+ Pika XC2
+
+
+
+
+
+
+ QDoubleSlider
+ QSlider
+
+
+
+ QMotorDoubleSlider
+ QSlider
+
+
+
+ ImagerPositionSimulation
+ QGraphicsView
+ imagerpositionsimulation.h
+
+
+ QYMotorDoubleSlider
+ QSlider
+
+
+
+
+
+
+
+
diff --git a/HPPA/HPPA.vcxproj b/HPPA/HPPA.vcxproj
new file mode 100644
index 0000000..fbc1abd
--- /dev/null
+++ b/HPPA/HPPA.vcxproj
@@ -0,0 +1,166 @@
+
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {E7886664-B69E-4781-BCBE-804574FB4033}
+ QtVS_v304
+ $(MSBuildProjectDirectory)\QtMsBuild
+ 10.0.17763.0
+
+
+
+ Application
+ v141
+
+
+ Application
+ v141
+
+
+
+
+
+
+ qt5.9.0_vs2017
+ core;network;gui;widgets;serialport;websockets;charts
+ debug
+
+
+ qt5.9.0_vs2017
+ core;network;gui;widgets;serialport;websockets;charts
+ release
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D:\software\Qt5.9.0\5.9\msvc2017_64\include;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_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_vs2017\HPPA\HPPA;$(IncludePath)
+ 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_vs2017\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\software\Qt5.9.0\5.9\msvc2017_64\lib;$(LibraryPath)
+
+
+ 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_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_vs2017\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_vs2017\HPPA\HPPA;$(IncludePath)
+ 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_vs2017\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\software\Qt5.9.0\5.9\msvc2017_64\lib;$(LibraryPath)
+
+
+
+ opencv_world3411.lib;opencv_world3411d.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5SerialPortd.lib;Qt5WebSocketsd.lib;Qt5Networkd.lib;Qt5Chartsd.lib;AutoFocus_InspireLinearMotor_DLL.lib;%(AdditionalDependencies)
+
+
+ _AMD64_;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+
+
+
+
+ opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5SerialPort.lib;Qt5WebSockets.lib;Qt5Network.lib;Qt5Charts.lib;AutoFocus_InspireLinearMotor_DLL.lib;%(AdditionalDependencies)
+
+
+
+
+ true
+ true
+ ProgramDatabase
+ Disabled
+ MultiThreadedDebugDLL
+
+
+ Windows
+ true
+
+
+
+
+ true
+ true
+ None
+ MaxSpeed
+ MultiThreadedDLL
+
+
+ Windows
+ false
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HPPA/HPPA.vcxproj.filters b/HPPA/HPPA.vcxproj.filters
new file mode 100644
index 0000000..6be9d8e
--- /dev/null
+++ b/HPPA/HPPA.vcxproj.filters
@@ -0,0 +1,153 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {99349809-55BA-4b9d-BF79-8FDBB0286EB3}
+ ui
+
+
+ {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}
+ ts
+
+
+
+
+ Resource Files
+
+
+ Form Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Form Files
+
+
+
+
+
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/HPPA/ImageReaderWriter.cpp b/HPPA/ImageReaderWriter.cpp
new file mode 100644
index 0000000..eebc154
--- /dev/null
+++ b/HPPA/ImageReaderWriter.cpp
@@ -0,0 +1,87 @@
+#include "stdafx.h"
+#include
+
+#include "ImageReaderWriter.h"
+
+
+
+ImageReaderWriter::ImageReaderWriter(const char * fileName)
+{
+ GDALAllRegister();
+ m_poDataset = (GDALDataset *)GDALOpen(fileName, GA_ReadOnly);
+ if (m_poDataset == NULL)
+ {
+ std::cout << "Ӱʧܣ" << std::endl;
+ return;
+ }
+
+ //ȡӰϢ
+ m_DataType = m_poDataset->GetRasterBand(1)->GetRasterDataType();
+ m_iBands = m_poDataset->GetRasterCount();
+ m_iXCount = m_poDataset->GetRasterXSize();
+ m_iYCount = m_poDataset->GetRasterYSize();
+
+}
+
+ImageReaderWriter::ImageReaderWriter()
+{
+
+}
+
+float * ImageReaderWriter::ReadImage(int nXOff, int nYOff, int nXSize, int nYSize)
+{
+ int xBuff = nXSize;
+ int yBuff = nYSize;
+
+
+ if (m_DataType == GDT_Byte)
+ {
+ unsigned char *pDataBuffer = (unsigned char*)CPLMalloc(sizeof(unsigned int)*(1)*(1)*(m_iBands));//unsigned char=BYTE
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(unsigned char));
+ }
+ else if (m_DataType == GDT_UInt16)
+ {
+ //WORD *pDataBuffer = new WORD[1 * 1 * m_iBands];//WORD=unsigned short
+ //memset(pDataBuffer, 0, 1 * 1 * m_iBands*sizeof(WORD));
+
+ float *pDataBuffer = (float*)CPLMalloc(sizeof(float)*(1)*(1)*(m_iBands));
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(float));
+
+ CPLErr status = m_poDataset->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pDataBuffer, xBuff, yBuff, GDT_Float32, m_iBands, NULL, 0, 0, 0); //ȸߺ
+
+ if (status != CE_None)
+ {
+ std::cout << "ȡӰʧܣ" << std::endl;
+ return 0;
+ }
+
+ /*for (size_t i = 0; i < m_iBands; i++)
+ {
+ std::cout << *pDataBuffer << std::endl;
+ pDataBuffer++;
+ }*/
+
+ return pDataBuffer;
+ }
+ else if (m_DataType == GDT_UInt32)
+ {
+ unsigned int *pDataBuffer = (unsigned int*)CPLMalloc(sizeof(unsigned int)*(1)*(1)*(m_iBands));
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(unsigned int));
+ }
+ else if (m_DataType == GDT_Float32)
+ {
+ float *pDataBuffer = (float*)CPLMalloc(sizeof(float)*(1)*(1)*(m_iBands));
+ memset(pDataBuffer, 0, 1 * 1 * m_iBands * sizeof(float));
+ }
+
+}
+
+int ImageReaderWriter::getXCount() const
+{
+ return m_iXCount;
+}
+
+int ImageReaderWriter::getyCount() const
+{
+ return m_iYCount;
+}
diff --git a/HPPA/ImageReaderWriter.h b/HPPA/ImageReaderWriter.h
new file mode 100644
index 0000000..cbf687f
--- /dev/null
+++ b/HPPA/ImageReaderWriter.h
@@ -0,0 +1,28 @@
+#ifndef IMAGE_READER_WRITER
+#define IMAGE_READER_WRITER
+#include "stdafx.h"
+#include "gdal_priv.h"
+#include "cpl_conv.h"
+
+class ImageReaderWriter
+{
+public:
+ ImageReaderWriter();
+ ImageReaderWriter(const char * fileName);
+ float * ReadImage(int nXOff, int nYOff, int nXSize, int nYSize);
+ //void WriteImage();
+
+ int getXCount() const;
+ int getyCount() const;
+
+
+protected:
+private:
+ GDALDataset *m_poDataset;
+ GDALDataType m_DataType;
+
+ int m_iBands;
+ int m_iXCount;
+ int m_iYCount;
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/ImageViewer.cpp b/HPPA/ImageViewer.cpp
new file mode 100644
index 0000000..ce71e03
--- /dev/null
+++ b/HPPA/ImageViewer.cpp
@@ -0,0 +1,227 @@
+#include "stdafx.h"
+#include
+
+#include
+#include
+
+#include "ImageViewer.h"
+
+
+#define VIEW_CENTER viewport()->rect().center()
+#define VIEW_WIDTH viewport()->rect().width()
+#define VIEW_HEIGHT viewport()->rect().height()
+
+
+ImageViewer::ImageViewer(QWidget* pParent) :QGraphicsView(pParent)
+{
+ m_qtGraphicsScene = new QGraphicsScene(this);
+ this->setScene(m_qtGraphicsScene);
+
+ m_framNumberLabel = new QLabel(this);
+ m_framNumberLabel->setAlignment(Qt::AlignHCenter);
+ m_framNumberLabel->setAlignment(Qt::AlignVCenter);
+
+ QFont ft;
+ ft.setPointSize(14);
+ m_framNumberLabel->setFont(ft);
+ m_framNumberLabel->setText("0");
+
+
+ m_GraphicsPixmapItemHandle = nullptr;
+
+ m_scale = 1.0;
+ m_zoomDelta = 0.1;
+ m_translateSpeed = 1.0;
+ m_bMouseTranslate = false;
+
+
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+}
+
+ImageViewer::~ImageViewer()
+{
+
+}
+
+void ImageViewer::DisplayFrameNumber(int frameNumber)
+{
+ m_framNumberLabel->setText(QString::number(frameNumber));
+ m_framNumberLabel->adjustSize();
+}
+
+void ImageViewer::SetImage(QPixmap *image)
+{
+ if (!HasImage())
+ {
+ m_GraphicsPixmapItemHandle = m_qtGraphicsScene->addPixmap(*image);
+ }
+ else
+ {
+ m_GraphicsPixmapItemHandle->setPixmap(*image);
+ }
+
+ setSceneRect(QRectF(image->rect()));
+
+}
+
+bool ImageViewer::HasImage()
+{
+ if (m_GraphicsPixmapItemHandle == nullptr)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+void ImageViewer::wheelEvent(QWheelEvent *event)
+{
+ //qDebug() << "---------------+++++++++++++++++++++++++++++++++++++++++++++++++++ ";
+ if (true)//HasImage()
+ {
+ //ΧŴhttps://blog.csdn.net/GoForwardToStep/article/details/77035287?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param
+ // ȡǰviewλ;
+ QPointF cursorPoint = event->pos();
+ // ȡǰsceneλ;
+ QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y()));
+
+ // ȡviewĿ;
+ qreal viewWidth = this->viewport()->width();
+ qreal viewHeight = this->viewport()->height();
+
+ // ȡǰλ൱viewСĺݱ;
+ qreal hScale = cursorPoint.x() / viewWidth;
+ qreal vScale = cursorPoint.y() / viewHeight;
+
+
+ // ֵĹ
+ QPoint scrollAmount = event->angleDelta();
+ // ֵʾԶʹ߷ŴֵʾʹС
+ scrollAmount.y() > 0 ? zoomIn() : zoomOut();
+
+
+ // sceneתΪŴС;
+ QPointF viewPoint = this->matrix().map(scenePos);
+ // ͨviewŴСչʾsceneλ;
+ horizontalScrollBar()->setValue(int(viewPoint.x() - viewWidth * hScale));
+ verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
+ }
+
+ QGraphicsView::wheelEvent(event);
+}
+
+void ImageViewer::scaling(qreal scaleFactor)
+{
+ //qDebug() << this->sceneRect();
+ scale(scaleFactor, scaleFactor);
+}
+
+void ImageViewer::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button()==Qt::LeftButton)
+ {
+ m_bMouseTranslate = true;
+ m_lastMousePos = event->pos();
+
+ //qDebug() << mapToScene(m_lastMousePos);
+
+ emit leftMouseButtonPressed(mapToScene(m_lastMousePos).x(), mapToScene(m_lastMousePos).y());
+ }
+
+
+ //If you do not perform all the necessary work in your implementation of the virtual function, you may need to call the base class's implementation.
+ QGraphicsView::mousePressEvent(event);
+}
+
+void ImageViewer::mouseMoveEvent(QMouseEvent *event)
+{
+ if (m_bMouseTranslate){
+ QPointF mouseDelta = mapToScene(event->pos()) - mapToScene(m_lastMousePos);
+ translate(mouseDelta);
+ }
+
+ m_lastMousePos = event->pos();
+ QGraphicsView::mousePressEvent(event);
+}
+
+void ImageViewer::mouseReleaseEvent(QMouseEvent *event)
+{
+ m_bMouseTranslate = false;
+ QGraphicsView::mouseReleaseEvent(event);
+}
+
+void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ QGraphicsView::mouseDoubleClickEvent(event);
+}
+
+void ImageViewer::zoomIn()
+{
+ zoom(1 + m_zoomDelta);
+}
+
+void ImageViewer::zoomOut()
+{
+ zoom(1 - m_zoomDelta);
+}
+
+void ImageViewer::zoom(float scaleFactor)
+{
+ // ֹС
+ qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
+ if (factor < 0.07 || factor > 100)
+ return;
+
+ scale(scaleFactor, scaleFactor);
+ m_scale *= scaleFactor;
+}
+
+void ImageViewer::translate(QPointF delta)
+{
+ // ݵǰ zoom ƽ
+ delta *= m_scale;
+ delta *= m_translateSpeed;
+
+ ////1
+ //scene()->setSceneRect(scene()->sceneRect().x() - delta.x(), scene()->sceneRect().y() - delta.y(),
+ // scene()->sceneRect().width(), scene()->sceneRect().height());
+ //scene()->update();
+
+ //2
+ // view µĵΪêλ scene
+ setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+ QPoint newCenter(VIEW_WIDTH / 2 - delta.x(), VIEW_HEIGHT / 2 - delta.y());
+ centerOn(mapToScene(newCenter));
+
+ // scene view ĵΪê
+ setTransformationAnchor(QGraphicsView::AnchorViewCenter);
+}
+
+void ImageViewer::setTranslateSpeed(qreal speed)
+{
+ // ٶȷΧ
+ Q_ASSERT_X(speed >= 0.0 && speed <= 2.0,
+ "InteractiveView::setTranslateSpeed", "Speed should be in range [0.0, 2.0].");
+ m_translateSpeed = speed;
+}
+
+qreal ImageViewer::translateSpeed() const
+{
+ return m_translateSpeed;
+}
+
+void ImageViewer::setZoomDelta(qreal delta)
+{
+ // Χ
+ Q_ASSERT_X(delta >= 0.0 && delta <= 1.0,
+ "InteractiveView::setZoomDelta", "Delta should be in range [0.0, 1.0].");
+ m_zoomDelta = delta;
+}
+
+qreal ImageViewer::zoomDelta() const
+{
+ return m_zoomDelta;
+}
diff --git a/HPPA/ImageViewer.h b/HPPA/ImageViewer.h
new file mode 100644
index 0000000..792817d
--- /dev/null
+++ b/HPPA/ImageViewer.h
@@ -0,0 +1,58 @@
+#ifndef IMAGE_VIEWER
+#define IMAGE_VIEWER
+
+#include "QGraphicsView"
+#include "qlabel.h"
+class ImageViewer :public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ ImageViewer(QWidget* pParent = NULL);
+ ~ImageViewer();
+
+
+ void DisplayFrameNumber(int frameNumber);
+
+
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+
+ void SetImage(QPixmap *image);
+ bool HasImage();
+
+ void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+ void scaling(qreal scaleFactor);
+
+ void zoomIn(); // Ŵ
+ void zoomOut(); // С
+ void zoom(float scaleFactor); // - scaleFactorŵı
+ void translate(QPointF delta); // ƽ
+
+ // ƽٶ
+ void setTranslateSpeed(qreal speed);
+ qreal translateSpeed() const;
+
+ // ŵ
+ void setZoomDelta(qreal delta);
+ qreal zoomDelta() const;
+protected:
+ QGraphicsScene *m_qtGraphicsScene;
+private:
+ QGraphicsPixmapItem *m_GraphicsPixmapItemHandle;
+ QLabel *m_framNumberLabel;//ʾʵʱɼ֡
+
+
+ qreal m_translateSpeed; // ƽٶ
+ qreal m_zoomDelta; // ŵ
+ bool m_bMouseTranslate; // ƽƱʶ
+ QPoint m_lastMousePos; // µλ
+ qreal m_scale; // ֵ
+
+
+signals:
+ void leftMouseButtonPressed(int, int);
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/ImagerPositionSimulation.cpp b/HPPA/ImagerPositionSimulation.cpp
new file mode 100644
index 0000000..31e981e
--- /dev/null
+++ b/HPPA/ImagerPositionSimulation.cpp
@@ -0,0 +1,103 @@
+#include "stdafx.h"
+
+#include "ImagerPositionSimulation.h"
+
+
+ImagerPositionSimulation::ImagerPositionSimulation(QWidget *parent) :
+QGraphicsView(parent)
+{
+ this->resize(1000, 500);
+
+ topLeftToLowerRight = nullptr;
+ topRightToLowerLeft = nullptr;
+
+ m_Scene = new QGraphicsScene(this);
+ this->setScene(m_Scene);
+
+ setSceneRect();
+
+
+ imager = new imagerSimulatioin();
+ m_Scene->addItem(imager);
+ //imager->setPos(-100, -100);
+
+ QBrush redBrush(Qt::red);
+ QPen outlinePen(Qt::black);
+
+ /*m_rectangle = m_Scene->addRect(0, 0, 100, 100, outlinePen, redBrush);
+ m_rectangle->setFlag(QGraphicsRectItem::ItemIsMovable);*/
+
+
+}
+
+ImagerPositionSimulation::~ImagerPositionSimulation()
+{
+
+}
+
+void ImagerPositionSimulation::setSceneRect()
+{
+ QRectF graphicsViewSize = viewport()->rect();
+
+ m_Scene->setSceneRect(-graphicsViewSize.width(), -graphicsViewSize.height(), graphicsViewSize.width(), graphicsViewSize.height());
+
+ drawX();
+}
+
+QRectF ImagerPositionSimulation::sceneRect()
+{
+ return m_Scene->sceneRect();
+}
+
+void ImagerPositionSimulation::mousePressEvent(QMouseEvent *event)
+{
+ QPoint viewPos = event->pos();
+
+
+ QGraphicsView::mousePressEvent(event);
+}
+
+void ImagerPositionSimulation::mouseReleaseEvent(QMouseEvent *event)
+{
+ QPoint viewPos = event->pos();
+
+ ////
+ //const type_info &x = typeid(imager);
+ //qDebug() << "---------------type_info: " << x.name() << x.raw_name() << x.hash_code();
+
+
+
+ //qDebug() << "---------------ImagerPositionSimulation view coordinate: " << viewPos;
+ //qDebug() << "---------------ImagerPositionSimulation scene coordinate: " << this->mapToScene(viewPos);
+
+
+ QGraphicsView::mouseReleaseEvent(event);
+}
+
+void ImagerPositionSimulation::drawX()
+{
+ QRectF rect = m_Scene->sceneRect();
+
+ QPen outlinePen(Qt::black);
+
+ if (topLeftToLowerRight == nullptr)
+ {
+ topLeftToLowerRight = m_Scene->addLine(rect.left(), rect.top(), rect.right(), rect.bottom(), outlinePen);
+ }
+ else
+ {
+ topLeftToLowerRight->setLine(rect.left(), rect.top(), rect.right(), rect.bottom());
+ }
+
+
+ if (topRightToLowerLeft == nullptr)
+ {
+ topRightToLowerLeft = m_Scene->addLine(rect.right(), rect.top(), rect.left(), rect.bottom(), outlinePen);
+ }
+ else
+ {
+ topRightToLowerLeft->setLine(rect.right(), rect.top(), rect.left(), rect.bottom());
+ }
+
+
+}
diff --git a/HPPA/ImagerPositionSimulation.h b/HPPA/ImagerPositionSimulation.h
new file mode 100644
index 0000000..a314b41
--- /dev/null
+++ b/HPPA/ImagerPositionSimulation.h
@@ -0,0 +1,35 @@
+#ifndef IMAGER_POSITION_SIMULATION
+#define IMAGER_POSITION_SIMULATION
+#include
+#include
+
+#include "imagerSimulatioin.h"
+
+class ImagerPositionSimulation :public QGraphicsView
+{
+ Q_OBJECT
+public:
+ ImagerPositionSimulation(QWidget* pParent = NULL);
+ ~ImagerPositionSimulation();
+
+ imagerSimulatioin *imager;
+
+ void drawX();
+
+ void setSceneRect();//QGraphicsViewviewportΪsceneRect
+
+ QRectF sceneRect();
+
+ void mousePressEvent(QMouseEvent *event);
+
+ void mouseReleaseEvent(QMouseEvent *event);
+
+private:
+ QGraphicsScene *m_Scene;
+ QGraphicsRectItem *m_rectangle;
+
+ QGraphicsLineItem *topLeftToLowerRight;
+ QGraphicsLineItem *topRightToLowerLeft;
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/QDoubleSlider.cpp b/HPPA/QDoubleSlider.cpp
new file mode 100644
index 0000000..3e98fa5
--- /dev/null
+++ b/HPPA/QDoubleSlider.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+#include "qDoubleSlider.h"
+QDoubleSlider::QDoubleSlider(QWidget* pParent /*= NULL*/) :
+QSlider(pParent),
+m_Multiplier(100.0)
+{
+ connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
+
+ setSingleStep(1);
+
+ setOrientation(Qt::Horizontal);
+ setFocusPolicy(Qt::NoFocus);
+}
+
+//ⷢ
+void QDoubleSlider::notifyValueChanged(int Value)
+{
+ emit valueChanged((double)Value / m_Multiplier);
+}
+
+//
+void QDoubleSlider::setValue(double Value, bool BlockSignals)
+{
+ QSlider::blockSignals(BlockSignals);
+
+ QSlider::setValue(Value * m_Multiplier);
+
+ if (!BlockSignals)
+ emit valueChanged(Value);
+
+ QSlider::blockSignals(false);
+}
+
+void QDoubleSlider::setRange(double Min, double Max)
+{
+ QSlider::setRange(Min * m_Multiplier, Max * m_Multiplier);
+
+ emit rangeChanged(Min, Max);
+}
+
+void QDoubleSlider::setMinimum(double Min)
+{
+ QSlider::setMinimum(Min * m_Multiplier);
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QDoubleSlider::minimum() const
+{
+ return QSlider::minimum() / m_Multiplier;
+}
+
+void QDoubleSlider::setMaximum(double Max)
+{
+ QSlider::setMaximum(Max * m_Multiplier);
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QDoubleSlider::maximum() const
+{
+ return QSlider::maximum() / m_Multiplier;
+}
+
+double QDoubleSlider::value() const
+{
+ int Value = QSlider::value();
+ return (double)Value / m_Multiplier;
+}
diff --git a/HPPA/QDoubleSlider.h b/HPPA/QDoubleSlider.h
new file mode 100644
index 0000000..fc4a863
--- /dev/null
+++ b/HPPA/QDoubleSlider.h
@@ -0,0 +1,32 @@
+#ifndef Q_DOUBLE_SLIDER_H
+#define Q_DOUBLE_SLIDER_H
+#include
+#include
+class QDoubleSlider : public QSlider
+{
+ Q_OBJECT
+
+public:
+ QDoubleSlider(QWidget* pParent = NULL);
+
+ void setRange(double Min, double Max);
+ void setMinimum(double Min);
+ double minimum() const;
+ void setMaximum(double Max);
+ double maximum() const;
+ double value() const;
+
+ public slots:
+ void notifyValueChanged(int value);//źvalueChanged(int)wrap
+ void setValue(double Value, bool BlockSignals = true);//QSlider::setValuewrap
+
+ private slots:
+
+signals :
+ void valueChanged(double Value);
+ void rangeChanged(double Min, double Max);
+
+private:
+ double m_Multiplier;
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/QMotorDoubleSlider.cpp b/HPPA/QMotorDoubleSlider.cpp
new file mode 100644
index 0000000..9dc5a96
--- /dev/null
+++ b/HPPA/QMotorDoubleSlider.cpp
@@ -0,0 +1,87 @@
+#include "stdafx.h"
+#include "QMotorDoubleSlider.h"
+QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :
+QSlider(pParent),
+//m_Multiplier(0.00054496986),//ϺũԺǰ0.00052734375/5=0.00010546875ĺȷֵΪ0.000544969862759644Ϊ0.00054496986/5=0.000108993972Ϊиеװ1Ҫ5
+m_Multiplier(0.00054496986),//˰ũ
+m_yMultiplier(0.000108993972)//
+{
+ connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
+
+ setSingleStep(1);
+
+ setOrientation(Qt::Horizontal);
+ setFocusPolicy(Qt::NoFocus);
+}
+
+//ⷢ
+void QMotorDoubleSlider::notifyValueChanged(int Value)
+{
+ emit valueChanged((double)Value * m_Multiplier);//////////
+}
+
+//
+void QMotorDoubleSlider::setValue(double Value, bool BlockSignals)
+{
+ QSlider::blockSignals(BlockSignals);
+
+ QSlider::setValue(Value / m_Multiplier);////////////
+
+ if (!BlockSignals)
+ emit valueChanged(Value);
+
+ QSlider::blockSignals(false);
+}
+
+void QMotorDoubleSlider::setRange(double Min, double Max)
+{
+ QSlider::setRange(Min / m_Multiplier, Max / m_Multiplier);//////
+
+ emit rangeChanged(Min, Max);
+}
+
+void QMotorDoubleSlider::setMinimum(double Min)
+{
+ QSlider::setMinimum(Min / m_Multiplier);//////
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QMotorDoubleSlider::minimum() const
+{
+ return QSlider::minimum() * m_Multiplier;/////
+}
+
+void QMotorDoubleSlider::setMaximum(double Max)
+{
+ QSlider::setMaximum(Max / m_Multiplier);//////
+
+ emit rangeChanged(minimum(), maximum());
+}
+
+double QMotorDoubleSlider::maximum() const
+{
+ return QSlider::maximum() * m_Multiplier;///////
+}
+
+double QMotorDoubleSlider::value() const
+{
+ int Value = QSlider::value();
+ return (double)Value * m_Multiplier;//////
+}
+
+double QMotorDoubleSlider::OriginalValue() const
+{
+ int Value = QSlider::value();
+ return (double)Value;
+}
+
+long QMotorDoubleSlider::getPositionPulse(double position)
+{
+ return position / m_Multiplier;
+}
+
+double QMotorDoubleSlider::getDistanceFromPulse(int pulse)
+{
+ return pulse * m_Multiplier;
+}
diff --git a/HPPA/QMotorDoubleSlider.h b/HPPA/QMotorDoubleSlider.h
new file mode 100644
index 0000000..da1b88a
--- /dev/null
+++ b/HPPA/QMotorDoubleSlider.h
@@ -0,0 +1,38 @@
+#ifndef Q_MOTOR_DOUBLE_SLIDER_H
+#define Q_MOTOR_DOUBLE_SLIDER_H
+#include
+#include
+class QMotorDoubleSlider : public QSlider
+{
+ Q_OBJECT
+
+public:
+ QMotorDoubleSlider(QWidget* pParent = NULL);
+
+ double m_Multiplier;//ݹʽ廻Ϊ룺1(m_Multiplier)=/(360/*ϸֱ)ַhttps://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
+ double m_yMultiplier;//ǣ1.8135mm
+
+ 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;//ֵҪʵʵֵǾ
+ long getPositionPulse(double position);//ݴľ뷵ֵ
+ double getDistanceFromPulse(int pulse);
+
+ public slots:
+ void notifyValueChanged(int value);//źvalueChanged(int)wrap
+ void setValue(double Value, bool BlockSignals = true);//QSlider::setValuewrap
+
+ private slots:
+
+signals :
+ void valueChanged(double Value);
+ void rangeChanged(double Min, double Max);
+
+private:
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/QYMotorDoubleSlider.cpp b/HPPA/QYMotorDoubleSlider.cpp
new file mode 100644
index 0000000..f8f4891
--- /dev/null
+++ b/HPPA/QYMotorDoubleSlider.cpp
@@ -0,0 +1,87 @@
+#include "stdafx.h"
+#include "QYMotorDoubleSlider.h"
+QYMotorDoubleSlider::QYMotorDoubleSlider(QWidget* pParent /*= NULL*/) :
+QSlider(pParent),
+//m_Multiplier(0.000108993972),//ϺũԺǰ0.00052734375/5=0.00010546875ĺȷֵΪ0.000544969862759644Ϊ0.00054496986/5=0.000108993972Ϊиеװ1Ҫ5
+m_Multiplier(0.000108993972),//˰ũ
+m_yMultiplier(0.000108993972)//
+{
+ connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
+
+ setSingleStep(1);
+
+ setOrientation(Qt::Horizontal);
+ setFocusPolicy(Qt::NoFocus);
+}
+
+//ⷢ
+void QYMotorDoubleSlider::notifyValueChanged(int Value)
+{
+ emit valueChanged((double)Value * m_Multiplier);//////////
+}
+
+//
+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;
+}
diff --git a/HPPA/QYMotorDoubleSlider.h b/HPPA/QYMotorDoubleSlider.h
new file mode 100644
index 0000000..bf7ff2e
--- /dev/null
+++ b/HPPA/QYMotorDoubleSlider.h
@@ -0,0 +1,38 @@
+#ifndef Q_YMOTOR_DOUBLE_SLIDER_H
+#define Q_YMOTOR_DOUBLE_SLIDER_H
+#include
+#include
+class QYMotorDoubleSlider : public QSlider//QYMotorDoubleSlider
+{
+ Q_OBJECT
+
+public:
+ QYMotorDoubleSlider(QWidget* pParent = NULL);
+
+ double m_Multiplier;//ݹʽ廻Ϊ룺1(m_Multiplier)=/(360/*ϸֱ)ַhttps://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
+ double m_yMultiplier;//ǣ1.8135mm
+
+ 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;//ֵҪʵʵֵǾ
+ long getPositionPulse(double position);//ݴľ뷵ֵ
+ double getDistanceFromPulse(int pulse);
+
+ public slots:
+ void notifyValueChanged(int value);//źvalueChanged(int)wrap
+ void setValue(double Value, bool BlockSignals = true);//QSlider::setValuewrap
+
+ private slots:
+
+signals :
+ void valueChanged(double Value);
+ void rangeChanged(double Min, double Max);
+
+private:
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/RgbCameraOperation.cpp b/HPPA/RgbCameraOperation.cpp
new file mode 100644
index 0000000..ab24e12
--- /dev/null
+++ b/HPPA/RgbCameraOperation.cpp
@@ -0,0 +1,68 @@
+#include "stdafx.h"
+#include "RgbCameraOperation.h"
+
+RgbCameraOperation::RgbCameraOperation()
+{
+ cam = nullptr;
+ m_ImageProcessor = new ImageProcessor();
+ m_func = nullptr;
+}
+
+RgbCameraOperation::~RgbCameraOperation()
+{
+}
+
+void RgbCameraOperation::OpenCamera()
+{
+ std::cout << "ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam = new cv::VideoCapture(0);
+
+ record = true;
+
+ while (record)
+ {
+ //std::cout << "ɼӰ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam->read(frame);
+ m_qImage = m_ImageProcessor->Mat2QImage(frame);
+
+ emit PlotSignal();
+ }
+
+ cam->release();
+
+ emit CamClosed();
+
+}
+
+void RgbCameraOperation::OpenCamera_callback()
+{
+ std::cout << "ͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam = new cv::VideoCapture(0);
+
+ record = true;
+
+ while (record)
+ {
+ //std::cout << "ɼӰ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+ cam->read(frame);
+ m_qImage = m_ImageProcessor->Mat2QImage(frame);
+
+ if(m_func)
+ m_func();
+ }
+
+ cam->release();
+}
+
+
+void RgbCameraOperation::setCallback(void(*func)())
+{
+ m_func = func;
+}
+
+void RgbCameraOperation::CloseCamera()
+{
+ std::cout << "رͷ+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
+
+ record = false;
+}
diff --git a/HPPA/RgbCameraOperation.h b/HPPA/RgbCameraOperation.h
new file mode 100644
index 0000000..d993049
--- /dev/null
+++ b/HPPA/RgbCameraOperation.h
@@ -0,0 +1,47 @@
+#pragma once
+#ifndef RGBCAMERAOPERATION_H
+#define RGBCAMERAOPERATION_H
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include "imageProcessor.h"
+
+typedef void(*func)();
+
+class RgbCameraOperation:public QObject
+{
+ Q_OBJECT
+
+public:
+ RgbCameraOperation();
+ ~RgbCameraOperation();
+
+ QImage m_qImage;
+ void setCallback(void(*func)());
+
+private:
+ cv::Mat frame;
+ cv::VideoCapture *cam;
+
+ func m_func;
+
+ ImageProcessor* m_ImageProcessor;
+
+ bool record;
+
+public slots:
+ void OpenCamera();
+ void OpenCamera_callback();//ʹźŶʹûص֪ͨˢƵ
+ void CloseCamera();
+
+signals:
+ void PlotSignal();
+
+ void CamClosed();
+};
+#endif // !RGBCAMERAOPERATION_H
diff --git a/HPPA/cpp.hint b/HPPA/cpp.hint
new file mode 100644
index 0000000..78ee111
--- /dev/null
+++ b/HPPA/cpp.hint
@@ -0,0 +1,5 @@
+// 提示文件帮助 Visual Studio IDE 解释 Visual C++ 标识符,
+// 如函数和宏的名称。
+// 有关详细信息,请参见 https://go.microsoft.com/fwlink/?linkid=865984
+#define Q_OBJECT public: QT_WARNING_PUSH Q_OBJECT_NO_OVERRIDE_WARNING static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); QT_TR_FUNCTIONS private: Q_OBJECT_NO_ATTRIBUTES_WARNING Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); QT_WARNING_POP struct QPrivateSignal {}; QT_ANNOTATE_CLASS(qt_qobject, "")
+#define Q_OBJECT
diff --git a/HPPA/fileOperation.cpp b/HPPA/fileOperation.cpp
new file mode 100644
index 0000000..8c82ed5
--- /dev/null
+++ b/HPPA/fileOperation.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+#include "fileOperation.h"
+
+FileOperation::FileOperation()
+{
+
+}
+
+FileOperation::~FileOperation()
+{
+
+}
+
+string FileOperation::getDirectoryOfExe()
+{
+ string exeName = _pgmptr;
+
+ string directory;
+ const size_t last_slash_idx = exeName.rfind('\\');
+ if (std::string::npos != last_slash_idx)
+ {
+ directory = exeName.substr(0, last_slash_idx);
+ }
+
+ return directory;
+}
+
+string FileOperation::getDirectoryFromString(string directory)
+{
+ QString tmp = QString::fromStdString(directory);
+ QDir dir;
+ if (!dir.exists(tmp))
+ {
+ bool res = dir.mkpath(tmp);
+ //qDebug() << "½Ŀ¼Ƿɹ" << res;
+ }
+ return directory;
+}
+
+bool FileOperation::copyFile(QString source, QString target)
+{
+ string source1 = source.toStdString();
+ string target1 = target.toStdString();
+
+ char buffer[256];
+ int n;
+
+ ifstream in(source1, ios_base::in | ios_base::binary);
+ ofstream out(target1, ios_base::out | ios_base::binary);
+
+ if (!in || !out){ cerr << "Open File Failure,Please Try Again!"; exit(1); }
+
+ while (!in.eof())
+ {
+ in.read(buffer, 256); //ļжȡ256ֽڵݵ
+ n = in.gcount(); //һв֪ȡ˶ֽڵݣúһ¡
+ out.write(buffer, n); //дǸֽڵ
+ }
+ in.close();
+ out.close();
+
+ string::size_type idx;
+
+ idx = source1.find("hdr");
+ if (idx == string::npos) //ڡ
+ emit CopyFinishedSignal();
+
+ return 1;
+}
diff --git a/HPPA/fileOperation.h b/HPPA/fileOperation.h
new file mode 100644
index 0000000..170524a
--- /dev/null
+++ b/HPPA/fileOperation.h
@@ -0,0 +1,41 @@
+#ifndef FILE_OPERATIOIN_H
+#define FILE_OPERATIOIN_H
+
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+class FileOperation :public QObject
+{
+ Q_OBJECT
+
+public:
+ FileOperation();
+ ~FileOperation();
+
+ string getDirectoryOfExe();//getDirectoryOfExe
+ string getDirectoryFromString(string directory="C:/HPPA_image");
+
+
+
+
+public Q_SLOTS:
+ bool copyFile(QString source, QString target);
+
+ /*bool moveFile(const string& source, const string& target);
+ bool deleteFile(const string& path);
+ bool hasFile(const string& path);
+
+ bool copyDirectory(const string& source, const string& target);
+ bool moveDirectory(const string& source, const string& target);
+ bool deleteDirectory(const string& path);*/
+
+
+
+signals:
+ void CopyFinishedSignal();//Ӱź
+};
+#endif
diff --git a/HPPA/focusWindow.cpp b/HPPA/focusWindow.cpp
new file mode 100644
index 0000000..f49bb9d
--- /dev/null
+++ b/HPPA/focusWindow.cpp
@@ -0,0 +1,297 @@
+#include "stdafx.h"
+#include "focusWindow.h"
+
+focusWindow::focusWindow(QWidget *parent, ResononImager * imager)
+{
+ ui.setupUi(this);
+
+ disableBeforeConnect(true);
+
+ setAttribute(Qt::WA_DeleteOnClose);//ùرմ͵ô
+
+ m_Imager = imager;
+ m_FocusState = 0;
+ m_ctrlFocusMotor = nullptr;
+
+ m_AutoFocusThread = new QThread();
+
+ connect(this->ui.connectMotor_btn, SIGNAL(clicked()), this, SLOT(onConnectMotor()));
+ connect(this->ui.logicZero_btn, SIGNAL(clicked()), this, SLOT(onMove2MotorLogicZero()));
+ connect(this->ui.max_btn, SIGNAL(clicked()), this, SLOT(onMove2MotorMax()));
+ connect(this->ui.add_btn, SIGNAL(clicked()), this, SLOT(onAdd()));
+ connect(this->ui.subtract_btn, SIGNAL(clicked()), this, SLOT(onSubtract()));
+ connect(this->ui.ultrasound_radioButton, SIGNAL(released()), this, SLOT(onUltrasound_radioButton()));
+ connect(this->ui.autoFocus_btn, SIGNAL(clicked()), this, SLOT(onAutoFocus()));
+ connect(this->ui.manualFocus_btn, SIGNAL(clicked()), this, SLOT(onManualFocus()));
+
+ //ҿôڣʾ
+ foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
+ {
+ QSerialPort serial;
+ serial.setPort(info);
+ if (serial.open(QIODevice::ReadWrite))
+ {
+ ui.motorPort_comboBox->addItem(serial.portName());
+ ui.ultrasoundPort_comboBox->addItem(serial.portName());
+ serial.close();
+ }
+ }
+
+ //Զ
+ ui.autoFocusProgress_progressBar->setMinimum(0);
+ ui.autoFocusProgress_progressBar->setMaximum(100);
+ ui.autoFocusProgress_progressBar->reset();
+}
+
+focusWindow::~focusWindow()
+{
+ printf("destroy focusWindow-------------------------\n");
+
+ delete m_ctrlFocusMotor;
+ //delete thread1, progressThread;
+}
+
+void focusWindow::disableBeforeConnect(bool disable)
+{
+ ui.controlMotor_groupBox->setDisabled(disable);
+ ui.autoFocus_btn->setDisabled(disable);
+}
+
+bool test(void *pCaller, int *x, int *y, void **pvdata)
+{
+ focusWindow *p = (focusWindow *)pCaller;
+
+ p->m_Imager->GetImageSize(*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();
+
+
+ BYTE *pbData = (BYTE*)pusData;
+ *pvdata = pbData;
+ return true;
+}
+
+void focusWindow::onConnectMotor()
+{
+ if (m_ctrlFocusMotor != nullptr)
+ {
+ printf("ظ-------------------------\n");
+ return;
+ }
+
+ bool isUltrasound = ui.ultrasound_radioButton->isChecked();
+
+ QString motorPortTmp = ui.motorPort_comboBox->currentText();
+ QString ultrasoundPortTmp = ui.ultrasoundPort_comboBox->currentText();
+
+ QRegExp rx("\\d+$");
+ rx.indexIn(motorPortTmp, 0);
+ int motorPort = rx.cap(0).toInt();
+ rx.indexIn(ultrasoundPortTmp, 0);
+ int ultrasoundPort = rx.cap(0).toInt();
+
+ int minPos = 120;
+ int maxPos = 1000;
+
+ if (isUltrasound)
+ {
+ PortInfo motor;
+ motor.iPortType = 0;
+ motor.indexParity = 0;
+
+ motor.iPortNumber = motorPort;
+ motor.indexBaudRate = 0x13;
+ motor.indexBytesize = 3;
+ motor.indexStopBits = 0;
+
+ PortInfo ultrasound;
+ ultrasound.iPortType = 0;
+ ultrasound.indexParity = 0;
+ ultrasound.iPortNumber = ultrasoundPort;
+ ultrasound.indexBaudRate = 0x0C;
+ ultrasound.indexBytesize = 3;
+ ultrasound.indexStopBits = 0;
+
+ m_ctrlFocusMotor = new CFocusMotorControl();
+
+ m_ctrlFocusMotor->SetLogicZero(minPos);
+ m_ctrlFocusMotor->SetLimit(minPos, maxPos);
+ m_iMotorMaxPos = maxPos;
+ m_ctrlFocusMotor->InitSystem(motor, ultrasound, test, this);
+ m_ctrlFocusMotor->MoveToLogicZero();
+ }
+ else
+ {
+ PortInfo motor;
+ motor.iPortType = 0;
+ motor.indexParity = 0;
+ motor.iPortNumber = motorPort;
+ motor.indexBaudRate = 0x13;
+ motor.indexBytesize = 3;
+ motor.indexStopBits = 0;
+
+ m_ctrlFocusMotor = new CFocusMotorControl();
+
+ m_ctrlFocusMotor->SetLogicZero(minPos);
+ m_ctrlFocusMotor->SetLimit(minPos, maxPos);
+ m_iMotorMaxPos = maxPos;
+ m_ctrlFocusMotor->InitSystem(motor, test, this);
+ m_ctrlFocusMotor->MoveToLogicZero();
+ }
+
+ disableBeforeConnect(false);
+}
+
+void focusWindow::onMove2MotorLogicZero()
+{
+ m_ctrlFocusMotor->MoveToLogicZero();
+}
+
+void focusWindow::onMove2MotorMax()
+{
+ m_ctrlFocusMotor->MoveToPos(m_iMotorMaxPos);
+}
+
+void focusWindow::onAdd()
+{
+ DriverInfo di;
+ m_ctrlFocusMotor->GetDriverStatus(di);
+
+ int stepSize = ui.addStepSize_lineEdit->text().toInt();
+
+ m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + stepSize);
+
+ m_ctrlFocusMotor->GetDriverStatus(di);
+ printf("λã%d", di.iAbsPosition);
+ std::cout << "ť" << std::endl;
+}
+
+void focusWindow::onSubtract()
+{
+ DriverInfo di;
+ m_ctrlFocusMotor->GetDriverStatus(di);
+
+ int stepSize = ui.subtractStepSize_lineEdit->text().toInt();
+
+ m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - stepSize);
+
+ m_ctrlFocusMotor->GetDriverStatus(di);
+ printf("λã%d", di.iAbsPosition);
+}
+
+void focusWindow::onAutoFocus()
+{
+ bool isUltrasound = ui.ultrasound_radioButton->isChecked();
+ WorkerThread2 *thread1 = new WorkerThread2(m_ctrlFocusMotor, isUltrasound);
+
+ connect(thread1, SIGNAL(AutoFocusFinishedSignal()), this, SLOT(onAutoFocusFinished()));
+
+ thread1->start();
+ this->setDisabled(true);
+
+ WorkerThread4 *progressThread = new WorkerThread4(m_ctrlFocusMotor);
+ connect(progressThread, SIGNAL(AutoFocusProgressSignal(int)), this, SLOT(onAutoFocusProgress(int)));
+ progressThread->start();
+ ui.autoFocusProgress_progressBar->reset();
+}
+
+void focusWindow::onManualFocus()
+{
+ m_FocusState += 1;
+ std::cout << "ť" << std::endl;
+
+
+ if (m_FocusState % 2 == 1)
+ {
+ //ʼ
+ emit StartManualFocusSignal(1);
+ ui.manualFocus_btn->setText(QString::fromLocal8Bit("ֹͣ"));
+
+ ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
+
+ //std::cout << "------------------------------------------" << m_FocusState << std::endl;
+ }
+ else
+ {
+ emit StartManualFocusSignal(0);
+ m_Imager->setFocusControlState(false);
+
+ ui.manualFocus_btn->setText(QString::fromLocal8Bit(""));
+
+ ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
+ }
+}
+
+void focusWindow::onAutoFocusFinished()
+{
+ this->setDisabled(false);
+}
+
+void focusWindow::onAutoFocusProgress(int progress)
+{
+ //std::cout << "ȣ" << progress << std::endl;
+
+ ui.autoFocusProgress_progressBar->setValue(progress);
+}
+
+void focusWindow::onUltrasound_radioButton()
+{
+ bool isUltrasound = ui.ultrasound_radioButton->isChecked();
+
+ if (isUltrasound)
+ {
+ ui.ultrasoundPort_comboBox->setEnabled(true);
+ }
+ else
+ {
+ ui.ultrasoundPort_comboBox->setEnabled(false);
+ }
+}
+
+WorkerThread2::WorkerThread2(CFocusMotorControl * ctrlFocusMotor, bool isUltrasound)
+{
+ m_ctrlFocusMotor = ctrlFocusMotor;
+ m_bIsUltrasound = isUltrasound;
+}
+
+void WorkerThread2::run()
+{
+ if (m_bIsUltrasound)
+ {
+ m_ctrlFocusMotor->SetFitParams(0.0017, 0.3277);
+ m_ctrlFocusMotor->StartAutoFocus(5, 2);
+ }
+ else
+ {
+ m_ctrlFocusMotor->StartAutoFocus(820, 910, 10, 2);
+ }
+
+ emit AutoFocusFinishedSignal();
+}
+
+WorkerThread4::WorkerThread4(CFocusMotorControl * ctrlFocusMotor)
+{
+ m_ctrlFocusMotor = ctrlFocusMotor;
+}
+
+void WorkerThread4::run()
+{
+ while (true)
+ {
+ int progress = m_ctrlFocusMotor->GetProgressIndex();
+
+ //std::cout << "WorkerThread4::run----Զȣ" << progress << std::endl;
+
+ emit AutoFocusProgressSignal(progress);
+ if (progress == 100)
+ {
+ //std::cout << "Զɣ" << std::endl;
+ break;
+ }
+
+ msleep(200);
+ }
+}
\ No newline at end of file
diff --git a/HPPA/focusWindow.h b/HPPA/focusWindow.h
new file mode 100644
index 0000000..29846e8
--- /dev/null
+++ b/HPPA/focusWindow.h
@@ -0,0 +1,96 @@
+#pragma once
+
+#include "windows.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ui_FocusDialog.h"
+#include "AbstractPortMiscDefines.h"
+#include "CFocusMotorControl.h"
+
+#include "resononImager.h"
+
+class focusWindow:public QDialog
+{
+ Q_OBJECT
+
+public:
+ focusWindow(QWidget *parent = Q_NULLPTR);
+ focusWindow(QWidget *parent, ResononImager * imager);
+ ~focusWindow();
+
+ ResononImager * m_Imager;
+
+
+private:
+ Ui::focusDialog ui;
+ QThread *m_AutoFocusThread;
+ int m_FocusState;
+
+ int m_iMotorMaxPos;
+
+ CFocusMotorControl* m_ctrlFocusMotor;
+
+ void disableBeforeConnect(bool disable);
+
+public Q_SLOTS:
+ void onConnectMotor();
+ void onMove2MotorLogicZero();
+ void onMove2MotorMax();
+ void onAdd();
+ void onSubtract();
+ void onAutoFocus();
+ void onManualFocus();
+ void onAutoFocusFinished();
+ void onAutoFocusProgress(int progress);
+ void onUltrasound_radioButton();
+
+signals:
+ void StartManualFocusSignal(int);//1ʼ0ֹͣ
+};
+
+class WorkerThread2 : public QThread
+{
+ Q_OBJECT
+private:
+ bool m_bIsUltrasound;
+
+public:
+ WorkerThread2(CFocusMotorControl * ctrlFocusMotor,bool isUltrasound);
+ CFocusMotorControl *m_ctrlFocusMotor;
+
+protected:
+ void run();
+
+signals:
+ void AutoFocusFinishedSignal();
+};
+
+class WorkerThread4 : public QThread
+{
+ Q_OBJECT
+private:
+
+public:
+ WorkerThread4(CFocusMotorControl * ctrlFocusMotor);
+ CFocusMotorControl *m_ctrlFocusMotor;
+
+protected:
+ void run();
+
+signals:
+ void AutoFocusProgressSignal(int);
+};
diff --git a/HPPA/image2display.cpp b/HPPA/image2display.cpp
new file mode 100644
index 0000000..971bff6
--- /dev/null
+++ b/HPPA/image2display.cpp
@@ -0,0 +1,193 @@
+#include "stdafx.h"
+#include "image2display.h"
+#include
+
+CImage::CImage(QWidget* pParent) :QObject(pParent)
+{
+ m_QRgbImage = nullptr;
+ m_matRgbImage = nullptr;
+ m_matFocusGrayImage = nullptr;
+ m_qimageFocusGrayImage = nullptr;
+}
+
+void CImage::SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber)
+{
+ using namespace cv;
+
+ if (m_QRgbImage != nullptr)
+ {
+ delete m_QRgbImage;//⣿
+ }
+ //m_QRgbImage = new QImage(Sample, FrameNumber, QImage::Format_RGB888);
+
+
+ if (m_matRgbImage != nullptr)
+ {
+ delete m_matRgbImage;
+ }
+ m_matRgbImage = new Mat(FrameNumber, Sample, CV_16UC3, Scalar(0, 0, 0));
+
+
+
+
+
+ if (m_qimageFocusGrayImage == nullptr)
+ {
+ m_qimageFocusGrayImage = new QImage(Sample, BandCount, QImage::Format_RGB32);
+ }
+
+
+ if (m_matFocusGrayImage == nullptr)
+ {
+ m_matFocusGrayImage = new Mat(BandCount, Sample, CV_16U, Scalar(0));
+
+ //cv::Mat matAdjustPreview = Mat::zeros(BandCount, Sample, CV_16U);
+ }
+
+ //cv::Mat matAdjustPreview = Mat::zeros(BandCount, Sample, CV_16U);
+ //m_matFocusGrayImage = matAdjustPreview;
+
+
+
+
+
+
+
+
+ std::cout << "֡" << FrameNumber << std::endl;
+
+ m_iFrameCounter = 0;//ÿζΪ0
+ m_iSampleNumber = Sample;
+ m_iBandNumber = BandCount;
+ m_iFrameNumber = FrameNumber;
+
+ //std::cout << "rgbӰڴַΪ" << m_QRgbImage << std::endl;
+}
+
+void CImage::FillRgbImage(unsigned short *datacube)
+{
+ //uchar==unsigned charڴС1ֽڣΧΪ0-255
+ //uchar * imagebits24 = m_QRgbImage->bits();
+
+ //uchar * imagebits24 = m_QRgbImage->scanLine(m_iFrameCounter);//??????????????????????????????????????????????????????????????????????
+
+ unsigned short r, g, b;
+
+ for (int j = 0; j < m_iSampleNumber; j++)
+ {
+ //std::cout << "rgbͼд֡" << j << std::endl;
+
+ //ȡֵһ֡ӰУҵrgbԪֵ
+ r = *(datacube + 121 * m_iSampleNumber + j);
+ g = *(datacube + 79 * m_iSampleNumber + j);
+ b = *(datacube + 40 * m_iSampleNumber + j);
+
+ //Ԫֵֵcv::MatУԪֵhttps://zhuanlan.zhihu.com/p/51842288
+ //int dataType = m_matRgbImage->type();//ΪCV_16UC3ʱ18
+ //std::cout << "m_matRgbImageΪ" << dataType << std::endl;
+ if (m_matRgbImage->type() == CV_16UC3)
+ {
+ //std::cout << "ֵ" << std::endl;
+ m_matRgbImage->at(m_iFrameCounter, j)[2] = r;
+ m_matRgbImage->at(m_iFrameCounter, j)[1] = g;
+ m_matRgbImage->at(m_iFrameCounter, j)[0] = b;
+ }
+
+
+ ////Ԫֵ4095һ255ķΧֵQImage
+ //imagebits24[j * 3] = uchar(r * 255 / 4095);
+ //imagebits24[j * 3 + 1] = uchar(g * 255 / 4095);
+ //imagebits24[j * 3 + 2] = uchar(b * 255 / 4095);
+ }
+
+ m_iFrameCounter++;
+
+ //rgbͼƬ
+ if (m_iFrameCounter % m_iFramerate == 0 || m_iFrameCounter == m_iFrameNumber - 1)
+ {
+ ////ļ
+ //FileOperation * fileOperation = new FileOperation();
+ //string directory = fileOperation->getDirectoryOfExe();
+ //string rgbFilePathStrech = directory + "\\tmp_image_strech.png";//ûͼƬ
+ //string rgbFilePathNoStrech = directory + "\\tmp_image_no_strech.png";//ͼƬ
+
+ //m_QRgbImage->save(QString::fromStdString(rgbFilePathNoStrech), "PNG");
+
+ //cv::imwrite(rgbFilePathNoStrech, *m_matRgbImage);
+ //cv::imwrite(rgbFilePathStrech, CStretch(*m_matRgbImage, 0.01));
+
+ }
+}
+
+void CImage::FillFocusGrayImage(unsigned short * datacube)
+{
+ int rowCount = m_matFocusGrayImage->rows;
+ int colCount = m_matFocusGrayImage->cols;
+ for (unsigned short i = 0; i < m_matFocusGrayImage->rows; i++)
+ {
+ for (unsigned short j = 0; j < m_matFocusGrayImage->cols; j++)
+ {
+ //m_matFocusGrayImage->at(i, j) = *(datacube + m_matFocusGrayImage->cols*i + j);
+ m_matFocusGrayImage->at(i, j) = datacube[m_matFocusGrayImage->cols*i + j];
+ }
+ }
+
+
+
+ //int rowCount = m_matFocusGrayImage.rows;
+ //int colCount = m_matFocusGrayImage.cols;
+ ////memcpy(m_matFocusGrayImage.data, datacube, rowCount*colCount);
+ //for (unsigned short i = 0; i < m_matFocusGrayImage.rows; i++)
+ //{
+ // for (unsigned short j = 0; j < m_matFocusGrayImage.cols; j++)
+ // {
+ // m_matFocusGrayImage.at(i, j) = *(datacube + m_matFocusGrayImage.cols*i + j);
+ // //m_matFocusGrayImage.at(i, j) = datacube[colCount*i + j];
+ // }
+ //}
+
+ //matļ
+ //cv::imwrite("D:/delete/2222222222/test.bmp", m_matFocusGrayImage);
+}
+
+void CImage::FillFocusGrayQImage(unsigned short * datacube)
+{
+ float two_eight = pow(2.0, 8);
+ float two_sixteen = pow(2.0, 12);
+
+ int width = m_qimageFocusGrayImage->width();
+ int height = m_qimageFocusGrayImage->height();
+ for (unsigned short i = 0; i < height; i++)
+ {
+ for (unsigned short j = 0; j < width; j++)
+ {
+ //uint tmp = (two_eight* *(datacube + width * i + j)) / two_sixteen;
+ uint tmp = (two_eight* datacube[width*i + j]) / two_sixteen;
+ //uint tmp = datacube[width*i + j];
+
+
+ //m_qimageFocusGrayImage->setPixel(j, i, tmp);
+ m_qimageFocusGrayImage->setPixel(j, i, qRgb((unsigned char)tmp, (unsigned char)tmp, (unsigned char)tmp));
+ }
+ }
+
+ m_qimageFocusGrayImage->save("D:/delete/2222222222/test.bmp");
+
+
+
+
+ /*float two_eight = pow(2.0, 8);
+ float two_sixteen = pow(2.0, 16);
+ QImage *qi = new QImage(imwidth, imheight, QImage::Format_RGB32);
+ for (int i = 0; i < imheight; i++)
+ {
+ for (int j = 0; j < imwidth; j++)
+ {
+ floatData[i*imwidth + j] = (two_eight* floatData[i*imwidth + j]) / two_sixteen;
+ qi->setPixel(j, i, qRgb((unsigned char)floatData[i*imwidth + j], (unsigned char)floatData[i*imwidth + j], (unsigned char)floatData[i*imwidth + j]));
+
+
+ }
+ }*/
+
+}
diff --git a/HPPA/image2display.h b/HPPA/image2display.h
new file mode 100644
index 0000000..5d7594a
--- /dev/null
+++ b/HPPA/image2display.h
@@ -0,0 +1,58 @@
+#ifndef CIMAGE
+#define CIMAGE
+#include
+
+
+#include //ж
+//#include
+//#include
+
+#include "QObject"
+#include "QImage"
+
+#include "fileOperation.h"
+
+
+class CImage :public QObject
+{
+ Q_OBJECT
+public:
+ CImage(QWidget* pParent = NULL);
+ //~CImage();
+ void SetRgbImageWidthAndHeight(int BandCount, int Sample, int FrameNumber);
+ void FillRgbImage(unsigned short *datacube);
+ void FillFocusGrayImage(unsigned short *datacube);
+ void FillFocusGrayQImage(unsigned short * datacube);
+
+ QImage *m_QRgbImage;
+ cv::Mat *m_matRgbImage;
+
+ QImage *m_qimageFocusGrayImage;
+ cv::Mat *m_matFocusGrayImage;//ڵʱʾһ֡ĻҶͼ
+ //cv::Mat m_matFocusGrayImage;//ڵʱʾһ֡ĻҶͼ
+
+
+ //Ƹrgbͼڼ֡У
+ //ҪΪ01úSetRgbImageWidthAndHeight2ÿοʼǰ
+ int m_iFrameCounter;
+
+
+ int m_iFramerate;//
+
+
+protected:
+
+private:
+ int m_iSampleNumber;//
+ int m_iBandNumber;//
+
+ int m_iFrameNumber;//
+
+public slots:
+
+signals :
+ void sendstr(QString str);
+ void sendstr1(QString str);
+ void refreslabelimg(QImage* img1);
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/imageProcessor.cpp b/HPPA/imageProcessor.cpp
new file mode 100644
index 0000000..4c1b6c5
--- /dev/null
+++ b/HPPA/imageProcessor.cpp
@@ -0,0 +1,169 @@
+#include "stdafx.h"
+#include "imageProcessor.h"
+
+ImageProcessor::ImageProcessor()
+{
+}
+
+ImageProcessor::~ImageProcessor()
+{
+}
+
+std::vector ImageProcessor::CHistogram(const cv::Mat img)
+{
+ cv::Mat mimg = img.clone();
+ int rows = mimg.rows;
+ int cols = mimg.cols;
+ //ͳÿҶȳֵĴ
+ std::vector hisnum(4096, 0);//
+ for (int i(0); i < rows; ++i)
+ {
+ //std::cout << "i" << i << std::endl;
+ for (int j(0); j < cols; ++j)
+ {
+ //std::cout << "j" << j << std::endl;
+ unsigned short gv = mimg.at(i, j);
+ //std::cout << "gvֵ" << gv << std::endl;
+
+ //ԷиֵͷǸڿ۳пΪֵ
+ //matΪCV_16UC3иֵʱֵΪ65535
+ if (gv > 4096)
+ {
+ ++hisnum[0];
+ }
+ else
+ {
+ ++hisnum[gv];
+ }
+
+
+ }
+ }
+ //ʼҶƵ
+ long int pnum = rows * cols;
+ std::vector hisp;
+ for (int i(0); i < hisnum.size(); ++i)
+ {
+ float p = (float)hisnum[i] / pnum;
+ hisp.push_back(cv::Point2f(i, p));
+ }
+ return hisp;
+}
+
+uint ImageProcessor::MaxRatio(const std::vector data, const float ratio)
+{
+ float maxp(0);
+ uint outnum(0);
+ for (int i(data.size() - 1); i >= 0; --i)
+ {
+ maxp += data[i].y;
+ if (maxp >= ratio)
+ {
+ outnum = i;
+ break;
+ }
+ }
+ return outnum;
+}
+
+uint ImageProcessor::MinRatio(const std::vector data, const float ratio)
+{
+ float minp(0);
+ uint outnum(0);
+ for (int i(0); i < data.size(); ++i)
+ {
+ minp += data[i].y;
+ if (minp >= ratio)
+ {
+ outnum = i;
+ break;
+ }
+ }
+ return outnum;
+}
+
+QImage ImageProcessor::Mat2QImage(cv::Mat cvImg)//https://www.cnblogs.com/annt/p/ant003.html
+{
+ QImage qImg;
+ if (cvImg.channels() == 3) //3 channels color image
+ {
+ cv::cvtColor(cvImg, cvImg, CV_BGR2RGB);
+ qImg = QImage((const unsigned char*)(cvImg.data),
+ cvImg.cols, cvImg.rows,
+ cvImg.cols*cvImg.channels(),
+ QImage::Format_RGB888);
+ }
+ else if (cvImg.channels() == 1) //grayscale image
+ {
+ qImg = QImage((const unsigned char*)(cvImg.data),
+ cvImg.cols, cvImg.rows,
+ cvImg.cols*cvImg.channels(),
+ QImage::Format_Indexed8);
+ }
+ else
+ {
+ qImg = QImage((const unsigned char*)(cvImg.data),
+ cvImg.cols, cvImg.rows,
+ cvImg.cols*cvImg.channels(),
+ QImage::Format_RGB888);
+ }
+
+ return qImg;
+}
+
+cv::Mat ImageProcessor::CStretchDeal(const cv::Mat img, const uint minnum, const uint maxnum)
+{
+ cv::Mat mimg = img.clone();
+ int rows = mimg.rows;
+ int cols = mimg.cols;
+ cv::Mat nimg = cv::Mat::zeros(rows, cols, CV_8U);
+ //һ
+ float dertnum = maxnum - minnum;
+ //ʼ
+ for (int i(0); i < rows; ++i)
+ {
+ for (int j(0); j < cols; ++j)
+ {
+ unsigned short a = mimg.at(i, j);
+ //СratioӦֵȡ0
+ if (a <= minnum)
+ nimg.at(i, j) = 0;
+ //ratioֵӦֵȡ255
+ else if (a >= maxnum)
+ nimg.at(i, j) = 255;
+ //мֵ쵽0-255
+ else
+ nimg.at(i, j) = 255 * (mimg.at(i, j) - minnum) / dertnum;
+ }
+ }
+ return nimg;
+}
+
+cv::Mat ImageProcessor::CStretch(const cv::Mat img, const float ratio)
+{
+ //ӰRGBҶֱͼ
+ cv::Mat mimg = img.clone();
+ cv::Mat bgr[3];
+ split(mimg, bgr);
+ std::vector hb = CHistogram(bgr[0]);
+ std::vector hg = CHistogram(bgr[1]);
+ std::vector hr = CHistogram(bgr[2]);
+ //ͳֱͼۼƵratioֵӦĻҶ
+ uint minb = MinRatio(hb, ratio);
+ uint ming = MinRatio(hg, ratio);
+ uint minr = MinRatio(hr, ratio);
+ uint maxb = MaxRatio(hb, ratio);
+ uint maxg = MaxRatio(hg, ratio);
+ uint maxr = MaxRatio(hr, ratio);
+ //ʼ칤
+ cv::Mat b, g, r;
+ b = CStretchDeal(bgr[0], minb, maxb);
+ g = CStretchDeal(bgr[1], ming, maxg);
+ r = CStretchDeal(bgr[2], minr, maxr);
+ //ϲ
+ cv::Mat newbgr;
+ newbgr.create(img.rows, img.cols, CV_32FC3);
+ cv::Mat nbgr[3] = { b, g, r };
+ merge(nbgr, 3, newbgr);
+ return newbgr;
+}
diff --git a/HPPA/imageProcessor.h b/HPPA/imageProcessor.h
new file mode 100644
index 0000000..c99fa73
--- /dev/null
+++ b/HPPA/imageProcessor.h
@@ -0,0 +1,41 @@
+#pragma once
+#ifndef IMAGEPROCESSOR
+#define IMAGEPROCESSOR
+
+#include //ж
+//#include
+//#include
+
+#include "QObject"
+#include "QImage"
+
+
+class ImageProcessor
+{
+public:
+ ImageProcessor();
+ ~ImageProcessor();
+
+ QImage Mat2QImage(cv::Mat cvImg);//https://www.cnblogs.com/annt/p/ant003.html
+
+ //envi 2%ԭ
+ //gdal汾 https://blog.csdn.net/HB_Programmer/article/details/82020703?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
+ //opencv汾 https://blog.csdn.net/qq_41824159/article/details/105469986
+ cv::Mat CStretchDeal(const cv::Mat img, const uint minnum, const uint maxnum);
+ uint MaxRatio(const std::vector data, const float ratio);
+ uint MinRatio(const std::vector data, const float ratio);
+ std::vector CHistogram(const cv::Mat img);
+ cv::Mat CStretch(const cv::Mat img, const float ratio);
+
+protected:
+
+private:
+
+
+
+public slots:
+
+signals:
+
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/imagerSimulatioin.cpp b/HPPA/imagerSimulatioin.cpp
new file mode 100644
index 0000000..a930241
--- /dev/null
+++ b/HPPA/imagerSimulatioin.cpp
@@ -0,0 +1,130 @@
+#include "stdafx.h"
+#include "imagerSimulatioin.h"
+
+imagerSimulatioin::imagerSimulatioin(QGraphicsItem *parent) :QGraphicsItem(parent)
+{
+ /*this->setFlag(QGraphicsItem::ItemIsSelectable);
+ this->setFlag(QGraphicsItem::ItemIsMovable);*/
+
+ setFlags(ItemIsSelectable | ItemIsMovable);
+
+ //itemChangeҪItemSendsGeometryChanges flag is needed to capture the change in position of QGraphicsItem
+ this->setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
+ m_height = 50;
+ m_width = 50;
+
+
+}
+
+imagerSimulatioin::~imagerSimulatioin()
+{
+
+}
+
+QRectF imagerSimulatioin::boundingRect() const
+{
+ qreal penWidth = 1;
+ return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
+ 20 + penWidth, 20 + penWidth);
+}
+
+void imagerSimulatioin::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ QBrush blueBrush(Qt::green);
+ QColor blue(32, 159, 223);
+ blueBrush.setColor(blue);
+
+ QPen outlinePen(Qt::black);
+
+ painter->setPen(outlinePen);
+ painter->setBrush(blueBrush);
+
+ painter->drawRect(-m_width / 2, -m_height / 2, m_width, m_height);//Ըıitemԭ㣬setSceneRect(qreal x, qreal y, qreal w, qreal h)һ
+
+
+ //QPen outlinePen(Qt::red);
+
+ painter->drawPoint(0, 0);
+ painter->drawEllipse(QPoint(0, 0), 10, 10);
+
+ //painter->drawRoundedRect(-10, -10, 100, 100, 5, 5);
+
+}
+
+void imagerSimulatioin::setPos(qreal x, qreal y)
+{
+ if (x>0)
+ {
+ x = -x;
+ }
+ if (y>0)
+ {
+ y = -y;
+ }
+
+ x = floor(x);
+ y = floor(y);
+
+ QGraphicsItem::setPos(x, y);//ø౻ǵĺִӦ
+
+ scene()->update();
+}
+
+QVariant imagerSimulatioin::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ if (change == ItemPositionChange && scene())
+ {
+ // value is the new position.
+ QPointF newPos = value.toPointF();
+
+ QRectF rect = scene()->sceneRect();
+ if (!rect.contains(newPos))
+ {
+ // Keep the item inside the scene rect.
+ newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
+ newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
+ //qDebug() << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
+ return newPos;
+ }
+ }
+
+ //qDebug() << "---------------";
+
+ return QGraphicsItem::itemChange(change, value);
+}
+
+void imagerSimulatioin::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ scene()->update();
+
+ QPointF originOfItem = this->scenePos();//itemϽsceneе
+ //qDebug() << originOfItem;
+
+ QGraphicsItem::mouseMoveEvent(event);
+}
+
+void imagerSimulatioin::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ QPointF x = pos();//itemԭ㣨00sceneе
+ QPointF originOfItem = this->scenePos();//itemԭ㣨00sceneе
+
+ QPointF viewPos = event->pos();
+
+
+ //qDebug() << "---------------event coordinate: " << x;
+ //qDebug() << "---------------event coordinate: " << viewPos;
+ //qDebug() << "---------------event scene coordinate: " << this->mapToScene(viewPos);
+
+ //qDebug() << "---------------imagerSimulatioin origin coordinate: " << originOfItem;
+ //qDebug() << "---------------imagerSimulatioin center coordinate: " << centerOfItem;
+
+ qDebug() << "---------------imagerSimulatioin origin coordinate: " << originOfItem;
+
+ emit leftMouseButtonPressed(originOfItem.x(), originOfItem.y());
+
+
+ //update();//ʵʱ
+ scene()->update();
+
+ QGraphicsItem::mouseReleaseEvent(event);
+}
diff --git a/HPPA/imagerSimulatioin.h b/HPPA/imagerSimulatioin.h
new file mode 100644
index 0000000..52416ef
--- /dev/null
+++ b/HPPA/imagerSimulatioin.h
@@ -0,0 +1,34 @@
+#ifndef IMAGER_SIMULATIOIN
+#define IMAGER_SIMULATIOIN
+
+#include
+
+class imagerSimulatioin :public QObject,public QGraphicsItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsItem)
+public:
+ imagerSimulatioin(QGraphicsItem *parent = Q_NULLPTR);
+ ~imagerSimulatioin();
+
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ void setPos(qreal x, qreal y);
+
+ //QGraphicsSceneͼԪ϶Χhttps://www.cnblogs.com/sfy5848/p/6611824.html
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);//϶itemʱͣĻƣ϶Ӱ
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);//ſʱʱͼԪsceneе
+protected:
+
+
+
+private:
+ int m_width;
+ int m_height;
+
+signals :
+ void leftMouseButtonPressed(int, int);
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/main.cpp b/HPPA/main.cpp
new file mode 100644
index 0000000..5d8c67a
--- /dev/null
+++ b/HPPA/main.cpp
@@ -0,0 +1,10 @@
+#include "HPPA.h"
+#include
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ HPPA w;
+ w.show();
+ return a.exec();
+}
diff --git a/HPPA/resononImager.cpp b/HPPA/resononImager.cpp
new file mode 100644
index 0000000..a7254ad
--- /dev/null
+++ b/HPPA/resononImager.cpp
@@ -0,0 +1,435 @@
+#include "stdafx.h"
+#include
+#include
+#include
+#include
+#include "resononImager.h"
+
+ResononImager::ResononImager()
+{
+ 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()
+{
+ if (buffer != nullptr)
+ {
+ std::cout << "ͷŶڴ" << std::endl;
+ free(buffer);
+ free(dark);
+ free(white);
+ }
+}
+
+CImage * ResononImager::getRgbImage() const
+{
+ return m_RgbImage;
+}
+
+cv::Mat * ResononImager::getMatRgbImage() const
+{
+ return m_RgbImage->m_matRgbImage;
+}
+
+cv::Mat * ResononImager::getMatFocusGrayImage() const
+{
+ return m_RgbImage->m_matFocusGrayImage;
+}
+
+QImage ResononImager::getQImageFocusGrayImage() const
+{
+ return *m_RgbImage->m_qimageFocusGrayImage;
+}
+
+bool ResononImager::getRecordControlState() const
+{
+ 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 << "ֵ֡Ϊ" << 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;//rgbͼĵ0
+ m_bRecordControlState = true;
+
+ //жڴbufferǷ
+ 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);
+
+ //ȥӦΪbufferdarkunsigned shortԵdark>bufferʱbuffer-dark=65535
+ if (m_HasDark)
+ {
+ for (size_t i = 0; i < m_FrameSize; i++)
+ {
+ buffer[i] = buffer[i] - dark[i];
+ }
+ }
+
+
+ //ת
+ if (m_HasWhite)
+ {
+ for (size_t i = 0; i < m_FrameSize; i++)
+ {
+ //װ壩Ϊ0
+ 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);
+
+ //rgbȡԱڽʾ
+ m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
+
+ //std::cout << "" << m_iFrameCounter << "֡д" << x << "unsigned short" << std::endl;
+
+ //ÿ1sһνͼλ
+ 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++;
+
+ //һλͼǰҪһ
+ //m_RgbImage
+ emit PlotSignal();//ɼɺһλͼԷɼ֡֡ʵıʱͼȫ
+
+ if (m_iFrameCounter >= m_iFrameNumber)
+ {
+ emit RecordFinishedSignal_WhenFrameNumberMeet();
+ }
+ else
+ {
+ emit RecordFinishedSignal_WhenFrameNumberNotMeet();
+ }
+
+ //QThread::msleep(1001);
+ fclose(m_fImage);
+}
+
+void ResononImager::record_dark()
+{
+ std::cout << "ɼ" << std::endl;
+ m_ResononImager.start();
+ m_ResononImager.get_frame(dark);
+ m_ResononImager.stop();
+
+ m_HasDark = true;
+}
+
+void ResononImager::record_white()
+{
+ std::cout << "ɼװ壡" << std::endl;
+ m_ResononImager.start();
+ m_ResononImager.get_frame(white);
+ m_ResononImager.stop();
+
+ 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_RgbImage->m_iFramerate = frames_per_second;
+}
+
+void ResononImager::set_integration_time(const double milliseconds)
+{
+ m_ResononImager.set_integration_time(milliseconds);
+}
+
+void ResononImager::set_gain(const double gain)
+{
+ m_ResononImager.set_gain(gain);
+}
+
+void ResononImager::set_buffer()
+{
+ //
+ if (buffer != nullptr)
+ {
+ std::cout << "ͷŶڴ" << std::endl;
+ free(buffer);
+ }
+
+ m_FrameSize = m_ResononImager.get_band_count()*m_ResononImager.get_sample_count();
+ //std::cout << "m_FrameSizeСΪ" << 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ڴַ" << buffer << std::endl;
+ std::cout << "darkڴַ" << dark << std::endl;
+ std::cout << "whiteڴַ" << white << std::endl;
+}
+
+void ResononImager::setFrameNumber(int FrameNumber)
+{
+ m_iFrameNumber = FrameNumber;
+ m_RgbImage->SetRgbImageWidthAndHeight(getBandCount(), getSampleCount(), FrameNumber);
+}
+
+double ResononImager::auto_exposure()
+{
+ //һعʱΪڵǰ֡
+ double x = 1 / m_ResononImager.get_framerate()*1000;//ȡعʱ
+ m_ResononImager.set_integration_time(x);
+
+ //ڶͨѭѰعʱ
+ 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 << "Զع-----------" << std::endl;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ m_ResononImager.stop();
+
+ //std::cout << "Զع⣺" << get_integration_time() << std::endl;
+
+ return get_integration_time();
+}
+
+void ResononImager::setFocusControlState(bool FocusControlState)
+{
+ m_bFocusControlState = FocusControlState;
+}
+
+void ResononImager::setFileName2Save(string FileName)
+{
+ m_FileName2Save = FileName;
+ m_FileSavedCounter = 1;
+}
+
+double ResononImager::getWavelengthAtBand(int band)
+{
+ return m_ResononImager.get_wavelength_at_band(band);
+}
+
+int ResononImager::getBandCount()
+{
+ return m_ResononImager.get_band_count();
+}
+
+int ResononImager::getSampleCount()
+{
+ return m_ResononImager.get_sample_count();
+}
+
+int ResononImager::GetImageSize(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;
+}
+
+void ResononImager::focus()
+{
+ m_iFocusFrameCounter = 1;
+ //std::cout << "-----------" << std::endl;
+
+ double tmpFrmerate = m_ResononImager.get_framerate();
+ double tmpIntegrationTime = m_ResononImager.get_integration_time();
+
+
+ m_ResononImager.set_framerate(5);
+ auto_exposure();
+ std::cout << "õعʱΪ" << 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);
+}
diff --git a/HPPA/resononImager.h b/HPPA/resononImager.h
new file mode 100644
index 0000000..511b5a8
--- /dev/null
+++ b/HPPA/resononImager.h
@@ -0,0 +1,97 @@
+#ifndef RESONON_IMAGER
+#define RESONON_IMAGER
+
+#include
+#include
+
+#include "resonon_imager_basler.h"
+#include "image2display.h"
+#include "fileOperation.h"
+
+class ResononImager:public QObject
+{
+ Q_OBJECT
+
+public:
+ ResononImager();
+ ~ResononImager();
+
+ 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;//洢ɼӰмһд뵽Ӳ
+
+ void set_buffer();
+ void setFrameNumber(int FrameNumber);
+ double auto_exposure();
+
+
+ void setFocusControlState(bool FocusControlState);
+
+ void setFileName2Save(string FileName);
+
+ double getWavelengthAtBand(int band);
+ int getBandCount();
+ int getSampleCount();
+
+ int GetImageSize(int &iWidth, int &iHeight);
+
+protected:
+private:
+ CImage* m_RgbImage;//ʾrgbͼ
+ int m_iFrameNumber;//Ҫɼ֡
+ int m_iFrameCounter;//¼ɼ֡
+ int m_iFocusFrameCounter;//¼ʱɼ֡
+ bool m_bRecordControlState;//ɼ״ִֹ̬ͣɼ
+ bool m_bFocusControlState;//Ƶ
+
+ //ڸӰļ
+ string m_FileName2Save;//Ӱļ
+ int m_FileSavedCounter;//˼Ӱļ
+
+ unsigned short * dark;//洢
+ unsigned short * white;//洢װ
+
+ FILE *m_fImage;//дӲ̵ļ
+ int m_FrameSize;//ʾһ֡жٸֵm_FrameSize = m_imager.get_band_count()*m_imager.get_sample_count();
+ bool m_HasDark;//ɼ˰֮Ϊtrue
+ bool m_HasWhite;//ɼ˰װ֮Ϊtrue
+
+ void WriteHdr();
+ unsigned short GetMaxValue(unsigned short * dark, int number);
+
+public slots:
+ void connect_imager(int frameNumber);//ٻ
+ 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();//Ӱź
+ void RecordFinishedSignal_WhenFrameNumberMeet();//ɼźţҪɼ֡m_iFrameNumberɼ
+ void RecordFinishedSignal_WhenFrameNumberNotMeet();//ɼźţҪɼ֡m_iFrameNumberûвɼɣ;ֹͣɼ
+ void SpectralSignal(int);//1ڵƹף0ʾɣ
+
+
+ void testImagerStatus();//ʾԲ״̬Ƿӣӳ
+};
+#endif
\ No newline at end of file
diff --git a/HPPA/resource.h b/HPPA/resource.h
new file mode 100644
index 0000000..0cc8414
--- /dev/null
+++ b/HPPA/resource.h
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ ɵİļ
+// HPPA.rc ʹ
+//
+#define IDI_ICON1 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/HPPA/stdafx.cpp b/HPPA/stdafx.cpp
new file mode 100644
index 0000000..fd4f341
--- /dev/null
+++ b/HPPA/stdafx.cpp
@@ -0,0 +1 @@
+#include "stdafx.h"
diff --git a/HPPA/stdafx.h b/HPPA/stdafx.h
new file mode 100644
index 0000000..983474e
--- /dev/null
+++ b/HPPA/stdafx.h
@@ -0,0 +1,3 @@
+#include
+#include
+#include