Browse Source

完成基础功能

master
zara 1 year ago
commit
dd59a21ca9
  1. 106
      CMakeLists.txt
  2. 454
      CMakeLists.txt.user
  3. 63
      avgfilter.cpp
  4. 33
      avgfilter.h
  5. 41
      bila.cpp
  6. 29
      bila.h
  7. 65
      clhe.cpp
  8. 27
      clhe.h
  9. BIN
      cpp/CyAPI.chm
  10. BIN
      cpp/CyAPI.pdf
  11. 600
      cpp/inc/CyAPI.h
  12. 90
      cpp/inc/CyUSB30_def.h
  13. 46
      cpp/inc/UsbdStatus.h
  14. 26
      cpp/inc/VersionNo.h
  15. 213
      cpp/inc/cyioctl.h
  16. 270
      cpp/inc/usb100.h
  17. 111
      cpp/inc/usb200.h
  18. BIN
      cpp/lib/x64/CyAPI.lib
  19. BIN
      cpp/lib/x86/CyAPI.lib
  20. 145
      datathread.cpp
  21. 60
      datathread.h
  22. 50
      dde.cpp
  23. 27
      dde.h
  24. 41
      login.cpp
  25. 32
      login.h
  26. 41
      login.ui
  27. BIN
      logo.ico
  28. 18
      main.cpp
  29. 563
      mainwindow.cpp
  30. 110
      mainwindow.h
  31. 283
      mainwindow.ui
  32. 117
      menu1.cpp
  33. 62
      menu1.h
  34. 139
      menu1.ui
  35. 89
      menu2.cpp
  36. 51
      menu2.h
  37. 130
      menu2.ui
  38. 49
      menu3.cpp
  39. 43
      menu3.h
  40. 116
      menu3.ui
  41. 68
      menu4.cpp
  42. 45
      menu4.h
  43. 78
      menu4.ui
  44. 25
      protocol.h
  45. 36
      qt5app.rc
  46. 82
      sagauss.cpp
  47. 34
      sagauss.h
  48. 293
      twopoint.cpp
  49. 72
      twopoint.h
  50. 415
      usbcontrol.cpp
  51. 63
      usbcontrol.h
  52. 155
      usbthread.cpp
  53. 66
      usbthread.h

106
CMakeLists.txt

@ -0,0 +1,106 @@
cmake_minimum_required(VERSION 3.5)
set(PROJECT_VERSION 1.4.0.0)
add_definitions(-DProjectVersion=\"${PROJECT_VERSION}\")
project(zxrcClient LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QFluentDIR "C:/QFluentWidgets_v170")
set(OpenCV_DIR "C:/opencv/build")
find_package(OpenCV)
set(INCLUDE_DIRS
${QFluentDIR}/QFluentWidgets/include/QFluentWidgets/include
${QFluentDIR}/QFluentWidgets/include/QFluentWidgets/Common/
${QFluentDIR}/QWindowKit/include/QWindowKit
cpp/inc
)
set(LIB_DIRS
${QFluentDIR}/QWindowKit/lib
${QFluentDIR}/QFluentWidgets/lib
cpp/lib/x64
)
set(QFluentWidgets_DIR ${QFluentDIR}/QFluentWidgets/lib/cmake/QFluentWidgets)
set(LIBS
QWKWidgets.lib
QWKCore.lib
CyAPI
SetupAPI
user32
ws2_32
legacy_stdio_definitions
)
find_package(QFluentWidgets REQUIRED)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
menu1.cpp
menu1.h
menu1.ui
menu2.cpp
menu2.h
menu2.ui
menu3.cpp
menu3.h
menu3.ui
menu4.cpp
menu4.h
menu4.ui
usbcontrol.cpp
usbcontrol.h
usbthread.cpp
usbthread.h
protocol.h
datathread.cpp
datathread.h
qt5app.rc
)
add_executable (zxrcClient WIN32 ${PROJECT_SOURCES})
target_include_directories (zxrcClient PRIVATE ${INCLUDE_DIRS})
target_link_directories (zxrcClient PRIVATE ${LIB_DIRS})
target_link_libraries (zxrcClient PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries (zxrcClient PRIVATE QFluentWidgets::Widgets ${LIBS})
target_link_libraries (zxrcClient PRIVATE ${OpenCV_LIBS})
add_executable (zxrcClientSim WIN32 ${PROJECT_SOURCES})
target_include_directories (zxrcClientSim PRIVATE ${INCLUDE_DIRS})
target_link_directories (zxrcClientSim PRIVATE ${LIB_DIRS})
target_link_libraries (zxrcClientSim PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries (zxrcClientSim PRIVATE QFluentWidgets::Widgets ${LIBS})
target_link_libraries (zxrcClientSim PRIVATE ${OpenCV_LIBS})
target_compile_definitions (zxrcClientSim PRIVATE CLIENT=1)
add_executable (zxrcClientPC WIN32 ${PROJECT_SOURCES})
target_include_directories (zxrcClientPC PRIVATE ${INCLUDE_DIRS})
target_link_directories (zxrcClientPC PRIVATE ${LIB_DIRS})
target_link_libraries (zxrcClientPC PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries (zxrcClientPC PRIVATE QFluentWidgets::Widgets ${LIBS})
target_link_libraries (zxrcClientPC PRIVATE ${OpenCV_LIBS})
target_compile_definitions (zxrcClientPC PRIVATE CLIENT=2)

454
CMakeLists.txt.user

@ -0,0 +1,454 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 11.0.1, 2024-05-19T19:02:09. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{b996d7c2-8baa-4dd5-9c90-a55ade3bd4fb}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">0</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">8</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
<value type="bool" key="UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.15.2 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.15.2 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5152.win64_msvc2019_64_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WorkSpace\zxrcClientNew\build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WorkSpace\zxrcClientNew\build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WorkSpace\zxrcClientNew\build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WorkSpace\zxrcClientNew\build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.4">
<value type="QString" key="CMake.Build.Type">MinSizeRel</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\WorkSpace\zxrcClientNew\build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">zxrcClient</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.zxrcClient</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">zxrcClient</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseTerminal">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/WorkSpace/zxrcClientNew/build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-Release</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">zxrcClientSim</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.zxrcClientSim</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">zxrcClientSim</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/WorkSpace/zxrcClientNew/build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-Release</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">zxrcClientPC</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.zxrcClientPC</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">zxrcClientPC</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/WorkSpace/zxrcClientNew/build-zxrcClient-Desktop_Qt_5_15_2_MSVC2019_64bit-Release</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">3</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

63
avgfilter.cpp

@ -0,0 +1,63 @@
#include "avgfilter.h"
#include <QDebug>
avgfilter::avgfilter(QObject *parent)
: QObject{parent}
{
thread = new QThread();
this->moveToThread(thread);
thread->start();
ready = false;
}
void avgfilter::setpara(int para)
{
this->para = para;
if(para!=0){
on();
}
else if(para==0){
off();
}
qDebug()<<"para = "<<para;
}
void avgfilter::on()
{
ready = true;
}
void avgfilter::off()
{
ready = false;
}
void avgfilter::slotprocimg(cv::Mat img)
{
if(ready){
if(lastmat.empty()){
img.copyTo(lastmat);
emit signalsendimg(img);
}
else{
// cv::Mat dst(img.rows,img.cols,CV_16UC1);
cv::Mat dst = (256-para)*(img/256)+para*(lastmat/256);
for(int i = 0;i< img.rows;i++){
for(int j = 0;j<img.cols;j++){
if(abs(int(img.at<ushort>(i,j))- int(dst.at<ushort>(i,j)))>(320))
// dst.at<ushort>(i,j) = (255-para)*(img.at<ushort>(i,j)/256)+para*(lastmat.at<ushort>(i,j)/256);
// else
dst.at<ushort>(i,j) = img.at<ushort>(i,j);
}
}
// qDebug()<<dst.type();
dst.copyTo(lastmat);
emit signalsendimg(dst);
}
}
else{
cv::Mat temp;
img.copyTo(temp);
emit signalsendimg(temp);
}
}

33
avgfilter.h

@ -0,0 +1,33 @@
#ifndef AVGFILTER_H
#define AVGFILTER_H
#include <QObject>
#include <opencv2/opencv.hpp>
#include <QThread>
class avgfilter : public QObject
{
Q_OBJECT
public:
explicit avgfilter(QObject *parent = nullptr);
void setpara(int para);
void on();
void off();
public slots:
void slotprocimg(cv::Mat img);
signals:
void signalsendimg(cv::Mat img);
private:
bool ready;
cv::Mat lastmat;
int para;
QThread* thread;
};
#endif // AVGFILTER_H

41
bila.cpp

@ -0,0 +1,41 @@
#include "bila.h"
bila::bila(QObject *parent)
: QObject{parent}
{
thread = new QThread();
thread->start();
this->moveToThread(thread);
ready = false;
}
void bila::setparas(int r, double sigmac, double sigmar)
{
this->r = r;
this->sigmac = sigmac;
this->sigmar = sigmar;
ready = true;
}
void bila::off()
{
ready = false;
}
void bila::slotprocimg(cv::Mat img)
{
if(ready){
cv::Mat temp;
cv::Mat tempd;
cv::Mat dst;
img.convertTo(temp,CV_32FC1);
cv::bilateralFilter(temp,tempd,2*r+1,sigmac,sigmar);
tempd.convertTo(dst,CV_16UC1);
emit signalsendimg(dst);
}
else{
cv::Mat temp;
img.copyTo(temp);
emit signalsendimg(temp);
}
}

29
bila.h

@ -0,0 +1,29 @@
#ifndef BILA_H
#define BILA_H
#include <QObject>
#include <QThread>
#include <opencv2/opencv.hpp>
class bila : public QObject
{
Q_OBJECT
public:
explicit bila(QObject *parent = nullptr);
void setparas(int r, double sigmac, double sigmar);
void off();
public slots:
void slotprocimg(cv::Mat img);
signals:
void signalsendimg(cv::Mat img);
private:
int r;
double sigmac;
double sigmar;
QThread* thread;
bool ready;
};
#endif // BILA_H

65
clhe.cpp

@ -0,0 +1,65 @@
#include "clhe.h"
#include <QFile>
clhe::clhe(QObject *parent)
: QObject{parent}
{
thread = new QThread();
thread->start();
this->moveToThread(thread);
hist = (int*)malloc(sizeof(int)*16384);
HIST = (int*)malloc(sizeof(int)*16384);
ready = false;
}
void clhe::setthreshold(int threshold)
{
this->threshold = threshold;
ready = true;
}
void clhe::off()
{
ready = false;
}
void clhe::slotprocimg(cv::Mat img)
{
if(ready){
cv::Mat dst(img.rows,img.cols,CV_16UC1);
memset(hist,0,sizeof(int)*16384);
for(int i = 0;i<img.rows;i++){
for (int j = 0;j<img.cols;j++){
hist[img.at<ushort>(i,j)/4]+=1;
}
}
HIST[0] = hist[0]>threshold?threshold:hist[0];
for(int i =1;i<16384;i++){
HIST[i] = HIST[i-1]+ (hist[i]>threshold?threshold:hist[i]);
}
double sub = double(img.rows*img.cols - HIST[16383])/16384;
for (int i = 0; i < 16384; ++i) {
HIST[i] += sub*(i+1);
}
for(int i = 0;i<img.rows;i++){
for(int j = 0;j<img.cols;j++){
dst.at<ushort>(i,j) = HIST[img.at<ushort>(i,j)/4]/double(HIST[16383])*65535;
}
}
emit(signalsendimg(dst));
}
else{
cv::Mat temp;
img.copyTo(temp);
emit(signalsendimg(temp));
}
}

27
clhe.h

@ -0,0 +1,27 @@
#ifndef CLHE_H
#define CLHE_H
#include <QObject>
#include <QThread>
#include <opencv2/opencv.hpp>
class clhe : public QObject
{
Q_OBJECT
public:
explicit clhe(QObject *parent = nullptr);
void setthreshold(int threshold);
void off();
public slots:
void slotprocimg(cv::Mat img);
signals:
void signalsendimg(cv::Mat img);
private:
int threshold;
QThread* thread;
int* hist;
int* HIST;
bool ready;
};
#endif // CLHE_H

BIN
cpp/CyAPI.chm

Binary file not shown.

BIN
cpp/CyAPI.pdf

Binary file not shown.

600
cpp/inc/CyAPI.h

@ -0,0 +1,600 @@
/*
## Cypress CyAPI C++ library header file (CyAPI.h)
## =======================================================
##
## Copyright Cypress Semiconductor Corporation, 2009-2018,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.rtf
##
## where <install> is the Cypress software
## install root directory path.
##
## =======================================================
*/
#ifndef CyUSBH
#define CyUSBH
#include "cyusb30_def.h"
/* Data straucture for the Vendor request and data */
typedef struct vendorCmdData
{
UCHAR *buf; /* Pointer to the data */
UCHAR opCode; /* Vendor request code */
UINT addr; /* Read/Write address */
long size; /* Size of the read/write */
bool isRead; /* Read or write */
} vendorCmdData ;
#ifndef __USB200_H__
#define __USB200_H__
#pragma pack(push,1)
typedef struct _USB_DEVICE_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdUSB;
UCHAR bDeviceClass;
UCHAR bDeviceSubClass;
UCHAR bDeviceProtocol;
UCHAR bMaxPacketSize0;
USHORT idVendor;
USHORT idProduct;
USHORT bcdDevice;
UCHAR iManufacturer;
UCHAR iProduct;
UCHAR iSerialNumber;
UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
typedef struct _USB_ENDPOINT_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bEndpointAddress;
UCHAR bmAttributes;
USHORT wMaxPacketSize;
UCHAR bInterval;
} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
typedef struct _USB_CONFIGURATION_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT wTotalLength;
UCHAR bNumInterfaces;
UCHAR bConfigurationValue;
UCHAR iConfiguration;
UCHAR bmAttributes;
UCHAR MaxPower;
} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
typedef struct _USB_INTERFACE_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bInterfaceNumber;
UCHAR bAlternateSetting;
UCHAR bNumEndpoints;
UCHAR bInterfaceClass;
UCHAR bInterfaceSubClass;
UCHAR bInterfaceProtocol;
UCHAR iInterface;
} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
typedef struct _USB_STRING_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
WCHAR bString[1];
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
typedef struct _USB_COMMON_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
} USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
#pragma pack(pop)
#endif
/*******************************************************************************/
class CCyIsoPktInfo {
public:
LONG Status;
LONG Length;
};
/*******************************************************************************/
/* {AE18AA60-7F6A-11d4-97DD-00010229B959} */
static GUID CYUSBDRV_GUID = {0xae18aa60, 0x7f6a, 0x11d4, 0x97, 0xdd, 0x0, 0x1, 0x2, 0x29, 0xb9, 0x59};
typedef enum {TGT_DEVICE, TGT_INTFC, TGT_ENDPT, TGT_OTHER } CTL_XFER_TGT_TYPE;
typedef enum {REQ_STD, REQ_CLASS, REQ_VENDOR } CTL_XFER_REQ_TYPE;
typedef enum {DIR_TO_DEVICE, DIR_FROM_DEVICE } CTL_XFER_DIR_TYPE;
typedef enum {XMODE_BUFFERED, XMODE_DIRECT } XFER_MODE_TYPE;
const int MAX_ENDPTS = 32;
const int MAX_INTERFACES = 255;
const int USB_STRING_MAXLEN = 256;
#define BUFSIZE_UPORT 2048 //4096 - CDT 130492
typedef enum { RAM = 1, I2CE2PROM, SPIFLASH } FX3_FWDWNLOAD_MEDIA_TYPE ;
typedef enum { SUCCESS = 0, FAILED, INVALID_MEDIA_TYPE, INVALID_FWSIGNATURE, DEVICE_CREATE_FAILED, INCORRECT_IMAGE_LENGTH, INVALID_FILE, SPILASH_ERASE_FAILED, CORRUPT_FIRMWARE_IMAGE_FILE,I2CE2PROM_UNKNOWN_I2C_SIZE } FX3_FWDWNLOAD_ERROR_CODE;
#define CYWB_BL_4_BYTES_COPY(destination,source) {memcpy((void *)(destination), (void *)(source), 4);}
/********************************************************************************
*
* The CCyEndPoint ABSTRACT Class
*
********************************************************************************/
class CCyUSBEndPoint
{
protected:
bool WaitForIO(OVERLAPPED *ovLapStatus);
virtual PUCHAR BeginDirectXfer(PUCHAR buf, LONG bufLen, OVERLAPPED *ov);
virtual PUCHAR BeginBufferedXfer(PUCHAR buf, LONG bufLen, OVERLAPPED *ov);
public:
CCyUSBEndPoint(void);
CCyUSBEndPoint(CCyUSBEndPoint& ept);
CCyUSBEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor);
CCyUSBEndPoint(HANDLE hDev, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor,USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR* SSEndPtDescriptor);
HANDLE hDevice;
/* The fields of an EndPoint Descriptor */
UCHAR DscLen;
UCHAR DscType;
UCHAR Address;
UCHAR Attributes;
USHORT MaxPktSize;
USHORT PktsPerFrame;
UCHAR Interval;
/* This are the fields for Super speed endpoint */
UCHAR ssdscLen;
UCHAR ssdscType;
UCHAR ssmaxburst; /* Maximum number of packets endpoint can send in one burst */
UCHAR ssbmAttribute; /* store endpoint attribute like for bulk it will be number of streams */
USHORT ssbytesperinterval;
/* Other fields */
ULONG TimeOut;
ULONG UsbdStatus;
ULONG NtStatus;
DWORD bytesWritten;
DWORD LastError;
bool bIn;
XFER_MODE_TYPE XferMode;
bool XferData(PUCHAR buf, LONG &len, CCyIsoPktInfo* pktInfos = NULL);
bool XferData(PUCHAR buf, LONG &bufLen, CCyIsoPktInfo* pktInfos, bool pktMode);
virtual PUCHAR BeginDataXfer(PUCHAR buf, LONG len, OVERLAPPED *ov) = 0;
virtual bool FinishDataXfer(PUCHAR buf, LONG &len, OVERLAPPED *ov, PUCHAR pXmitBuf, CCyIsoPktInfo* pktInfos = NULL);
bool WaitForXfer(OVERLAPPED *ov, ULONG tOut);
ULONG GetXferSize(void);
void SetXferSize(ULONG xfer);
bool Reset(void);
bool Abort(void);
};
/********************************************************************************
*
* The Control Endpoint Class
*
********************************************************************************/
class CCyControlEndPoint : public CCyUSBEndPoint
{
public:
CCyControlEndPoint(void);
CCyControlEndPoint(CCyControlEndPoint& ept);
CCyControlEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor);
CTL_XFER_TGT_TYPE Target;
CTL_XFER_REQ_TYPE ReqType;
CTL_XFER_DIR_TYPE Direction;
UCHAR ReqCode;
WORD Value;
WORD Index;
bool Read(PUCHAR buf, LONG &len);
bool Write(PUCHAR buf, LONG &len);
PUCHAR BeginDataXfer(PUCHAR buf, LONG len, OVERLAPPED *ov);
};
/********************************************************************************
*
* The Isoc Endpoint Class
*
********************************************************************************/
class CCyIsocEndPoint : public CCyUSBEndPoint
{
protected:
virtual PUCHAR BeginDirectXfer(PUCHAR buf, LONG bufLen, OVERLAPPED *ov);
virtual PUCHAR BeginBufferedXfer(PUCHAR buf, LONG bufLen, OVERLAPPED *ov);
public:
CCyIsocEndPoint(void);
CCyIsocEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor);
CCyIsocEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor,USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR* SSEndPtDescriptor);
PUCHAR BeginDataXfer(PUCHAR buf, LONG len, OVERLAPPED *ov);
CCyIsoPktInfo* CreatePktInfos(LONG bufLen, int &packets);
};
/********************************************************************************
*
* The Bulk Endpoint Class
*
********************************************************************************/
class CCyBulkEndPoint : public CCyUSBEndPoint
{
public:
CCyBulkEndPoint(void);
CCyBulkEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor);
CCyBulkEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor,USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR* SSEndPtDescriptor);
PUCHAR BeginDataXfer(PUCHAR buf, LONG len, OVERLAPPED *ov);
};
/********************************************************************************
*
* The Interrupt Endpoint Class
*
********************************************************************************/
class CCyInterruptEndPoint : public CCyUSBEndPoint
{
public:
CCyInterruptEndPoint(void);
CCyInterruptEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor);
CCyInterruptEndPoint(HANDLE h, PUSB_ENDPOINT_DESCRIPTOR pEndPtDescriptor,USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR* SSEndPtDescriptor);
PUCHAR BeginDataXfer(PUCHAR buf, LONG len, OVERLAPPED *ov);
};
/********************************************************************************
*
* The Interface Class
*
********************************************************************************/
class CCyUSBInterface
{
public:
CCyUSBEndPoint *EndPoints[MAX_ENDPTS]; /* Holds pointers to all the interface's endpoints,
plus a pointer to the Control endpoint zero */
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bInterfaceNumber;
UCHAR bAlternateSetting;
UCHAR bNumEndpoints; /* Not counting the control endpoint */
UCHAR bInterfaceClass;
UCHAR bInterfaceSubClass;
UCHAR bInterfaceProtocol;
UCHAR iInterface;
UCHAR bAltSettings;
USHORT wTotalLength; /* Needed in case Intfc has additional (non-endpt) descriptors */
CCyUSBInterface(HANDLE handle, PUSB_INTERFACE_DESCRIPTOR pIntfcDescriptor,UCHAR usb30Dummy);
CCyUSBInterface(HANDLE h, PUSB_INTERFACE_DESCRIPTOR pIntfcDescriptor);
CCyUSBInterface(CCyUSBInterface& ifc); /* Copy Constructor */
~CCyUSBInterface(void);
};
/********************************************************************************
*
* The Config Class
*
********************************************************************************/
class CCyUSBConfig
{
public:
CCyUSBInterface *Interfaces[MAX_INTERFACES];
UCHAR bLength;
UCHAR bDescriptorType;
USHORT wTotalLength;
UCHAR bNumInterfaces;
UCHAR bConfigurationValue;
UCHAR iConfiguration;
UCHAR bmAttributes;
UCHAR MaxPower;
UCHAR AltInterfaces;
CCyUSBConfig(void);
CCyUSBConfig(CCyUSBConfig& cfg); /* Copy Constructor */
CCyUSBConfig(HANDLE h, PUSB_CONFIGURATION_DESCRIPTOR pConfigDescr);
CCyUSBConfig(HANDLE h, PUSB_CONFIGURATION_DESCRIPTOR pConfigDescr,UCHAR usb30Dummy);
~CCyUSBConfig(void);
};
/********************************************************************************
*
* The Bos USB20 Extesnion Class
*
********************************************************************************/
class CCyBosUSB20Extesnion
{
public:
UCHAR bLength; /* Descriptor length */
UCHAR bDescriptorType; /* Descriptor Type */
UCHAR bDevCapabilityType; /* Device capability type */
UINT bmAttribute; /* Bitmap encoding for supprted feature and Link power managment supprted if set */
CCyBosUSB20Extesnion(void);
CCyBosUSB20Extesnion(HANDLE h,PUSB_BOS_USB20_DEVICE_EXTENSION BosUsb20ExtDesc);
};
/********************************************************************************
*
* The Bos SuperSpeed Capability Class
*
********************************************************************************/
class CCyBosSuperSpeedCapability
{
public:
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bDevCapabilityType;
UCHAR bmAttribute;
USHORT SpeedsSuported;
UCHAR bFunctionalitySupporte;
UCHAR bU1DevExitLat;
USHORT bU2DevExitLat;
CCyBosSuperSpeedCapability(void);
CCyBosSuperSpeedCapability(HANDLE h,PUSB_BOS_SS_DEVICE_CAPABILITY pUSB_SuperSpeedUsb);
};
/********************************************************************************
*
* The Bos Container ID Class
*
********************************************************************************/
class CCyBosContainerID
{
public:
UCHAR bLength; /* Descriptor length */
UCHAR bDescriptorType; /* Descriptor Type */
UCHAR bDevCapabilityType; /* Device capability type */
UCHAR bReserved; /* no use */
UCHAR ContainerID[USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE]; /* UUID */
CCyBosContainerID(void);
CCyBosContainerID(HANDLE h,PUSB_BOS_CONTAINER_ID pContainerID);
};
/********************************************************************************
*
* The USB BOS Class
*
********************************************************************************/
class CCyUSBBOS
{
public:
CCyBosContainerID *pContainer_ID;
CCyBosUSB20Extesnion *pUSB20_DeviceExt;
CCyBosSuperSpeedCapability *pSS_DeviceCap;
UCHAR bLength; /* Descriptor length */
UCHAR bDescriptorType; /* Descriptor Type */
USHORT wTotalLength; /* Total length of descriptor ( icluding device capabilty */
UCHAR bNumDeviceCaps; /* Number of device capability descriptors in BOS */
CCyUSBBOS(void);
CCyUSBBOS(HANDLE h,PUSB_BOS_DESCRIPTOR pBosDescrData);
~CCyUSBBOS();
};
/*********************************************************************************
*
* The USB Device Class - This is the main class that contains members of all the
* other classes.
*
* To use the library, create an instance of this Class and call it's Open method.
*
*********************************************************************************/
class CCyUSBDevice
{
/* The public members are accessible (i.e. corruptible) by the user of the library
* Algorithms of the class don't rely on any public members. Instead, they use the
* private members of the class for their calculations. */
public:
CCyUSBDevice(HANDLE hnd = NULL, GUID guid = CYUSBDRV_GUID, BOOL bOpen = true);
~CCyUSBDevice(void);
CCyUSBEndPoint **EndPoints; /* Shortcut to USBCfgs[CfgNum]->Interfaces[IntfcIndex]->Endpoints */
CCyUSBEndPoint *EndPointOf(UCHAR addr);
CCyUSBBOS *UsbBos;
CCyIsocEndPoint *IsocInEndPt;
CCyIsocEndPoint *IsocOutEndPt;
CCyBulkEndPoint *BulkInEndPt;
CCyBulkEndPoint *BulkOutEndPt;
CCyControlEndPoint *ControlEndPt;
CCyInterruptEndPoint *InterruptInEndPt;
CCyInterruptEndPoint *InterruptOutEndPt;
USHORT StrLangID;
ULONG LastError;
ULONG UsbdStatus;
ULONG NtStatus;
ULONG DriverVersion;
ULONG USBDIVersion;
char DeviceName[USB_STRING_MAXLEN];
char FriendlyName[USB_STRING_MAXLEN];
wchar_t Manufacturer[USB_STRING_MAXLEN];
wchar_t Product[USB_STRING_MAXLEN];
wchar_t SerialNumber[USB_STRING_MAXLEN];
CHAR DevPath[USB_STRING_MAXLEN];
USHORT BcdUSB;
USHORT VendorID;
USHORT ProductID;
UCHAR USBAddress;
UCHAR DevClass;
UCHAR DevSubClass;
UCHAR DevProtocol;
INT MaxPacketSize;
USHORT BcdDevice;
UCHAR ConfigValue;
UCHAR ConfigAttrib;
UCHAR MaxPower;
UCHAR IntfcClass;
UCHAR IntfcSubClass;
UCHAR IntfcProtocol;
bool bHighSpeed;
bool bSuperSpeed;
DWORD BytesXfered;
UCHAR DeviceCount(void);
UCHAR ConfigCount(void);
UCHAR IntfcCount(void);
UCHAR AltIntfcCount(void);
UCHAR EndPointCount(void);
void SetConfig(UCHAR cfg);
UCHAR Config(void) { return CfgNum; } /* Normally 0 */
UCHAR Interface(void) { return IntfcNum; } /* Usually 0 */
/* No SetInterface method since only 1 intfc per device (per Windows) */
UCHAR AltIntfc(void);
bool SetAltIntfc(UCHAR alt);
GUID DriverGUID(void) { return DrvGuid; }
HANDLE DeviceHandle(void) { return hDevice; }
void UsbdStatusString(ULONG stat, PCHAR s);
bool CreateHandle(UCHAR dev);
void DestroyHandle();
bool Open(UCHAR dev);
void Close(void);
bool Reset(void);
bool ReConnect(void);
bool Suspend(void);
bool Resume(void);
bool IsOpen(void) { return (hDevice != INVALID_HANDLE_VALUE); }
UCHAR PowerState(void);
bool GetBosDescriptor(PUSB_BOS_DESCRIPTOR descr);
bool GetBosUSB20DeviceExtensionDescriptor(PUSB_BOS_USB20_DEVICE_EXTENSION descr);
bool GetBosContainedIDDescriptor(PUSB_BOS_CONTAINER_ID descr);
bool GetBosSSCapabilityDescriptor(PUSB_BOS_SS_DEVICE_CAPABILITY descr);
void GetDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR descr);
void GetConfigDescriptor(PUSB_CONFIGURATION_DESCRIPTOR descr);
void GetIntfcDescriptor(PUSB_INTERFACE_DESCRIPTOR descr);
CCyUSBConfig GetUSBConfig(int index);
private:
USB_DEVICE_DESCRIPTOR USBDeviceDescriptor;
PUSB_CONFIGURATION_DESCRIPTOR USBConfigDescriptors[2];
PUSB_BOS_DESCRIPTOR pUsbBosDescriptor;
CCyUSBConfig *USBCfgs[2];
HANDLE hWnd;
HANDLE hDevice;
HANDLE hDevNotification;
HANDLE hHndNotification;
GUID DrvGuid;
UCHAR Devices;
UCHAR Interfaces;
UCHAR AltInterfaces;
UCHAR Configs;
UCHAR DevNum;
UCHAR CfgNum;
UCHAR IntfcNum; /* The current selected interface's bInterfaceNumber */
UCHAR IntfcIndex; /* The entry in the Config's interfaces table matching to IntfcNum and AltSetting */
bool GetInternalBosDescriptor();
void GetDevDescriptor(void);
void GetCfgDescriptor(int descIndex);
void GetString(wchar_t *s, UCHAR sIndex);
void SetStringDescrLanguage(void);
void SetAltIntfcParams(UCHAR alt);
bool IoControl(ULONG cmd, PUCHAR buf, ULONG len);
void SetEndPointPtrs(void);
void GetDeviceName(void);
void GetFriendlyName(void);
void GetDriverVer(void);
void GetUSBDIVer(void);
void GetSpeed(void);
void GetUSBAddress(void);
//void CloseEndPtHandles(void);
bool RegisterForPnpEvents(HANDLE h);
};
/********************************************************************************
*
* The FX3 Device Class
*
********************************************************************************/
class CCyFX3Device: public CCyUSBDevice
{
public:
CCyFX3Device(void);
~CCyFX3Device(void);
bool IsBootLoaderRunning();
FX3_FWDWNLOAD_ERROR_CODE DownloadFw(char *fileName, FX3_FWDWNLOAD_MEDIA_TYPE enMediaType);
private:
bool Ep0VendorCommand(vendorCmdData cmdData);
bool SetProgramEntry(UCHAR opCode,UINT start_addr);
bool DownloadBufferToDevice(UINT start_addr, USHORT count, UCHAR *data_buf, UCHAR opCode);
bool UploadBufferFromDevice(UINT start_addr, USHORT count, UCHAR *data_buf, UCHAR opCode);
FX3_FWDWNLOAD_ERROR_CODE DownloadFwToRam(PUCHAR buffer_p, UINT fw_size, UCHAR opCode);
FX3_FWDWNLOAD_ERROR_CODE DownloadUserIMGtoI2CE2PROM(PUCHAR buffer_p, UINT fw_size, UCHAR opCode);
FX3_FWDWNLOAD_ERROR_CODE DownloadUserIMGtoSPIFLASH(PUCHAR buffer_p, UINT fw_size, UCHAR opCode);
FX3_FWDWNLOAD_ERROR_CODE EraseSectorOfSPIFlash(UINT SectorNumber, UCHAR opCode);
bool WriteToSPIFlash(PUCHAR Buf, UINT buflen, UINT ByteAddress, UCHAR opCode);
};
/********************************************************************************/
#endif

90
cpp/inc/CyUSB30_def.h

@ -0,0 +1,90 @@
/*
## Cypress CyAPI C++ library USB3.0 defination header file (CyUSB30_def.h)
## =======================================================
##
## Copyright Cypress Semiconductor Corporation, 2009-2018,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.rtf
##
## where <install> is the Cypress software
## install root directory path.
##
## =======================================================
*/
#ifndef _CYUSB30_H
#define _CYUSB30_H
//#pragma pack(1)
#pragma pack(push, 1)
// USB3.0 specific constant defination
#define BCDUSBJJMASK 0xFF00 //(0xJJMN JJ - Major version,M Minor version, N sub-minor vesion)
#define USB30MAJORVER 0x0300
#define USB20MAJORVER 0x0200
#define USB_BOS_DESCRIPTOR_TYPE 0x0F
#define USB_DEVICE_CAPABILITY 0x10
#define USB_SUPERSPEED_ENDPOINT_COMPANION 0x30
#define USB_BOS_CAPABILITY_TYPE_Wireless_USB 0x01
#define USB_BOS_CAPABILITY_TYPE_USB20_EXT 0x02
#define USB_BOS_CAPABILITY_TYPE_SUPERSPEED_USB 0x03
#define USB_BOS_CAPABILITY_TYPE_CONTAINER_ID 0x04
#define USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE 0x10
#define USB_BOS_DEVICE_CAPABILITY_TYPE_INDEX 0x2
//constant defination
typedef struct _USB_BOS_DESCRIPTOR
{
UCHAR bLength;/* Descriptor length*/
UCHAR bDescriptorType;/* Descriptor Type */
USHORT wTotalLength;/* Total length of descriptor ( icluding device capability*/
UCHAR bNumDeviceCaps;/* Number of device capability descriptors in BOS */
}USB_BOS_DESCRIPTOR,*PUSB_BOS_DESCRIPTOR;
typedef struct _USB_BOS_USB20_DEVICE_EXTENSION
{
UCHAR bLength;/* Descriptor length*/
UCHAR bDescriptorType;/* Descriptor Type */
UCHAR bDevCapabilityType;/* Device capability type*/
UINT bmAttribute;// Bitmap encoding for supprted feature and Link power managment supprted if set
}USB_BOS_USB20_DEVICE_EXTENSION,*PUSB_BOS_USB20_DEVICE_EXTENSION;
typedef struct _USB_BOS_SS_DEVICE_CAPABILITY
{
UCHAR bLength;/* Descriptor length*/
UCHAR bDescriptorType;/* Descriptor Type */
UCHAR bDevCapabilityType;/* Device capability type*/
UCHAR bmAttribute;// Bitmap encoding for supprted feature and Link power managment supprted if set
USHORT wSpeedsSuported;//low speed supported if set,full speed supported if set,high speed supported if set,super speed supported if set,15:4 nt used
UCHAR bFunctionalitySupporte;
UCHAR bU1DevExitLat;//U1 device exit latency
USHORT bU2DevExitLat;//U2 device exit latency
}USB_BOS_SS_DEVICE_CAPABILITY,*PUSB_BOS_SS_DEVICE_CAPABILITY;
typedef struct _USB_BOS_CONTAINER_ID
{
UCHAR bLength;/* Descriptor length*/
UCHAR bDescriptorType;/* Descriptor Type */
UCHAR bDevCapabilityType;/* Device capability type*/
UCHAR bReserved; // no use
UCHAR ContainerID[USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE];/* UUID */
}USB_BOS_CONTAINER_ID,*PUSB_BOS_CONTAINER_ID;
typedef struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR
{
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bMaxBurst;
UCHAR bmAttributes;
USHORT bBytesPerInterval;
}USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR,*PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR;
#pragma pack(pop)
#endif /*_CYUSB30_H*/

46
cpp/inc/UsbdStatus.h

@ -0,0 +1,46 @@
// Note: see usbdi.h in the DDK for the USBD_STATUS source definitions
typedef LONG USBD_STATUS;
#define USBD_STATUS(Status) ((ULONG)(Status) & 0x0FFFFFFFL)
#define USBD_STATE(Status) ((ULONG)(Status) & 0xF0000000L)
// HC status codes (Note: both error and stall bit are set)
#define USBD_STATUS_SUCCESS ((USBD_STATUS)0x00000000L)
#define USBD_STATUS_PENDING ((USBD_STATUS)0x40000000L)
#define USBD_STATUS_HALTED ((USBD_STATUS)0xC0000000L)
#define USBD_STATUS_ERROR ((USBD_STATUS)0x80000000L)
#define USBD_STATUS_CRC ((USBD_STATUS)0xC0000001L)
#define USBD_STATUS_BTSTUFF ((USBD_STATUS)0xC0000002L)
#define USBD_STATUS_DATA_TOGGLE_MISMATCH ((USBD_STATUS)0xC0000003L)
#define USBD_STATUS_STALL_PID ((USBD_STATUS)0xC0000004L)
#define USBD_STATUS_DEV_NOT_RESPONDING ((USBD_STATUS)0xC0000005L)
#define USBD_STATUS_PID_CHECK_FAILURE ((USBD_STATUS)0xC0000006L)
#define USBD_STATUS_UNEXPECTED_PID ((USBD_STATUS)0xC0000007L)
#define USBD_STATUS_DATA_OVERRUN ((USBD_STATUS)0xC0000008L)
#define USBD_STATUS_DATA_UNDERRUN ((USBD_STATUS)0xC0000009L)
#define USBD_STATUS_RESERVED1 ((USBD_STATUS)0xC000000AL)
#define USBD_STATUS_RESERVED2 ((USBD_STATUS)0xC000000BL)
#define USBD_STATUS_BUFFER_OVERRUN ((USBD_STATUS)0xC000000CL)
#define USBD_STATUS_BUFFER_UNDERRUN ((USBD_STATUS)0xC000000DL)
#define USBD_STATUS_NOT_ACCESSED ((USBD_STATUS)0xC000000FL)
#define USBD_STATUS_FIFO ((USBD_STATUS)0xC0000010L)
#define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS)0xC0000030L)
#define USBD_STATUS_NO_MEMORY ((USBD_STATUS)0x80000100L)
#define USBD_STATUS_INVALID_URB_FUNCTION ((USBD_STATUS)0x80000200L)
#define USBD_STATUS_INVALID_PARAMETER ((USBD_STATUS)0x80000300L)
#define USBD_STATUS_ERROR_BUSY ((USBD_STATUS)0x80000400L)
#define USBD_STATUS_REQUEST_FAILED ((USBD_STATUS)0x80000500L)
#define USBD_STATUS_INVALID_PIPE_HANDLE ((USBD_STATUS)0x80000600L)
#define USBD_STATUS_NO_BANDWIDTH ((USBD_STATUS)0x80000700L)
#define USBD_STATUS_INTERNAL_HC_ERROR ((USBD_STATUS)0x80000800L)
#define USBD_STATUS_ERROR_SHORT_TRANSFER ((USBD_STATUS)0x80000900L)
#define USBD_STATUS_BAD_START_FRAME ((USBD_STATUS)0xC0000A00L)
#define USBD_STATUS_ISOCH_REQUEST_FAILED ((USBD_STATUS)0xC0000B00L)
#define USBD_STATUS_FRAME_CONTROL_OWNED ((USBD_STATUS)0xC0000C00L)
#define USBD_STATUS_FRAME_CONTROL_NOT_OWNED ((USBD_STATUS)0xC0000D00L)
#define USBD_STATUS_CANCELED ((USBD_STATUS)0x00010000L)
#define USBD_STATUS_CANCELING ((USBD_STATUS)0x00020000L)

26
cpp/inc/VersionNo.h

@ -0,0 +1,26 @@
/*
## Cypress CyAPI C++ library version number header file (VersionNo.h)
## =======================================================
##
## Copyright Cypress Semiconductor Corporation, 2009-2018,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.rtf
##
## where <install> is the Cypress software
## install root directory path.
##
## =======================================================
*/
#define FILEVER 1,2,3,0
#define PRODUCTVER 1,2,3,0
#define STRFILEVER "1, 2, 3, 0"
#define STRPRODUCTVER "1, 2, 3, 0"
#define STRFILEVER_ASSENBLY "1.2.3.0"

213
cpp/inc/cyioctl.h

@ -0,0 +1,213 @@
/*
## Cypress CyAPI C++ library IOCTL defination header file (cyioctl.h)
## =======================================================
##
## Copyright Cypress Semiconductor Corporation, 2009-2012,
## All Rights Reserved
## UNPUBLISHED, LICENSED SOFTWARE.
##
## CONFIDENTIAL AND PROPRIETARY INFORMATION
## WHICH IS THE PROPERTY OF CYPRESS.
##
## Use of this file is governed
## by the license agreement included in the file
##
## <install>/license/license.rtf
##
## where <install> is the Cypress software
## install root directory path.
##
## =======================================================
*/
#ifndef __IOCTL_H__
#define __IOCTL_H__
#ifndef DRIVER
#ifndef CTL_CODE
#include <devioctl.h>
#endif
#ifndef BM_REQUEST_TYPE
#include "usb200.h"
#endif
#include <PSHPACK1.H>
#define DIR_HOST_TO_DEVICE 0
#define DIR_DEVICE_TO_HOST 1
#define DEVICE_SPEED_UNKNOWN 0x00000000
#define DEVICE_SPEED_LOW_FULL 0x00000001
#define DEVICE_SPEED_HIGH 0x00000002
#define DEVICE_SPEED_SUPER 0x00000004
typedef struct _WORD_SPLIT {
UCHAR lowByte;
UCHAR hiByte;
} WORD_SPLIT, *PWORD_SPLIT;
typedef struct _BM_REQ_TYPE {
UCHAR Recipient:2;
UCHAR Reserved:3;
UCHAR Type:2;
UCHAR Direction:1;
} BM_REQ_TYPE, *PBM_REQ_TYPE;
typedef struct _SETUP_PACKET {
union {
BM_REQ_TYPE bmReqType;
UCHAR bmRequest;
};
UCHAR bRequest;
union {
WORD_SPLIT wVal;
USHORT wValue;
};
union {
WORD_SPLIT wIndx;
USHORT wIndex;
};
union {
WORD_SPLIT wLen;
USHORT wLength;
};
ULONG ulTimeOut;
} SETUP_PACKET, *PSETUP_PACKET;
#define USB_ISO_ID 0x4945
#define USB_ISO_CMD_ASAP 0x8000
#define USB_ISO_CMD_CURRENT_FRAME 0x8001
#define USB_ISO_CMD_SET_FRAME 0x8002
typedef struct _ISO_ADV_PARAMS {
USHORT isoId;
USHORT isoCmd;
ULONG ulParam1;
ULONG ulParam2;
} ISO_ADV_PARAMS, *PISO_ADV_PARAMS;
typedef struct _ISO_PACKET_INFO {
ULONG Status;
ULONG Length;
} ISO_PACKET_INFO, *PISO_PACKET_INFO;
typedef struct _SINGLE_TRANSFER {
union {
SETUP_PACKET SetupPacket;
ISO_ADV_PARAMS IsoParams;
};
UCHAR reserved;
UCHAR ucEndpointAddress;
ULONG NtStatus;
ULONG UsbdStatus;
ULONG IsoPacketOffset;
ULONG IsoPacketLength;
ULONG BufferOffset;
ULONG BufferLength;
} SINGLE_TRANSFER, *PSINGLE_TRANSFER;
#endif // #ifndef DRIVER
typedef struct _SET_TRANSFER_SIZE_INFO {
UCHAR EndpointAddress;
ULONG TransferSize;
} SET_TRANSFER_SIZE_INFO, *PSET_TRANSFER_SIZE_INFO;
//
// Macro to extract function out of the device io control code
//
#ifdef WIN_98_DDK
#define DEVICE_TYPE_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0xffff0000)) >> 16)
#endif
#define FUNCTION_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0x00003FFC)) >> 2)
#define ACCESS_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0x000C0000)) >> 14)
//#define METHOD_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0x00000003)))
#define IOCTL_ADAPT_INDEX 0x0000
// Get the driver version
#define IOCTL_ADAPT_GET_DRIVER_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Get the current USBDI version
#define IOCTL_ADAPT_GET_USBDI_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+1, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Get the current device alt interface settings from driver
#define IOCTL_ADAPT_GET_ALT_INTERFACE_SETTING CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+2, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Set the device interface and alt interface setting
#define IOCTL_ADAPT_SELECT_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+3, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Get device address from driver
#define IOCTL_ADAPT_GET_ADDRESS CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+4, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Get number of endpoints for current interface and alt interface setting from driver
#define IOCTL_ADAPT_GET_NUMBER_ENDPOINTS CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+5, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Get the current device power state
#define IOCTL_ADAPT_GET_DEVICE_POWER_STATE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+6, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Set the device power state
#define IOCTL_ADAPT_SET_DEVICE_POWER_STATE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+7, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Send a raw packet to endpoint 0
#define IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+8, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Send/receive data to/from nonep0
#define IOCTL_ADAPT_SEND_NON_EP0_TRANSFER CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+9, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Simulate a disconnect/reconnect
#define IOCTL_ADAPT_CYCLE_PORT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+10, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Reset the pipe
#define IOCTL_ADAPT_RESET_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+11, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Reset the device
#define IOCTL_ADAPT_RESET_PARENT_PORT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+12, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Get the current transfer size of an endpoint (in number of bytes)
#define IOCTL_ADAPT_GET_TRANSFER_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+13, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Set the transfer size of an endpoint (in number of bytes)
#define IOCTL_ADAPT_SET_TRANSFER_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+14, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Return the name of the device
#define IOCTL_ADAPT_GET_DEVICE_NAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+15, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Return the "Friendly Name" of the device
#define IOCTL_ADAPT_GET_FRIENDLY_NAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+16, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Abort all outstanding transfers on the pipe
#define IOCTL_ADAPT_ABORT_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+17, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Send/receive data to/from nonep0 w/ direct buffer acccess (no buffering)
#define IOCTL_ADAPT_SEND_NON_EP0_DIRECT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+18, METHOD_NEITHER, FILE_ANY_ACCESS)
// Return device speed
#define IOCTL_ADAPT_GET_DEVICE_SPEED CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+19, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Get the current USB frame number
#define IOCTL_ADAPT_GET_CURRENT_FRAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+20, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define NUMBER_OF_ADAPT_IOCTLS 21 // Last IOCTL_ADAPT_INDEX + 1
#include <POPPACK.H>
#endif // __IOCTL_H__

270
cpp/inc/usb100.h

@ -0,0 +1,270 @@
#ifndef __USB100_H__
#define __USB100_H__
#include <PSHPACK1.H>
//bmRequest.Dir
#define BMREQUEST_HOST_TO_DEVICE 0
#define BMREQUEST_DEVICE_TO_HOST 1
//bmRequest.Type
#define BMREQUEST_STANDARD 0
#define BMREQUEST_CLASS 1
#define BMREQUEST_VENDOR 2
//bmRequest.Recipient
#define BMREQUEST_TO_DEVICE 0
#define BMREQUEST_TO_INTERFACE 1
#define BMREQUEST_TO_ENDPOINT 2
#define BMREQUEST_TO_OTHER 3
#define MAXIMUM_USB_STRING_LENGTH 255
// values for the bits returned by the USB GET_STATUS command
#define USB_GETSTATUS_SELF_POWERED 0x01
#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
#define USB_STRING_DESCRIPTOR_TYPE 0x03
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
// descriptor types defined by DWG documents
#define USB_RESERVED_DESCRIPTOR_TYPE 0x06
#define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07
#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08
#define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i))
//
// Values for bmAttributes field of an
// endpoint descriptor
//
#define USB_ENDPOINT_TYPE_MASK 0x03
#define USB_ENDPOINT_TYPE_CONTROL 0x00
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
#define USB_ENDPOINT_TYPE_BULK 0x02
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
//
// definitions for bits in the bmAttributes field of a
// configuration descriptor.
//
#define USB_CONFIG_POWERED_MASK 0xc0
#define USB_CONFIG_BUS_POWERED 0x80
#define USB_CONFIG_SELF_POWERED 0x40
#define USB_CONFIG_REMOTE_WAKEUP 0x20
//
// Endpoint direction bit, stored in address
//
#define USB_ENDPOINT_DIRECTION_MASK 0x80
// test direction bit in the bEndpointAddress field of
// an endpoint descriptor.
#define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
#define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
//
// USB defined request codes
// see chapter 9 of the USB 1.0 specifcation for
// more information.
//
// These are the correct values based on the USB 1.0
// specification
#define USB_REQUEST_GET_STATUS 0x00
#define USB_REQUEST_CLEAR_FEATURE 0x01
#define USB_REQUEST_SET_FEATURE 0x03
#define USB_REQUEST_SET_ADDRESS 0x05
#define USB_REQUEST_GET_DESCRIPTOR 0x06
#define USB_REQUEST_SET_DESCRIPTOR 0x07
#define USB_REQUEST_GET_CONFIGURATION 0x08
#define USB_REQUEST_SET_CONFIGURATION 0x09
#define USB_REQUEST_GET_INTERFACE 0x0A
#define USB_REQUEST_SET_INTERFACE 0x0B
#define USB_REQUEST_SYNC_FRAME 0x0C
//
// defined USB device classes
//
#define USB_DEVICE_CLASS_RESERVED 0x00
#define USB_DEVICE_CLASS_AUDIO 0x01
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
#define USB_DEVICE_CLASS_MONITOR 0x04
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
#define USB_DEVICE_CLASS_POWER 0x06
#define USB_DEVICE_CLASS_PRINTER 0x07
#define USB_DEVICE_CLASS_STORAGE 0x08
#define USB_DEVICE_CLASS_HUB 0x09
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
//
// USB Core defined Feature selectors
//
#define USB_FEATURE_ENDPOINT_STALL 0x0000
#define USB_FEATURE_REMOTE_WAKEUP 0x0001
//
// USB DWG defined Feature selectors
//
#define USB_FEATURE_INTERFACE_POWER_D0 0x0002
#define USB_FEATURE_INTERFACE_POWER_D1 0x0003
#define USB_FEATURE_INTERFACE_POWER_D2 0x0004
#define USB_FEATURE_INTERFACE_POWER_D3 0x0005
typedef struct _USB_DEVICE_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdUSB;
UCHAR bDeviceClass;
UCHAR bDeviceSubClass;
UCHAR bDeviceProtocol;
UCHAR bMaxPacketSize0;
USHORT idVendor;
USHORT idProduct;
USHORT bcdDevice;
UCHAR iManufacturer;
UCHAR iProduct;
UCHAR iSerialNumber;
UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
typedef struct _USB_ENDPOINT_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bEndpointAddress;
UCHAR bmAttributes;
USHORT wMaxPacketSize;
UCHAR bInterval;
} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
typedef struct _USB_CONFIGURATION_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT wTotalLength;
UCHAR bNumInterfaces;
UCHAR bConfigurationValue;
UCHAR iConfiguration;
UCHAR bmAttributes;
UCHAR MaxPower;
} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
typedef struct _USB_INTERFACE_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bInterfaceNumber;
UCHAR bAlternateSetting;
UCHAR bNumEndpoints;
UCHAR bInterfaceClass;
UCHAR bInterfaceSubClass;
UCHAR bInterfaceProtocol;
UCHAR iInterface;
} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
typedef struct _USB_STRING_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
WCHAR bString[1];
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
typedef struct _USB_COMMON_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
} USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
//
// Standard USB HUB definitions
//
// See Chapter 11 USB core specification
//
typedef struct _USB_HUB_DESCRIPTOR {
UCHAR bDescriptorLength; // Length of this descriptor
UCHAR bDescriptorType; // Hub configuration type
UCHAR bNumberOfPorts; // number of ports on this hub
USHORT wHubCharacteristics; // Hub Charateristics
UCHAR bPowerOnToPowerGood; // port power on till power good in 2ms
UCHAR bHubControlCurrent; // max current in mA
//
// room for 255 ports power control and removable bitmask
UCHAR bRemoveAndPowerMask[64];
} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
//
// Structures defined by various DWG feature documents
//
//
// See DWG USB Feature Specification: Interface Power Management
//
#define USB_SUPPORT_D0_COMMAND 0x01
#define USB_SUPPORT_D1_COMMAND 0x02
#define USB_SUPPORT_D2_COMMAND 0x04
#define USB_SUPPORT_D3_COMMAND 0x08
#define USB_SUPPORT_D1_WAKEUP 0x10
#define USB_SUPPORT_D2_WAKEUP 0x20
typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR SelfPowerConsumedD0[3];
UCHAR bPowerSummaryId;
UCHAR bBusPowerSavingD1;
UCHAR bSelfPowerSavingD1;
UCHAR bBusPowerSavingD2;
UCHAR bSelfPowerSavingD2;
UCHAR bBusPowerSavingD3;
UCHAR bSelfPowerSavingD3;
USHORT TransitionTimeFromD1;
USHORT TransitionTimeFromD2;
USHORT TransitionTimeFromD3;
} USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR;
typedef struct _USB_INTERFACE_POWER_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bmCapabilitiesFlags;
UCHAR bBusPowerSavingD1;
UCHAR bSelfPowerSavingD1;
UCHAR bBusPowerSavingD2;
UCHAR bSelfPowerSavingD2;
UCHAR bBusPowerSavingD3;
UCHAR bSelfPowerSavingD3;
USHORT TransitionTimeFromD1;
USHORT TransitionTimeFromD2;
USHORT TransitionTimeFromD3;
} USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR;
#include <POPPACK.H>
#endif /* __USB100_H__ */

111
cpp/inc/usb200.h

@ -0,0 +1,111 @@
#ifndef __USB200_H__
#define __USB200_H__
#include "usb100.h"
#include <PSHPACK1.H>
typedef enum _USB_DEVICE_SPEED {
UsbLowSpeed = 0,
UsbFullSpeed,
UsbHighSpeed
} USB_DEVICE_SPEED;
typedef enum _USB_DEVICE_TYPE {
Usb11Device = 0,
Usb20Device
} USB_DEVICE_TYPE;
// standard definiions for the port status
// word of the HUB port register
#define USB_PORT_STATUS_CONNECT 0x0001
#define USB_PORT_STATUS_ENABLE 0x0002
#define USB_PORT_STATUS_SUSPEND 0x0004
#define USB_PORT_STATUS_OVER_CURRENT 0x0008
#define USB_PORT_STATUS_RESET 0x0010
#define USB_PORT_STATUS_POWER 0x0100
#define USB_PORT_STATUS_LOW_SPEED 0x0200
#define USB_PORT_STATUS_HIGH_SPEED 0x0400
typedef union _BM_REQUEST_TYPE {
struct _BM {
UCHAR Recipient:2;
UCHAR Reserved:3;
UCHAR Type:2;
UCHAR Dir:1;
};
UCHAR B;
} BM_REQUEST_TYPE, *PBM_REQUEST_TYPE;
typedef struct _USB_DEFAULT_PIPE_SETUP_PACKET {
BM_REQUEST_TYPE bmRequestType;
UCHAR bRequest;
union _wValue {
struct {
UCHAR LowByte;
UCHAR HiByte;
};
USHORT W;
} wValue;
union _wIndex {
struct {
UCHAR LowByte;
UCHAR HiByte;
};
USHORT W;
} wIndex;
USHORT wLength;
} USB_DEFAULT_PIPE_SETUP_PACKET, *PUSB_DEFAULT_PIPE_SETUP_PACKET;
// setup packet is eight bytes -- defined by spec
C_ASSERT(sizeof(USB_DEFAULT_PIPE_SETUP_PACKET) == 8);
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 0x06
typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdUSB;
UCHAR bDeviceClass;
UCHAR bDeviceSubClass;
UCHAR bDeviceProtocol;
UCHAR bMaxPacketSize0;
UCHAR bNumConfigurations;
UCHAR bReserved;
} USB_DEVICE_QUALIFIER_DESCRIPTOR, *PUSB_DEVICE_QUALIFIER_DESCRIPTOR;
typedef union _USB_HIGH_SPEED_MAXPACKET {
struct _MP {
USHORT MaxPacket:11; /* 0..10 */
USHORT HSmux:2; /* 11..12 */
USHORT Reserved:3; /* 13..15 */
};
USHORT us;
} USB_HIGH_SPEED_MAXPACKET, *PUSB_HIGH_SPEED_MAXPACKET;
#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 0x0B
typedef struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR {
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bFirstInterface;
UCHAR bInterfaceCount;
UCHAR bFunctionClass;
UCHAR bFunctionSubClass;
UCHAR bFunctionProtocol;
UCHAR iFunction;
} USB_INTERFACE_ASSOCIATION_DESCRIPTOR, *PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR;
#include <POPPACK.H>
#endif __USB200_H__

BIN
cpp/lib/x64/CyAPI.lib

Binary file not shown.

BIN
cpp/lib/x86/CyAPI.lib

Binary file not shown.

145
datathread.cpp

@ -0,0 +1,145 @@
#include "datathread.h"
#include <QDebug>
#include "protocol.h"
datathread::datathread(QObject *parent)
: QThread{parent}
{
recvImage = (unsigned char*)malloc(2880*1600*4);
sendImage = (unsigned char*)malloc(2880*1600*4);
pureData = (unsigned char*)malloc(4*1024*1024*16);
data = (unsigned char*)malloc(4*1024*1024*16);
datalen = 0;
}
void datathread::SetImageInfo(int _type, int _rows, int _cols)
{
type = _type;
rows = _rows;
cols = _cols;
switch (type) {
case gray8:
bitsPerPix=1;
break;
case gray16:
bitsPerPix=2;
break;
default:
break;
}
msleep(100);
onImage = false;
if(type == gray8){
image = Mat(rows,cols,CV_8UC1);
}
else if(type == gray16){
image = Mat(rows,cols,CV_16UC1);
}
}
void datathread::stopProcess()
{
}
void datathread::setStatu(bool _run)
{
isRun = _run;
}
void datathread::appendData(char *data, int len)
{
// qDebug()<<"get data with "<<len;
dataMutex.lock();
if(datalen+len>4*1024*1024*16){
dataMutex.unlock();
return;
}
memcpy(pureData+datalen,data,len);
datalen += len;
dataMutex.unlock();
}
int sizeofhead = 64;
void datathread::run(){
minLen = MINFrameSize;
datalen = 0;
onImage = false;//是否传输图像中
onLine = false;
lineNum = 0;
pixNum = 0;
while(isRun){
dataMutex.lock();
int len = datalen;
// qDebug()<<"data len "<<len;
memcpy(data,pureData,len);
dataMutex.unlock();
int i = 0;
for(;i<(len-sizeofhead);i+=4){
if(!onImage){
if(data[i] == 0xff&& data[i+1] == 0xff&& data[i+2] == 0xff&& data[i+3] == 0xff ){
onImage = true;
// qDebug()<<"get head";
}
}
else{
if(!onLine){
if(data[i] == 0xf0){
lineNum = (data[i+1]*256+data[i+2])*256+data[i+3];
pixNum = 0;
onLine = true;
}
}
else{
if(lineNum<rows && pixNum<cols){
for(int j =0;j<bitsPerPix;j++){
recvImage[(lineNum*cols+pixNum)*bitsPerPix+j] = data[i+4-1-j];
}
if(type == gray8 && image.type() == CV_8UC1){
image.at<uchar>(lineNum,pixNum) = data[i+3];
}
else if(type == gray16 && image.type() == CV_16UC1){
image.at<ushort>(lineNum,pixNum) = data[i+2]*256+data[i+3];
}
}
pixNum += 1;
if(pixNum==cols){
onLine = false;
if(lineNum+1 == rows){
memcpy(sendImage,recvImage,rows*cols*bitsPerPix);
// emit(signalGetImage(sendImage));
image.copyTo(temp);
emit(signalGetImage(temp));
// qDebug()<<"send image";
onImage = false;
}
}
}
}
}
dataMutex.lock();
memcpy(pureData,pureData+i,datalen-i);
datalen -=i;
dataMutex.unlock();
}
}

60
datathread.h

@ -0,0 +1,60 @@
#ifndef DATATHREAD_H
#define DATATHREAD_H
#include <qt_windows.h>
#include <QObject>
#include <QThread>
#include <QByteArray>
#include <QMutex>
#include <opencv2/opencv.hpp>
using namespace cv;
class datathread : public QThread
{
Q_OBJECT
public:
explicit datathread(QObject *parent = nullptr);
void SetImageInfo(int _type, int _rows, int _cols);
void stopProcess();
void setStatu(bool _run);
public slots:
void appendData(char* data,int len);
signals:
void signalGetImage(cv::Mat);
protected:
void run()override;
private:
QMutex dataMutex;
int minLen;
bool onImage;
bool onLine;
int cols;
int rows;
int type;
int lineNum;
int pixNum;
unsigned char* recvImage;
unsigned char* sendImage;
int bitsPerPix;
unsigned char* pureData;
unsigned char* data;
int datalen;
bool isRun;
Mat image;
Mat temp;
};
#endif // DATATHREAD_H

50
dde.cpp

@ -0,0 +1,50 @@
#include "dde.h"
dde::dde(QObject *parent)
: QObject{parent}
{
ready = false;
dderate = 1;
thread = new QThread();
thread->start();
this->moveToThread(thread);
}
void dde::setpara(double rate)
{
dderate = rate;
ready = true;
if(rate ==0 )
ready = false;
}
void dde::off()
{
ready = false;
}
void dde::slotprocimg(cv::Mat img)
{
if(ready){
cv::Mat gauss;
cv::GaussianBlur(img,gauss,cv::Size(5,5),5);
cv::Mat dst(img.rows,img.cols,CV_16UC1);
for(int i = 0;i<img.rows;i++){
for(int j = 0; j<img.cols;j++){
int temp = dderate*(img.at<ushort>(i,j)-gauss.at<ushort>(i,j))+gauss.at<ushort>(i,j);
dst.at<ushort>(i,j) =temp;
if(temp<0)
dst.at<ushort>(i,j) = 0;
if(temp>65535)
dst.at<ushort>(i,j) = 65535;
}
}
emit signalsendimg(dst);
}
else{
cv::Mat temp;
img.copyTo(temp);
emit signalsendimg(temp);
}
}

27
dde.h

@ -0,0 +1,27 @@
#ifndef DDE_H
#define DDE_H
#include <QObject>
#include <QThread>
#include <opencv2/opencv.hpp>
class dde : public QObject
{
Q_OBJECT
public:
explicit dde(QObject *parent = nullptr);
void setpara(double rate);
void off();
public slots:
void slotprocimg(cv::Mat img);
signals:
void signalsendimg(cv::Mat img);
private:
QThread* thread;
double dderate;
bool ready;
};
#endif // DDE_H

41
login.cpp

@ -0,0 +1,41 @@
#include "login.h"
#include "ui_login.h"
login::login(QWidget *parent) :
QWidget(parent),
ui(new Ui::login)
{
ui->setupUi(this);
setAttribute(Qt::WA_TranslucentBackground);
// setStyleSheet("background-color:{rgba:0,0,0,0}");
// setWindowOpacity(0.5);
setWindowFlag(Qt::FramelessWindowHint);
t = new QTimer();
s = 0;
ui->progressBar->setValue(0);
ui->progressBar->setAlignment(Qt::AlignVCenter);
connect(t,SIGNAL(timeout()),this,SLOT(slotTimeout()));
t->start(1000);
}
login::~login()
{
delete ui;
delete w;
}
void login::slotTimeout()
{
s+=1;
if(s<6)
ui->progressBar->setValue(s*20);
else{
t->stop();
delete t;
close();
emit(signalReady());
// w = new MainWindow();
// w->show();
}
}

32
login.h

@ -0,0 +1,32 @@
#ifndef LOGIN_H
#define LOGIN_H
#include "mainwindow.h"
#include <QWidget>
#include <QTimer>
namespace Ui {
class login;
}
class login : public QWidget
{
Q_OBJECT
public:
explicit login(QWidget *parent = nullptr);
~login();
public slots:
void slotTimeout();
signals:
void signalReady();
private:
Ui::login *ui;
QTimer* t;
int s;
MainWindow* w;
};
#endif // LOGIN_H

41
login.ui

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>login</class>
<widget class="QWidget" name="login">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>146</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>../../zxrcClient/zxrcClient/logo.ico</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

BIN
logo.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

18
main.cpp

@ -0,0 +1,18 @@
#include "mainwindow.h"
#include <QApplication>
#include <FluentApp.h>
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(qfluentwidgets);
qfluentwidgets::setLicense("RjU5dGJZUE9ORkQ2SFg2T2RVaVQrMXEvUFpZSjdHU2x4NnNRR2p5VjRKYS8wWFppcE1sNjhtRVRoNmF4eHltSHg1dnVpWm12M0g4TzQxaEY5eUlTQXFodWo2dzQ1S3hPYWtMMXAvSkRDYXZNcyt0bg==");
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

563
mainwindow.cpp

@ -0,0 +1,563 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QDateTime>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
initIns();
initUI();
initConnect();
#if CLIENT==1
hideui();
#endif
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::initUI()
{
b_stat = false;
flip0 = false;
flip1 = false;
savevideo = false;
savebin = false;
savesbin = false;
shotimg = false;
shotbin = false;
path = "";
fps = 0;
fpscount = 0;
path = QApplication::applicationDirPath()+"/";
setWindowTitle(QString(ProjectVersion));
ui->splitter_2->setCollapsible(1,false);
// QHBoxLayout lout = QHBoxLayout();
ui->toolBar->addWidget(ui->pushButton);
ui->toolBar->addWidget(ui->pushButton_2);
ui->toolBar->addWidget(ui->label_2);
ui->toolBar->addWidget(ui->spinBox);
ui->toolBar->addWidget(ui->label_3);
ui->toolBar->addWidget(ui->spinBox_2);
m1 = new menu1();
m2 = new menu2();
m3 = new menu3();
m4 = new menu4();
ui->toolbox->addItem(m1,u8"相机设置");
ui->toolbox->addItem(m2,u8"算法设置");
ui->toolbox->addItem(m3,u8"显示设置");
ui->toolbox->addItem(m4,u8"保存设置");
type = gray8;
rows = ui->spinBox->value();
cols = ui->spinBox_2->value();
ui->scrollAreaWidgetContents->setMinimumSize(cols+20,rows+20);
ui->label->resize(cols,rows);
ui->tableWidget->horizontalHeader()->hide();
ui->tableWidget->verticalHeader()->hide();
ui->tableWidget->setRowCount(5);
ui->tableWidget->setColumnCount(5);
ui->tableWidget->resizeColumnsToContents();
ui->tableWidget->resizeRowsToContents();
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->label->installEventFilter(this);
}
void MainWindow::initConnect()
{
connect(usb,SIGNAL(signalGetImage(cv::Mat)),this,SLOT(slotShowImage(cv::Mat)));
connect(m1,SIGNAL(signalsavelow()),ucontrol,SLOT(savelow()));
connect(m1,SIGNAL(signalsavehigh()),ucontrol,SLOT(savehigh()));
connect(m1,SIGNAL(signalcalck()),ucontrol,SLOT(calck()));
connect(m1,SIGNAL(signalsavek()),ucontrol,SLOT(savek()));
connect(m1,SIGNAL(signalopenk(bool)),ucontrol,SLOT(openk(bool)));
connect(m1,SIGNAL(signalonepoint()),ucontrol,SLOT(onepoint()));
connect(m1,SIGNAL(signalsaveb()),ucontrol,SLOT(saveb()));
connect(m1,SIGNAL(signalopenb(bool)),ucontrol,SLOT(openb(bool)));
connect(m1,SIGNAL(signalsetGPOL(int)),ucontrol,SLOT(setGPOL(int)));
connect(m1,SIGNAL(signalsetIT(double)),ucontrol,SLOT(setIT(double)));
connect(m1,SIGNAL(signalopenTEC(bool)),ucontrol,SLOT(tec(bool)));
connect(m1,SIGNAL(signalset14bit(bool)),ucontrol,SLOT(bit14(bool)));
connect(m1,&menu1::signalset14bit,[=](bool b){
if(b)
usb->SetImageInfo(gray16,rows,cols);
else
usb->SetImageInfo(gray8,rows,cols);
});
connect(m2,SIGNAL(signalsag(bool)),ucontrol,SLOT(setsag(bool)));
connect(m2,SIGNAL(signalsetDDE(int)),ucontrol,SLOT(setDDE(int)));
connect(m2,SIGNAL(signalsetkf(int)),ucontrol,SLOT(setkf(int)));
connect(m2,SIGNAL(signalsethist(int)),ucontrol,SLOT(sethist(int)));
// connect(m2,SIGNAL(signalsetDE(bool)),)
// connect(m2,SIGNAL(signalseterate(double)),)
// connect(m2,SIGNAL(signalsetbright(int)),)
///线性拉伸设置
///
///
connect(ucontrol,SIGNAL(signalSendMessage(QString)),this,SLOT(slotlogtext(QString)));
connect(m3,&menu3::signalflip0,[=](bool b){
flip0 = b;
});
connect(m3,&menu3::signalflip1,[=](bool b){
flip1 = b;
});
connect(m3,&menu3::signalturnl,[=](){
turnl = true;
turnf = false;
turnr = false;
});
connect(m3,&menu3::signalturnf,[=](){
turnl = false;
turnf = true;
turnr = false;
});
connect(m3,&menu3::signalturnr,[=](){
turnl = false;
turnf = false;
turnr = true;
});
connect(m3,&menu3::signalcolorgray,[=](){
colortype =0;//gray
});
connect(m3,&menu3::signalcolorsub,[=](){
colortype = 1;//sub
});
connect(m3,&menu3::signalcolorrgb,[=](){
colortype = 2;
});
connect(m4,&menu4::signalsetdir,[=](QString dir){
if(dir == ""){
path = QApplication::applicationDirPath()+"/";
}
else{
path = dir+"/";
}
});
connect(m4,&menu4::signalshotimg,[=](){
shotimg = true;
});
connect(m4,&menu4::signalshotbin,[=](){
shotbin = true;
});
connect(m4,&menu4::signalsavevideo,[=](bool b){
if(b){
QString now = QDateTime::currentDateTime().toString("yyyy_MM_dd_hh_mm_ss");
std::string filename = path.toStdString()+now.toStdString()+".mp4";
writer = new cv::VideoWriter(filename,cv::VideoWriter::fourcc('M','P','4','V'),fps,cv::Size(cols,rows),false);
QString msg = now +QString::fromLocal8Bit( "开始保存视频");
slotlogtext(msg);
savevideo =true;
}
else{
savevideo = false;
writer->release();
QDateTime t = QDateTime::currentDateTime();
QString msg = t.toString() +QString::fromLocal8Bit( "结束保存视频");
slotlogtext(msg);
}
});
connect(m4,&menu4::signalsavebin,[=](bool b){
if(b){
QString now = QDateTime::currentDateTime().toString("/yyyy-MM-dd-hh-mm-ss");
QString filename = path+now;
if(type == gray8)
filename += "8bit.bin";
else if(type == gray16)
filename += "14bit.bin";
purefile = new QFile(filename);
purefile->open(QIODevice::ReadWrite);
savebin = true;
QString msg = now +QString::fromLocal8Bit( "开始保存数据");
slotlogtext(msg);
}
else{
savebin = false;
purefile->close();
QString now = QDateTime::currentDateTime().toString("/yyyy-MM-dd-hh-mm-ss");
QString msg = now +QString::fromLocal8Bit( "结束保存数据");
slotlogtext(msg);
}
});
connect(m4,&menu4::signalsavesbin,[=](int frames){
if(savesbin)
return;
QString now = QDateTime::currentDateTime().toString("/yyyy-MM-dd-hh-mm-ss");
QString filename = path+now;
if(type == gray8)
filename += "8bit.bin";
else if(type == gray16)
filename += "14bit.bin";
spurefile = new QFile(filename);
spurefile->open(QIODevice::ReadWrite); sbinnum = frames;
savesbin = true;
});
}
void MainWindow::hideui()
{
m1->hideui();
m2->hideui();
}
void MainWindow::on_pushButton_clicked()// 开启传输
{
if(ui->pushButton->isChecked()){
usb->SetImageInfo(type,rows,cols);
usb->setStatu(true);
usb->start();
ui->pushButton->setText(u8"停止传输");
}
else{
usb->setStatu(false);
usb->stopProcessData();
ui->pushButton->setText(u8"开始传输");
}
}
void MainWindow::on_pushButton_2_clicked()
{
//恢复默认设置
#ifndef CLIENT
ucontrol->bit14(false);
type = gray8;
#elif CLIENT == 1
ucontrol->bit14(false);
type = gray8;
qDebug()<<"sim";
#elif CLIENT == 2
ucontrol->bit14(true);
type = gray16;
qDebug()<<"pc";
#endif
ucontrol->setIT(5.0);
ucontrol->setGPOL(800);
ucontrol->sethist(200);
ucontrol->openk(true);
ucontrol->openb(true);
}
void MainWindow::on_pushButton_3_clicked()
{
b_stat = ui->pushButton_3->isChecked();
if(b_stat){
ui->pushButton_3->setText(u8"暂停统计");
}
else{
ui->pushButton_3->setText(u8"开始统计");
}
}
void MainWindow::slotShowImage(cv::Mat img)
{
fpscount +=1;
if(shotimg){
QString now = QDateTime::currentDateTime().toString("yyyy_MM_dd_hh_mm_ss");
QString file = path+ now+".png";
cv::imwrite(file.toLocal8Bit().toStdString(),img);
shotimg = false;
}
if(shotbin){
QDateTime t = QDateTime::currentDateTime();
QString filename = path+ t.toString("yyyy-MM-dd-hh-mm-ss");
if(type == gray8)
filename+= "-8bit.bin";
else if(type == gray16)
filename+= "-14bit.bin";
QFile file(filename);
file.open(QIODevice::NewOnly);
file.write((char*)img.data,img.total()*img.elemSize());
file.flush();
file.close();
shotbin = false;
}
if(savevideo){
writer->write(img);
}
if(savebin){
purefile->write((char*)img.data,img.total()*img.elemSize());
purefile->flush();
}
if(savesbin){
if(sbinnum>0){
spurefile->write((char*)img.data,img.total()*img.elemSize());
spurefile->flush();
}
sbinnum -=1;
// qDebug()<<sbinnum;
if(sbinnum == 0){
spurefile->close();
savesbin = false;
}
}
if(flip0){
cv::flip(img,img,0);
}
if(flip1){
cv::flip(img,img,1);
}
if(turnl){
}
else if(turnr){
}
if(b_stat ){
if(img.type() == CV_16UC1)
lastimage = img/4;
else
lastimage = img;
if( imageX>=0 && imageX<img.cols && imageY>=0 && imageY< img.rows){
int r = 2;
int lmask[25] = {0};
int ldata[25] = {0};
for (int i = -r;i<=r;i++){
for (int j = -r;j<=r;j++){
int row = i+imageY;
int col = j+imageX;
if(row<0 || row>=lastimage.rows|| col<0 || col>=lastimage.cols){
ui->tableWidget->setItem(i+r,j+r,new QTableWidgetItem());
}
else{
lmask[(i+r)*(2*r+1)+(j+r)] = 1;
if(lastimage.type() == CV_16UC1){
QTableWidgetItem *item = new QTableWidgetItem(QString::number(lastimage.at<ushort>(row,col)));
int gray = lastimage.at<ushort>(row,col)/64/2+64;
item->setBackground(QColor(gray,gray,gray));
ui->tableWidget->setItem(i+r,j+r,item);
ldata[(i+r)*(2*r+1)+(j+r)] = lastimage.at<ushort>(row,col);
}
else{
QTableWidgetItem *item = new QTableWidgetItem(QString::number(lastimage.at<uchar>(row,col)));
int gray = lastimage.at<uchar>(row,col)/2+64;
item->setBackground(QColor(gray,gray,gray));
ui->tableWidget->setItem(i+r,j+r,item);
ldata[(i+r)*(2*r+1)+(j+r)] = lastimage.at<uchar>(row,col);
}
}
}
}
double sum = 0;
double msum = 0;
double sum2 = 0;
for(int i = 0; i< 25;i++){
sum+= lmask[i]*ldata[i];
msum += lmask[i];
sum2 += lmask[i]*ldata[i]*ldata[i];
}
if(msum!=0){
double avg = sum/msum;
double SIGMA = sum2/msum - avg*avg;
double sigma = sqrt(SIGMA);
ui->lineEdit->setText(QString::number(imageX));
ui->lineEdit_2->setText(QString::number(imageY));
ui->lineEdit_3->setText(QString::number(avg,'f',2));
ui->lineEdit_4->setText(QString::number(sigma,'f',2));
}
}
else{
ui->lineEdit->setText("");
ui->lineEdit_2->setText("");
ui->lineEdit_3->setText("");
ui->lineEdit_4->setText("");
}
int lows = 0;
int highs = 0;
double sum = 0;
double sum2 = 0;
double sigma = 0;
if(lastimage.type() == CV_16UC1){
for(int i = 0;i<lastimage.rows;i++){
for(int j = 0; j<lastimage.cols;j++){
int temp;
temp =lastimage.at<ushort>(i,j);
if(temp == 0){
lows+=1;
}
if(temp == 16383){
highs +=1;
}
sum += temp;
sum2+=temp*temp;
}
}
}
else{
for(int i = 0;i<lastimage.rows;i++){
for(int j = 0; j<lastimage.cols;j++){
int temp;
temp =lastimage.at<uchar>(i,j);
sum += temp;
sum2+=temp*temp;
}
}
}
int avg = sum/512/640;
sigma = sqrt( sum2/512/640 -avg*avg);
if(lastimage.type() == CV_16UC1){
ui->lineEdit_5->setText(QString::number(lows));
ui->lineEdit_6->setText(QString::number(highs));
}
else{
ui->lineEdit_5->setText("");
ui->lineEdit_6->setText("");
}
ui->lineEdit_7->setText(QString::number(avg,'f',2));
ui->lineEdit_8->setText(QString::number(sigma,'f',2));
}
if(img.type() == CV_16UC1)
img.convertTo(img,CV_8UC1,1.0/257);
QImage image(img.data,img.cols,img.rows,img.cols,QImage::Format_Grayscale8);
QPixmap pix = QPixmap::fromImage(image);
// QPixmap pix = QPixmap::fromImage(img);
if(b_stat){
QPainter p(&pix);
QPen pen = p.pen();
QPen npen(QColor(0xad,0x14,0x53));
npen.setWidth(4);
p.setPen(npen);
if(imageX>=0 && imageX<img.cols && imageY>=0 && imageY< img.rows){
p.drawLine(imageX-10,imageY,imageX+10,imageY);
p.drawLine(imageX,imageY-10,imageX,imageY+10);
}
p.setPen(pen);
}
ui->label->setPixmap(pix);
}
void MainWindow::slotlogtext(QString msg)
{
ui->textBrowser->append(msg);
}
void MainWindow::slotlogstatus()
{
QString msg = QString::fromLocal8Bit("当前图像深度为");
if(type==gray8){
msg+=QString::fromLocal8Bit( "8位");
}
else{
msg+=QString::fromLocal8Bit("14位");
}
msg+=QString::fromLocal8Bit(",帧率为")+QString::number(fps);
ui->statusbar->showMessage(msg);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *e)
{
if(obj == ui->label && e->type() == QEvent::MouseButtonPress){
QMouseEvent* ev = static_cast<QMouseEvent*>(e);
imageX = ev->x();
imageY =ev->y();
return true;
}
return false;
}
void MainWindow::keyPressEvent(QKeyEvent *ev)
{
if(ev->key() == Qt::Key_A){
imageX-=1;
}
if(ev->key() == Qt::Key_D){
imageX+=1;
}
if(ev->key() == Qt::Key_W){
imageY-=1;
}
if(ev->key() == Qt::Key_S){
imageY+=1;
}
}
void MainWindow::initIns()
{
qRegisterMetaType<cv::Mat>("cv::Mat");
usb = new usbthread();
ucontrol = new usbcontrol();
QTimer* t = new QTimer(this);
connect(t,&QTimer::timeout,[=](){
fps = fpscount;
fpscount = 0;
slotlogstatus();
});
t->start(1000);
}
void MainWindow::on_spinBox_valueChanged(int arg1)
{
rows = arg1;
ui->scrollAreaWidgetContents->setMinimumHeight(rows+20);
ui->label->resize(cols,rows);
}
void MainWindow::on_spinBox_2_valueChanged(int arg1)
{
cols = arg1;
ui->scrollAreaWidgetContents->setMinimumWidth(cols+20);
ui->label->resize(cols,rows);
}

110
mainwindow.h

@ -0,0 +1,110 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFile>
#include "menu1.h"
#include "menu2.h"
#include "menu3.h"
#include "menu4.h"
#include "usbcontrol.h"
#include "usbthread.h"
#include "protocol.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
public slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void slotShowImage(cv::Mat);
void slotlogtext(QString);
void slotlogstatus();
protected:
bool eventFilter(QObject* obj,QEvent *e) override;
void keyPressEvent(QKeyEvent* ev) override;
private slots:
void on_spinBox_valueChanged(int arg1);
void on_spinBox_2_valueChanged(int arg1);
private:
void initIns();
void initUI();
void initConnect();
void hideui();
private:
Ui::MainWindow *ui;
menu1* m1;
menu2* m2;
menu3* m3;
menu4* m4;
usbcontrol* ucontrol;
usbthread* usb;
int type;
int rows;
int cols;
QString path;
bool flip0;
bool flip1;
bool turnl;
bool turnf;
bool turnr;
bool b_stat;//
int imageY;
int imageX;
bool shotimg;
bool shotbin;
bool savevideo;
bool savebin;
bool savesbin;
int sbinnum;
int colortype;
cv::VideoWriter* writer;
QFile* purefile;
QFile* spurefile;
int fps;
int fpscount;
cv::Mat lastimage;
};
#endif // MAINWINDOW_H

283
mainwindow.ui

@ -0,0 +1,283 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1092</width>
<height>607</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="5">
<widget class="SpinBox" name="spinBox_2">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>640</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="TogglePushButton" name="pushButton">
<property name="text">
<string>开始传输</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string> 行数 </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="PushButton" name="pushButton_2">
<property name="text">
<string>恢复默认</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="SpinBox" name="spinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>512</number>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_3">
<property name="text">
<string> 列数 </string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="6">
<widget class="Splitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="Splitter" name="splitter_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="ToolBox" name="toolbox" native="true"/>
<widget class="QTextBrowser" name="textBrowser"/>
</widget>
<widget class="QScrollArea" name="scrollArea">
<property name="minimumSize">
<size>
<width>648</width>
<height>520</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>646</width>
<height>518</height>
</rect>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>621</width>
<height>481</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="8" column="1">
<widget class="QLineEdit" name="lineEdit_6"/>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_3"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>中心点横坐标</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="TogglePushButton" name="pushButton_3">
<property name="text">
<string>开始统计</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>区域平均值</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_4"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="13" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>中心点纵坐标</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>全局平均值</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="lineEdit_7"/>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>全局均方根</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>区域均方根</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEdit_5"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>截止点数</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>溢出点数</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="lineEdit_8"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>TogglePushButton</class>
<extends>QPushButton</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>SpinBox</class>
<extends>QSpinBox</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>ToolBox</class>
<extends>QWidget</extends>
<header location="global">qfluentwidgets</header>
<container>1</container>
</customwidget>
<customwidget>
<class>Splitter</class>
<extends>QSplitter</extends>
<header location="global">qfluentwidgets</header>
<container>1</container>
</customwidget>
<customwidget>
<class>PushButton</class>
<extends>QPushButton</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

117
menu1.cpp

@ -0,0 +1,117 @@
#include "menu1.h"
#include "ui_menu1.h"
menu1::menu1(QWidget *parent) :
QWidget(parent),
ui(new Ui::menu1)
{
ui->setupUi(this);
}
menu1::~menu1()
{
delete ui;
}
void menu1::hideui()
{
ui->pushButton_4->hide();
ui->pushButton_7->hide();
ui->pushButton_12->hide();
}
void menu1::on_pushButton_clicked()
{
emit signalsavelow();
}
void menu1::on_pushButton_2_clicked()
{
emit signalsavehigh();
}
void menu1::on_pushButton_3_clicked()
{
emit signalcalck();
}
void menu1::on_pushButton_4_clicked()
{
emit signalsavek();
}
void menu1::on_pushButton_5_clicked()
{
emit signalopenk(ui->pushButton_5->isChecked());
if(ui->pushButton_5->isChecked()){
ui->pushButton_5->setText(u8"关闭K值");
}
else{
ui->pushButton_5->setText(u8"开启K值");
}
}
void menu1::on_pushButton_6_clicked()
{
emit signalonepoint();
}
void menu1::on_pushButton_7_clicked()
{
emit signalsaveb();
}
void menu1::on_pushButton_8_clicked()
{
emit signalopenb(ui->pushButton_8->isChecked());
if(ui->pushButton_8->isChecked()){
ui->pushButton_8->setText(u8"关闭B值");
}
else{
ui->pushButton_8->setText(u8"开启B值");
}
}
void menu1::on_pushButton_9_clicked()
{
emit signalsetGPOL(ui->spinBox->value());
}
void menu1::on_pushButton_10_clicked()
{
emit signalsetIT(ui->doubleSpinBox->value());
}
void menu1::on_pushButton_11_clicked()
{
emit signalopenTEC(ui->pushButton_11->isChecked());
if(ui->pushButton_11->isChecked()){
ui->pushButton_11->setText(u8"关闭TEC");
}
else{
ui->pushButton_11->setText(u8"开启TEC");
}
}
void menu1::on_pushButton_12_clicked()
{
emit signalset14bit(ui->pushButton_12->isChecked());
if(ui->pushButton_12->isChecked()){
ui->pushButton_12->setText(u8"切换8bit");
}
else{
ui->pushButton_12->setText(u8"切换14bit");
}
}

62
menu1.h

@ -0,0 +1,62 @@
#ifndef MENU1_H
#define MENU1_H
#include <QWidget>
namespace Ui {
class menu1;
}
class menu1 : public QWidget
{
Q_OBJECT
public:
explicit menu1(QWidget *parent = nullptr);
~menu1();
void hideui();
signals:
void signalsavelow();
void signalsavehigh();
void signalcalck();
void signalsavek();
void signalopenk(bool);
void signalonepoint();
void signalsaveb();
void signalopenb(bool);
void signalsetGPOL(int);
void signalsetIT(double);
void signalopenTEC(bool);
void signalset14bit(bool);
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
void on_pushButton_5_clicked();
void on_pushButton_6_clicked();
void on_pushButton_7_clicked();
void on_pushButton_8_clicked();
void on_pushButton_9_clicked();
void on_pushButton_10_clicked();
void on_pushButton_11_clicked();
void on_pushButton_12_clicked();
private:
Ui::menu1 *ui;
};
#endif // MENU1_H

139
menu1.ui

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>menu1</class>
<widget class="QWidget" name="menu1">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>209</width>
<height>640</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>存低温背景</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>存高温背景</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>计算K值</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>保存K值</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="TogglePushButton" name="pushButton_5">
<property name="text">
<string>开启K值</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>单点校正</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_7">
<property name="text">
<string>保存B值</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="TogglePushButton" name="pushButton_8">
<property name="text">
<string>开启B值</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="SpinBox" name="spinBox">
<property name="maximum">
<number>4000</number>
</property>
<property name="singleStep">
<number>0</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButton_9">
<property name="text">
<string>设置GPOL(mv)</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="DoubleSpinBox" name="doubleSpinBox">
<property name="maximum">
<double>35.000000000000000</double>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="pushButton_10">
<property name="text">
<string>设置积分时间(ms)</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="TogglePushButton" name="pushButton_11">
<property name="text">
<string>开启TEC</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="TogglePushButton" name="pushButton_12">
<property name="text">
<string>切换14Bit</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TogglePushButton</class>
<extends>QPushButton</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>SpinBox</class>
<extends>QSpinBox</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

89
menu2.cpp

@ -0,0 +1,89 @@
#include "menu2.h"
#include "ui_menu2.h"
menu2::menu2(QWidget *parent) :
QWidget(parent),
ui(new Ui::menu2)
{
ui->setupUi(this);
}
menu2::~menu2()
{
delete ui;
}
void menu2::hideui()
{
ui->label->hide();
ui->label_2->hide();
ui->spinBox_4->hide();
ui->doubleSpinBox->hide();
ui->pushButton_5->hide();
}
void menu2::on_pushButton_clicked()
{
emit signalsag(ui->pushButton->isChecked());
if(ui->pushButton->isChecked()){
ui->pushButton->setText(u8"关闭空间滤波");
}
else{
ui->pushButton->setText(u8"开启空间滤波");
}
}
void menu2::on_pushButton_2_clicked()
{
emit signalsetDDE(ui->spinBox->value());
}
void menu2::on_pushButton_3_clicked()
{
emit signalsetkf(ui->spinBox_2->value());
}
void menu2::on_pushButton_4_clicked()
{
emit signalsethist(ui->spinBox_3->value());
}
void menu2::on_pushButton_5_clicked()
{
emit signalsetDE(ui->pushButton_5->isChecked());
if(ui->pushButton_5->isChecked()){
ui->pushButton_5->setText(u8"关闭数字增强");
}
else{
ui->pushButton_5->setText(u8"开启数字增强");
}
}
void menu2::on_doubleSpinBox_valueChanged(double arg1)
{
emit signalseterate(arg1);
}
void menu2::on_spinBox_4_valueChanged(int arg1)
{
emit signalsetbright(arg1);
}
void menu2::on_pushButton_6_clicked()
{
emit signalbila(ui->pushButton_6->isChecked());
if(ui->pushButton_6->isChecked()){
ui->pushButton_6->setText(u8"关闭双边滤波");
}
else{
ui->pushButton_6->setText(u8"开启双边滤波");
}
}

51
menu2.h

@ -0,0 +1,51 @@
#ifndef MENU2_H
#define MENU2_H
#include <QWidget>
namespace Ui {
class menu2;
}
class menu2 : public QWidget
{
Q_OBJECT
public:
explicit menu2(QWidget *parent = nullptr);
~menu2();
void hideui();
signals:
void signalsag(bool);
void signalsetDDE(int);
void signalsetkf(int);
void signalsethist(int);
void signalsetDE(bool);
void signalbila(bool);
void signalseterate(double);
void signalsetbright(int);
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
void on_pushButton_5_clicked();
void on_doubleSpinBox_valueChanged(double arg1);
void on_spinBox_4_valueChanged(int arg1);
void on_pushButton_6_clicked();
private:
Ui::menu2 *ui;
};
#endif // MENU2_H

130
menu2.ui

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>menu2</class>
<widget class="QWidget" name="menu2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>640</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="TogglePushButton" name="pushButton">
<property name="text">
<string>开启空间滤波</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="SpinBox" name="spinBox">
<property name="maximum">
<number>1023</number>
</property>
<property name="value">
<number>250</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>设置DDE增益</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="SpinBox" name="spinBox_2">
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>85</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>设置数字滤波系数</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="SpinBox" name="spinBox_3">
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>200</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>设置直方图平台值</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="TogglePushButton" name="pushButton_5">
<property name="text">
<string>开启数字增强</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>对比度</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="DoubleSpinBox" name="doubleSpinBox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>亮度</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="SpinBox" name="spinBox_4"/>
</item>
<item row="0" column="1">
<widget class="TogglePushButton" name="pushButton_6">
<property name="text">
<string>开启双边滤波</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TogglePushButton</class>
<extends>QPushButton</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>SpinBox</class>
<extends>QSpinBox</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

49
menu3.cpp

@ -0,0 +1,49 @@
#include "menu3.h"
#include "ui_menu3.h"
menu3::menu3(QWidget *parent) :
QWidget(parent),
ui(new Ui::menu3)
{
ui->setupUi(this);
ui->groupBox_2->hide();
ui->radioButton->hide();
ui->radioButton_2->hide();
ui->radioButton_3->hide();
}
menu3::~menu3()
{
delete ui;
}
void menu3::on_checkBox_stateChanged(int arg1)
{
emit signalflip1(ui->checkBox->isChecked());
}
void menu3::on_checkBox_2_stateChanged(int arg1)
{
emit signalflip0(ui->checkBox_2->isChecked());
}
void menu3::on_radioButton_clicked()
{
emit signalcolorgray();
}
void menu3::on_radioButton_2_clicked()
{
emit signalcolorsub();
}
void menu3::on_radioButton_3_clicked()
{
emit signalcolorrgb();
}

43
menu3.h

@ -0,0 +1,43 @@
#ifndef MENU3_H
#define MENU3_H
#include <QWidget>
namespace Ui {
class menu3;
}
class menu3 : public QWidget
{
Q_OBJECT
public:
explicit menu3(QWidget *parent = nullptr);
~menu3();
signals:
void signalflip0(bool);
void signalflip1(bool);
void signalturnl();
void signalturnf();
void signalturnr();
void signalcolorgray();
void signalcolorsub();
void signalcolorrgb();
private slots:
void on_checkBox_stateChanged(int arg1);
void on_checkBox_2_stateChanged(int arg1);
void on_radioButton_clicked();
void on_radioButton_2_clicked();
void on_radioButton_3_clicked();
private:
Ui::menu3 *ui;
};
#endif // MENU3_H

116
menu3.ui

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>menu3</class>
<widget class="QWidget" name="menu3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>640</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>方向控制</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="CheckBox" name="checkBox">
<property name="text">
<string>左右镜像</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="CheckBox" name="checkBox_2">
<property name="text">
<string>上下镜像</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="RadioButton" name="radioButton">
<property name="text">
<string>左转90°</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="RadioButton" name="radioButton_2">
<property name="text">
<string>不变</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="RadioButton" name="radioButton_3">
<property name="text">
<string>右转90°</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>颜色模式</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="RadioButton" name="radioButton_4">
<property name="text">
<string>原色</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="RadioButton" name="radioButton_5">
<property name="text">
<string>反色</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="RadioButton" name="radioButton_6">
<property name="text">
<string>彩色</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>RadioButton</class>
<extends>QRadioButton</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>CheckBox</class>
<extends>QCheckBox</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

68
menu4.cpp

@ -0,0 +1,68 @@
#include "menu4.h"
#include "ui_menu4.h"
#include "qfluentwidgets"
#include <QFileDialog>
menu4::menu4(QWidget *parent) :
QWidget(parent),
ui(new Ui::menu4)
{
ui->setupUi(this);
}
menu4::~menu4()
{
delete ui;
}
void menu4::on_pushButton_clicked()
{
QString dir = QFileDialog::getExistingDirectory(this,QString::fromLocal8Bit("设置存储位置"));
emit signalsetdir(dir);
qDebug()<<dir;
}
void menu4::on_pushButton_2_clicked()
{
emit signalshotimg();
}
void menu4::on_pushButton_3_clicked()
{
emit signalshotbin();
}
void menu4::on_pushButton_4_clicked()
{
emit signalsavevideo(ui->pushButton_4->isChecked());
if(ui->pushButton_4->isChecked()){
ui->pushButton_4->setText(u8"停止");
}
else{
ui->pushButton_4->setText(u8"保存视频");
}
}
void menu4::on_pushButton_5_clicked()
{
emit signalsavebin(ui->pushButton_5->isChecked());
if(ui->pushButton_5->isChecked()){
ui->pushButton_5->setText(u8"停止");
}
else{
ui->pushButton_5->setText(u8"保存连续原始数据");
}
}
void menu4::on_pushButton_6_clicked()
{
emit signalsavesbin(ui->spinBox->value());
}

45
menu4.h

@ -0,0 +1,45 @@
#ifndef MENU4_H
#define MENU4_H
#include <QWidget>
namespace Ui {
class menu4;
}
class menu4 : public QWidget
{
Q_OBJECT
public:
explicit menu4(QWidget *parent = nullptr);
~menu4();
signals:
void signalsetdir(QString);
void signalshotimg();
void signalshotbin();
void signalsavevideo(bool);
void signalsavebin(bool);
void signalsavesbin(int);
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
void on_pushButton_5_clicked();
void on_pushButton_6_clicked();
private:
Ui::menu4 *ui;
};
#endif // MENU4_H

78
menu4.ui

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>menu4</class>
<widget class="QWidget" name="menu4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>640</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="0">
<widget class="SpinBox" name="spinBox"/>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>保存指定帧数数据</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="TogglePushButton" name="pushButton_5">
<property name="text">
<string>保存连续原始数据</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="TogglePushButton" name="pushButton_4">
<property name="text">
<string>保存视频</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>保存单帧原始数据</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>保存单帧图像</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>设置文件保存路径</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TogglePushButton</class>
<extends>QPushButton</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
<customwidget>
<class>SpinBox</class>
<extends>QSpinBox</extends>
<header location="global">qfluentwidgets</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

25
protocol.h

@ -0,0 +1,25 @@
#ifndef PROTOCOL_H
#define PROTOCOL_H
enum IMAGETYPE{
gray8,
gray16
};
#define FrameHead 0xFFFFFFFF
#define LineHead 0xF0000000
#define MINFrameSize 60000
struct headStruct{
int headid;
int frameType;
int rows;
int cols;
int check;
};
#endif // PROTOCOL_H

36
qt5app.rc

@ -0,0 +1,36 @@
IDI_ICON1 ICON "logo.ico"
1 VERSIONINFO
FILEVERSION 1,4,0,0
PRODUCTVERSION 1,4,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "client"
VALUE "CompanyName", "zxrc"
VALUE "FileDescription", "zxrc"
VALUE "FileVersion", "1.4.0.0"
VALUE "InternalName", "zxrc"
VALUE "LegalCopyright", "zxrctech"
VALUE "OriginalFilename", "zxrcClient.exe"
VALUE "ProductName", "zxrcClient"
VALUE "ProductVersion", "1.2.13.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1300
END
END

82
sagauss.cpp

@ -0,0 +1,82 @@
#include "sagauss.h"
sagauss::sagauss(QObject *parent)
: QObject{parent}
{
thread = new QThread();
thread->start();
this->moveToThread(thread);
sigmaN = 0;
ready = false;
}
void sagauss::setpara(int r, double sigma)
{
this->r = r;
this->sigma = sigma;
// ready = true;
}
void sagauss::on()
{
ready = true;
}
void sagauss::off()
{
ready = false;
}
void sagauss::slotprocimg(cv::Mat img)
{
if(ready){
cv::Mat src;
img.convertTo(src,CV_32FC1,4);
cv::Mat gauss;
cv::GaussianBlur(src,gauss,cv::Size(2*r+1,2*r+1),sigma);
cv::Mat res = src-gauss;
cv::Mat sigma1 = cv::abs(res);
cv::Mat sigma2;
cv::GaussianBlur(sigma1,sigma2,cv::Size(2*r+1,2*r+1),sigma);
// cv::Mat sigma2t = sigma2/32;
cv::Mat sigma3(src.rows,src.cols,CV_32FC1);
for(int i = 0;i< src.rows;i++){
for(int j = 0;j<src.cols;j++){
sigma3.at<float>(i,j) = sigma2.at<float>(i,j)*sigma2.at<float>(i,j)/32;
}
}
cv::Mat sigmaU1 = sigma3-sigmaN;
cv::Mat sigmaU2 = cv::abs(sigmaU1)/2+sigmaU1/2;
// cv::Mat sigmaU3 = sigmaU2/(sigma3+0.00001)*res;
cv::Mat sigmaU3(src.rows,src.cols,CV_32FC1);
for(int i = 0;i< src.rows;i++){
for(int j = 0;j<src.cols;j++){
sigmaU3.at<float>(i,j) = sigmaU2.at<float>(i,j)*res.at<float>(i,j)/(sigma3.at<float>(i,j)+0.00001);
}
}
cv::Mat dstt = gauss+sigmaU3;
cv::Mat dst;
dstt.convertTo(dst,CV_16UC1,1/4.0);
emit(signalsendimg(dst));
double max;
cv::minMaxLoc(sigma3,nullptr,&max);
int* hist = (int*)malloc(sizeof(int)*int(max+1));
memset(hist,0,sizeof(int)*int(max+1));
for(int i = 0;i< sigma3.rows;i++){
for(int j = 0;j<sigma3.cols;j++){
hist[int(sigma3.at<float>(i,j))] +=1;
}
}
int max1 = hist[0];
for(int i = 1;i<(max+1);i++){
max1 = hist[i]>max1?hist[i]:max1;
}
free(hist);
sigmaN = (9*sigmaN+2*max1)/10.0;
}
else{
cv::Mat temp;
img.copyTo(temp);
emit(signalsendimg(temp));
}
}

34
sagauss.h

@ -0,0 +1,34 @@
#ifndef SAGAUSS_H
#define SAGAUSS_H
#include <QObject>
#include <QThread>
#include <opencv2/opencv.hpp>
class sagauss : public QObject
{
Q_OBJECT
public:
explicit sagauss(QObject *parent = nullptr);
void setpara(int r, double sigma);
void on();
void off();
public slots:
void slotprocimg(cv::Mat img);
signals:
void signalsendimg(cv::Mat img);
private:
double sigmaN;
int r;
double sigma;
bool ready;
QThread * thread;
};
#endif // SAGAUSS_H

293
twopoint.cpp

@ -0,0 +1,293 @@
#include "twopoint.h"
twoPoint::twoPoint(QObject *parent)
: QObject{parent}
{
thread = new QThread();
thread->start();
this->moveToThread(thread);
ready = false;
b_savelow = false;
b_savehigh = false;
n_savelow = 8;
n_savehigh = 8;
b_onepoint = false;
vardim = 4;
opnum = 0;
c = 0;
bdb = false;
dbrange = 1;
}
void twoPoint::addlow(cv::Mat img, int id)
{
cv::Mat temp;
img.convertTo(temp,CV_32FC1,1.0/32.0);
if(lowtemp.empty()){
// img.copyTo(lowtemp);
// img.convertTo(lowtemp,CV_32FC1);
lowtemp = temp;
// lowtemp = lowtemp/8;
}
if(id == 0){
// img.convertTo(lowtemp,CV_32FC1);
lowtemp = temp;
}
else if(id<32) {
// lowtemp+= img;
lowtemp+= temp;
}
else{
b_savelow = false;
}
}
void twoPoint::addhigh(cv::Mat img, int id)
{
cv::Mat temp;
img.convertTo(temp,CV_32FC1,1.0/32.0);
if(hightemp.empty()){
// img.copyTo(hightemp);
// img.convertTo(hightemp,CV_32FC1);
hightemp = temp;
// lowtemp = lowtemp/8;
}
if(id == 0){
// hightemp = img/32;
// img.convertTo(hightemp,CV_32FC1);
hightemp = temp;
}
else if(id<32) {
// hightemp+= img;
hightemp += temp;
}
else{
b_savehigh = false;
}
}
void twoPoint::onepoint(cv::Mat img)
{
// ready = false;
if(kmat.empty() || bmat.empty()){
return;
}
cv::Mat temp;
img.convertTo(temp,CV_32FC1,1.0/32.0);
if(opnum == 32){
temp.copyTo(bmat);
}
else{
bmat += temp;
}
opnum-=1;
// if(opnum == 0){
// base =
// }
// cv::Mat dst = cv::Mat(img.rows,img.cols,CV_16UC1);
// double sum = 0;
// for(int i =0 ;i< img.rows;i++){
// for (int j = 0;j< img.cols;j++){
// int temp = kmat.at<float>(i,j)*img.at<ushort>(i,j)+bmat.at<float>(i,j);
// if(temp<0) temp = 0;
// if(temp>65535) temp = 65535;
//// dst.at<ushort>(i,j) = temp;
// sum+=temp;
// }
// }
// sum = sum/img.rows/img.cols;
// for(int i =0 ;i< img.rows;i++){
// for (int j = 0;j< img.cols;j++){
// bmat.at<float>(i,j) = sum-kmat.at<float>(i,j)*img.at<ushort>(i,j);
// }
// }
/// k(i,j)*img(i,j)+b(i,j) = out(i,j)
/// b'(i,j) = out^-k(i,j)*img(i,j)
///
// ready = true;
}
void twoPoint::onepoint()
{
b_onepoint = true;
opnum = 32;
}
void twoPoint::calc()
{
if(hightemp.empty() || lowtemp.empty()){
return;
}
kmat = cv::Mat(hightemp.rows,hightemp.cols,CV_32FC1);
bmat = cv::Mat(hightemp.rows,hightemp.cols,CV_32FC1);
// double
high = 0,low = 0;
for(int i = 0;i<hightemp.rows;i++){
for(int j = 0;j< hightemp.cols;j++){
high += hightemp.at<float>(i,j);
low += lowtemp.at<float>(i,j);
}
}
high = high/hightemp.total();
high = 16383*4;
low = low/hightemp.total();
low = 0;
/// (temp(i,j) - b(i,j))*k(i,j)+low = fix(i,j)
/// low(i,j) = b(i,j)
/// (high(i,j) - b(i,j))*k(i,j) = high - low
/// k(i,j) = (high-low)/(high(i,j)-low(i,j))
/// base = low
for(int i = 0;i<hightemp.rows;i++){
for(int j = 0;j<hightemp.cols;j++){
kmat.at<float>(i,j) =(high-low)/(hightemp.at<float>(i,j)-lowtemp.at<float>(i,j));
// bmat.at<float>(i,j) = low - lowtemp.at<ushort>(i,j)*kmat.at<float>(i,j);
bmat.at<float>(i,j) = lowtemp.at<float>(i,j);
}
}
kmean = cv::mean(kmat)[0];
base = low;
ready =true;
}
void twoPoint::savek()
{
if(ready)
cv::imwrite("k.tiff",kmat);
}
void twoPoint::saveb()
{
if(ready)
cv::imwrite("b.tiff",bmat);
}
void twoPoint::savelow()
{
ready = false;
b_savelow = true;
n_savelow = 0;
}
void twoPoint::savehigh()
{
ready = false;
b_savehigh = true;
n_savehigh = 0;
}
void twoPoint::on(cv::Size s)
{
if(kmat.empty()|| bmat.empty())
{
kmat = cv::Mat(s,CV_32FC1);
bmat = cv::Mat(s,CV_32FC1);
for(int i = 0;i<s.height;i++){
for(int j = 0;j<s.width;j++){
kmat.at<float>(i,j) = 1;
bmat.at<float>(i,j) = 0;
}
}
base = 0;
}
ready = true;
}
void twoPoint::off()
{
ready = false;
}
void twoPoint::loaddata()
{
kmat = cv::imread("k.tiff",cv::IMREAD_UNCHANGED);
bmat = cv::imread("b.tiff",cv::IMREAD_UNCHANGED);
if(kmat.empty() || bmat.empty()){
return;
}
ready = true;
}
void twoPoint::setdim(int value)
{
vardim = value;
}
void twoPoint::savedata()
{
c+=1;
cv::imwrite( "high"+QString::number(c).toStdString()+".tiff",hightemp);
cv::imwrite("low"+QString::number(c).toStdString()+".tiff",lowtemp);
}
void twoPoint::dbon()
{
bdb = true;
}
void twoPoint::dboff()
{
bdb = false;
}
void twoPoint::setpara(double range)
{
this->dbrange = range;
}
void twoPoint::slotprocimg(cv::Mat img)
{
img = img/vardim;
img = img*vardim;
if(b_savelow){
addlow(img,n_savelow);
n_savelow+=1;
}
if(b_savehigh){
addhigh(img,n_savehigh);
n_savehigh += 1;
}
if(b_onepoint & (opnum>0)){
onepoint(img);
// b_onepoint = false;
}
if(ready){
cv::Mat dst = cv::Mat(img.rows,img.cols,CV_16UC1);
for(int i =0 ;i< img.rows;i++){
for (int j = 0;j< img.cols;j++){
int temp = kmat.at<float>(i,j)*(img.at<ushort>(i,j)-bmat.at<float>(i,j))+base;
if(temp<low) temp = low;
// if(temp>65535) temp = 65535;
if(temp>high) temp = high;
dst.at<ushort>(i,j) = temp;
}
}
if(bdb){
for(int i =0 ;i< img.rows;i++){
for (int j = 1;j< img.cols;j++){
if((kmat.at<float>(i,j)/kmean-dbrange<1) && (kmat.at<float>(i,j)/kmean+dbrange>1))
continue;
dst.at<ushort>(i,j) = dst.at<ushort>(i,j-1);
}
}
}
emit signalsendimg(dst);
}
else{
cv::Mat temp;
img.copyTo(temp);
emit signalsendimg(temp);
}
}

72
twopoint.h

@ -0,0 +1,72 @@
#ifndef TWOPOINT_H
#define TWOPOINT_H
#include <QObject>
#include <QThread>
#include <opencv2/opencv.hpp>
class twoPoint : public QObject
{
Q_OBJECT
public:
explicit twoPoint(QObject *parent = nullptr);
void addlow(cv::Mat img,int id);
void addhigh(cv::Mat img, int id);
void onepoint(cv::Mat img);
void onepoint();
void calc();
void savek();
void saveb();
void savelow();
void savehigh();
void on(cv::Size s);
void off();
void loaddata();
void setdim(int value);
void savedata();
void dbon();
void dboff();
void setpara(double range);
public slots:
void slotprocimg(cv::Mat);
signals:
void signalsendimg(cv::Mat);
private:
cv::Mat lowtemp;
cv::Mat hightemp;
cv::Mat kmat;
cv::Mat bmat;
bool ready;
QThread* thread;
bool b_savelow;
bool b_savehigh;
int n_savelow;
int n_savehigh;
bool b_onepoint;
int vardim;
double base;
int opnum; //opnum onepoint number
int c;
bool bdb; //bool deblind
double dbrange;
double high ,low , kmean;
};
#endif // TWOPOINT_H

415
usbcontrol.cpp

@ -0,0 +1,415 @@
#include "usbcontrol.h"
#include "QDebug"
#include <QDateTime>
usbcontrol::usbcontrol(QObject* parent):
QObject{parent}
{
device = NULL;
bulkinPoint = NULL;
initEndPoint();
}
int usbcontrol::sendMessage(char *msg, int msglen)
{
if(msglen!=8)
return -1;
else
msg[7]=0;
for(int i = 1;i<7;i++){
msg[7] +=msg[i];
}
if(bulkinPoint==NULL){
initEndPoint();
}
if(bulkinPoint==NULL){
emit signalSendMessage(QString::fromLocal8Bit("未找到设备或端口,请检查硬件"));
return -4;
}
long len = bulkinPoint->MaxPktSize;
memset(buffer,0,len);
int ret = 0;
contexts = bulkinPoint->BeginDataXfer(buffer,len,&inOvLap);
if(!bulkinPoint->WaitForXfer(&inOvLap,1500))
ret = - 1;
if(!bulkinPoint->FinishDataXfer(buffer,len,&inOvLap,contexts))
ret = -2;
if(ret !=0){
device = new CCyUSBDevice(NULL);
int vid,pid;
int d = 0;
int devices = device->DeviceCount();
do{
device->Open(d);
vid = device->VendorID;
pid = device->ProductID;
d++;
}while((d<devices)&&(vid!=0x04b4)&&(pid!=0x00f1));
bulkinPoint =(CCyBulkEndPoint*)device->EndPointOf(0x01);
if(bulkinPoint == NULL){
return -3;
}
}
memcpy(buffer,msg,msglen);
contexts = bulkinPoint->BeginDataXfer(buffer,len,&inOvLap);
if(!bulkinPoint->WaitForXfer(&inOvLap,1500))
return -1;
if(!bulkinPoint->FinishDataXfer(buffer,len,&inOvLap,contexts))
return -2;
return 0;
}
void usbcontrol::initEndPoint()
{
device = new CCyUSBDevice(NULL);
int vid,pid;
int d = 0;
int devices = device->DeviceCount();
do{
device->Open(d);
vid = device->VendorID;
pid = device->ProductID;
d++;
}while((d<devices)&&(vid!=0x04b4)&&(pid!=0x00f1));
bulkinPoint =(CCyBulkEndPoint*)device->EndPointOf(0x01);
if(bulkinPoint == NULL){
return;
}
long len = bulkinPoint->MaxPktSize;
buffer = (unsigned char*)malloc(len);
inOvLap.hEvent = CreateEventW(NULL,false,false,NULL);
}
void usbcontrol::bit14(bool b)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x05;
if(b)
msg[3] = 0x01;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log;
if(b)
log = t.toString()+QString::fromLocal8Bit("设置14bit输出");
else
log = t.toString()+QString::fromLocal8Bit("设置8bit输出");
emit signalSendMessage(log);
}
void usbcontrol::tec(bool b)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x01;
msg[2] = 0x07;
if(b)
msg[3] = 0x01;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString();
if(b)
log = log+QString::fromLocal8Bit("开启TEC");
else
log = log+QString::fromLocal8Bit("关闭TEC");
emit signalSendMessage(log);
}
void usbcontrol::onepoint()
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x03;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("单点校正");
emit signalSendMessage(log);
}
void usbcontrol::savelow()
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x01;
msg[2] = 0x00;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("存低温图像");
emit signalSendMessage(log);
}
void usbcontrol::savehigh()
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x01;
msg[2] = 0x01;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("存高温图像");
emit signalSendMessage(log);
}
void usbcontrol::calck()
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x01;
msg[2] = 0x02;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("计算K");
emit signalSendMessage(log);
}
void usbcontrol::savek()
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x01;
msg[2] = 0x03;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("保存K");
emit signalSendMessage(log);
}
void usbcontrol::openk(bool b)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x01;
if(b)
msg[2] = 0x05;
else
msg[2] = 0x04;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString();
if(b)
log+= QString::fromLocal8Bit("开启K值");
else
log+= QString::fromLocal8Bit("关闭K值");
emit signalSendMessage(log);
}
void usbcontrol::saveb()
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x03;
msg[3]= 0x01;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("存储B");
emit signalSendMessage(log);
}
void usbcontrol::openb(bool b)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x03;
if(b)
msg[3]= 0x02;
else
msg[3] = 0x03;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString();
if(b)
log+= QString::fromLocal8Bit("开启B值");
else
log+= QString::fromLocal8Bit("关闭B值");
emit signalSendMessage(log);
}
void usbcontrol::openbila(bool b)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x04;
if(b)
msg[3] = 0x01;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString();
if(b)
log+=QString::fromLocal8Bit("开启机芯双边滤波");
else
log+= QString::fromLocal8Bit("关闭机芯双边滤波");
emit signalSendMessage(log);
}
void usbcontrol::setDDE(int v)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x0A;
msg[3] = v/256;
msg[4] = v%256;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString();
log+=
QString::fromLocal8Bit("设置DDE系数为")+QString::number(v);
emit signalSendMessage(log);
}
void usbcontrol::setGPOL(int value)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x12;
int v= 16*value;
// int v = ui->spinBox_GPOL->value()*16;
msg[3] = v/256;
msg[4] = v%256;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("设置GPOL为") + QString::number( value) +"mv";
emit signalSendMessage(log);
}
void usbcontrol::setIT(double value)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x10;
int v = value*6250/4;//转换为int型
msg[3] = v/256;
msg[4] = v%256;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()
+QString::fromLocal8Bit("设置积分时间为")+QString::number( value) +"ms";
emit signalSendMessage(log);
}
void usbcontrol::setkf(int v)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x02;
msg[3] = v;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("设置数字滤波系数为")+QString::number(v);
emit signalSendMessage(log);
}
void usbcontrol::sethist(int gray)
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x01;
msg[3] = gray/256;
msg[4] = gray%256;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString()+QString::fromLocal8Bit("设置直方图平台值")+QString::number(gray) ;
emit signalSendMessage(log);
}
void usbcontrol::setsag(bool b )
{
char msg[8] = {0};
msg[0] = 0x44;
msg[1] = 0x02;
msg[2] = 0x14;
if(b)
msg[3] = 0x01;
sendMessage(msg,8);
QDateTime t = QDateTime::currentDateTime();
QString log = t.toString();
if(b)
log+=QString::fromLocal8Bit("开启自适应增强");
else
log += QString::fromLocal8Bit("关闭自适应增强");
emit signalSendMessage(log);
}

63
usbcontrol.h

@ -0,0 +1,63 @@
#ifndef USBCONTROL_H
#define USBCONTROL_H
#include "qt_windows.h"
#include <QObject>
#include <QThread>
#include <QByteArray>
#include <QTimer>
#include <chrono>
#include <CyAPI.h>
#include <QObject>
class usbcontrol:public QObject
{
Q_OBJECT
public:
explicit usbcontrol(QObject *parent = nullptr);
int sendMessage(char* msg, int msglen);
void initEndPoint();
public slots:
void bit14(bool b);
void tec(bool b);
void onepoint();
void savelow();
void savehigh();
void calck();
void savek();
void openk(bool b);
void saveb();
void openb(bool b);
void openbila(bool b);
void setDDE(int v);
void setGPOL(int value);
void setIT(double value);
void setkf(int v);
void sethist(int gray);
void setsag(bool b);
signals:
void signalSendMessage(QString);
private:
CCyUSBDevice *device;
CCyBulkEndPoint* bulkinPoint ;
unsigned char* buffer;
unsigned char* contexts;
OVERLAPPED inOvLap;
};
#endif // USBCONTROL_H

155
usbthread.cpp

@ -0,0 +1,155 @@
#include "usbthread.h"
#include <QDebug>
#include <opencv2/opencv.hpp>
#include <QFile>
#include <chrono>
usbthread::usbthread(QObject *parent):
QThread{parent}
{
qRegisterMetaType<cv::Mat>("cv::Mat");
// qRegisterMetaType<Mat>("Mat");
newProcess = new datathread();
connect(this,SIGNAL(signalAppendData(char*,int)),newProcess,SLOT(appendData(char*,int)));
connect(newProcess,SIGNAL(signalGetImage(cv::Mat )),this,SLOT(slotGetImage(cv::Mat )));
rows = -1;
cols = -1;
usbData =(unsigned char*) malloc(0x10000);
memset(usbData,0,0x10000);
datalen = 0x10000;
isRun = false;
tg = new QTimer();
lensum = 0;
connect(tg,&QTimer::timeout,[=](){
// qDebug()<<"lensum = "<<lensum;
// lensum = 0;
});
tg->start(1000);
}
usbthread::~usbthread()
{
}
void usbthread::SetImageInfo(int _type, int _rows, int _cols)
{
type = _type;
rows = _rows;
cols = _cols;
if(newProcess!=NULL)
newProcess->SetImageInfo(type,rows,cols);
}
void usbthread::stopProcessData()
{
// if(handle){
// libusb_close(handle);
// }
// if(ctx){
// libusb_exit(ctx);
// }
newProcess->setStatu(false);
newProcess->exit();
// newProcess->terminate();
newProcess->wait();
}
void usbthread::setStatu(bool _run)
{
isRun = _run;
}
//void usbClass::setcallback(void (*func)(cv::Mat))
//{
// imageCallback = func;
//}
#define queue 128
#define UPCHAR unsigned char*
void usbthread::run()
{
newProcess->setStatu(true);
newProcess->start();
device = new CCyUSBDevice(NULL);
int vid,pid;
int d = 0;
int devices = device->DeviceCount();
do{
device->Open(d);
vid = device->VendorID;
pid = device->ProductID;
d++;
}while((d<devices)&&(vid!=0x04b4)&&(pid!=0x00f1));
// PUSB_DEVICE_DESCRIPTOR desc;
// device->GetDeviceDescriptor(desc);
// if(desc->bDeviceSubClass == 0x03){
// }
CCyBulkEndPoint* bulkinPoint =(CCyBulkEndPoint*)device->EndPointOf(0x81);
if(bulkinPoint == NULL){
qDebug()<<"no endpoint ";
return;
}
if( device->bSuperSpeed !=true){
signalMessage(QString::fromLocal8Bit("当前usb接口并非usb3.0, 请确认连接"));
newProcess->setStatu(false);
return;
}
unsigned char** buffer = new unsigned char*[128];
unsigned char** contexts = (unsigned char**)malloc(sizeof(unsigned char*)*128);
OVERLAPPED inOvLap[128];
long len = bulkinPoint->MaxPktSize;
for(int i = 0;i<128;i++){
buffer[i] = (unsigned char*)malloc(len);
inOvLap[i].hEvent = CreateEventW(NULL,false,false,NULL);
contexts[i] = bulkinPoint->BeginDataXfer(buffer[i],len,&inOvLap[i]);
}
int i =0;
while(isRun){
long rlen = len;
if(!bulkinPoint->WaitForXfer(&inOvLap[i],1500)){
}
if(bulkinPoint->FinishDataXfer(buffer[i],rlen,&inOvLap[i],contexts[i])){
emit(signalAppendData((char*)buffer[i],rlen));
}
contexts[i] = bulkinPoint->BeginDataXfer(buffer[i],len,&inOvLap[i]);
i++;
if(i==queue){
i = 0;
}
}
}
void usbthread::logout()
{
}
void usbthread::slotGetImage(Mat image)
{
emit signalGetImage(image);
}

66
usbthread.h

@ -0,0 +1,66 @@
#ifndef USBTHREAD_H
#define USBTHREAD_H
//#include "Windows.h"
#include "qt_windows.h"
#include <QObject>
#include <QThread>
#include <QByteArray>
#include <QTimer>
#include <chrono>
#include "datathread.h"
#include <CyAPI.h>
#include <opencv2/opencv.hpp>
using namespace cv;
class usbthread:public QThread{
Q_OBJECT
public:
explicit usbthread(QObject* parent = nullptr);
~usbthread();
void SetImageInfo(int _type, int _rows, int _cols);
void stopProcessData();
void setStatu(bool _run);
// void setcallback(void(*func)(cv::Mat));
signals:
void signalGetImage(cv::Mat);
void signalMessage(QString msg);
void signalSetImageInfo(int type, int rows, int cols);
void signalAppendData(char* data,int len);
protected:
void run()override;
protected slots:
void logout();
void slotGetImage(cv::Mat );
private:
datathread* newProcess;
unsigned char* usbData;
int datalen;
int type;
int rows;
int cols;
bool isRun;
CCyUSBDevice *device;
// void(*imageCallback)(cv::Mat image);
QTimer* tg;
int lensum;
};
#endif // USBTHREAD_H
Loading…
Cancel
Save