commit 8ccab171db5ef40c10dabbc99e4df5bc0282b6db Author: Chenglei98 <44131164+Chenglei98@users.noreply.github.com> Date: Sat Sep 17 10:52:03 2022 +0800 Add files via upload 淮安部署版本 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f3e296 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.o +saved_image +.qmake.stash +doc +log diff --git a/.qmake.stash b/.qmake.stash new file mode 100644 index 0000000..e1d04e4 --- /dev/null +++ b/.qmake.stash @@ -0,0 +1,24 @@ +QMAKE_CXX.INCDIRS = \ + /usr/include/c++/7 \ + /usr/include/x86_64-linux-gnu/c++/7 \ + /usr/include/c++/7/backward \ + /usr/lib/gcc/x86_64-linux-gnu/7/include \ + /usr/local/include \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed \ + /usr/include/x86_64-linux-gnu \ + /usr/include +QMAKE_CXX.LIBDIRS = \ + /usr/lib/gcc/x86_64-linux-gnu/7 \ + /usr/lib/x86_64-linux-gnu \ + /usr/lib \ + /lib/x86_64-linux-gnu \ + /lib +QMAKE_CXX.QT_COMPILER_STDCXX = 201402L +QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 +QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 5 +QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_GCC_MAJOR_VERSION \ + QMAKE_GCC_MINOR_VERSION \ + QMAKE_GCC_PATCH_VERSION diff --git a/123.txt b/123.txt new file mode 100644 index 0000000..c2d5175 --- /dev/null +++ b/123.txt @@ -0,0 +1,30 @@ +connect plc success +>>> connect to monitor successfully! >>> +>>> load system parameter successfully! >>> + welcome dk ! + Display ID: SF3000-GE04K-10C-00 00:26:ac:a1:00:9d [192.168.15.105] + Display ID: FX10e 70:f8:e7:b0:07:c4 [169.254.128.27] +set ip success +*** Unable to connect to FX10e 70:f8:e7:b0:07:c4 [169.254.128.27] +*** init camera error, error code: -1 *** +>>> try to init camera again... >>> + Display ID: SF3000-GE04K-10C-00 00:26:ac:a1:00:9d [192.168.15.105] + Display ID: FX10e 70:f8:e7:b0:07:c4 [192.168.123.3] +set ip success +>>> Successfully connected to FX10e 70:f8:e7:b0:07:c4 [192.168.123.3] + +>>> load calibration init success! >>> +>>> Connecting to SF3000-GE04K-10C-00 00:26:ac:a1:00:9d [192.168.15.105] +>>> Successfully connected to SF3000-GE04K-10C-00 00:26:ac:a1:00:9d [192.168.15.105] + +>>> init camera successfully + hello dk ! +>>> spec threshold 4 send to python +>>> rgb threshold 6 send to python +new connection to lower machine! +receive message from suhandong +start +queue buffer successfully... +running on 0 +queue buffer successfully... +>>> start acquisition >>> diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..97481f2 --- /dev/null +++ b/Makefile @@ -0,0 +1,863 @@ +############################################################################# +# Makefile for building: tobacco_v1_0 +# Generated by qmake (3.1) (Qt 5.9.5) +# Project: tobacco_v1_0.pro +# Template: app +# Command: /usr/lib/qt5/bin/qmake -o Makefile tobacco_v1_0.pro +############################################################################# + +MAKEFILE = Makefile + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB +CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES) +CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES) +INCPATH = -I. -I/opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include -isystem /usr/include/opencv2 -I/home/dt/下载/libmodbus-3.1.6/install/include/modbus -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ +QMAKE = /usr/lib/qt5/bin/qmake +DEL_FILE = rm -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p +COPY = cp -f +COPY_FILE = cp -f +COPY_DIR = cp -f -R +INSTALL_FILE = install -m 644 -p +INSTALL_PROGRAM = install -m 755 -p +INSTALL_DIR = cp -f -R +QINSTALL = /usr/lib/qt5/bin/qmake -install qinstall +QINSTALL_PROGRAM = /usr/lib/qt5/bin/qmake -install qinstall -exe +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +TAR = tar -cf +COMPRESS = gzip -9f +DISTNAME = tobacco_v1_01.0.0 +DISTDIR = /home/dt/tobacco_huaian/aaaaa/2022.8.21/2022.8.20/tobacco_v1_0/.tmp/tobacco_v1_01.0.0 +LINK = g++ +LFLAGS = -Wl,-O1 +LIBS = $(SUBLIBS) -L/opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/lib/ -lEbTransportLayerLib -lPtUtilsLib -lPvBase -lPvCameraBridge -lPvGenICam -lPvPersistence -lPvStream -lPvTransmitter -lSimpleImagingLib -lEbUtilsLib -lPtConvertersLib -lPvAppUtils -lPvBuffer -lPvDevice -lPvGUI -lPvSerial -lPvSystem -lPvVirtualDevice -L/usr/lib/x86_64-linux-gnu/ -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lmodbus -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Core -lGL -lpthread +AR = ar cqs +RANLIB = +SED = sed +STRIP = strip + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + widget.cpp \ + camera.cpp \ + thread.cpp \ + parameter.cpp moc_widget.cpp \ + moc_camera.cpp \ + moc_thread.cpp +OBJECTS = main.o \ + widget.o \ + camera.o \ + thread.o \ + parameter.o \ + moc_widget.o \ + moc_camera.o \ + moc_thread.o +DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/sanitize.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/qconfig.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_accessibility_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_egl_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfsdeviceintegration_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_fb_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_fontdatabase_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_glx_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_input_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_kms_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_linuxaccessibility_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_service_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_theme_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_functions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf \ + .qmake.stash \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/toolchain.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resolve_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_post.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/warn_on.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resources.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/moc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/opengl.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/uic.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/thread.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qmake_use.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/file_copies.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/testcase_targets.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exceptions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf \ + tobacco_v1_0.pro widget.h \ + camera.h \ + thread.h \ + parameter.h main.cpp \ + widget.cpp \ + camera.cpp \ + thread.cpp \ + parameter.cpp +QMAKE_TARGET = tobacco_v1_0 +DESTDIR = +TARGET = tobacco_v1_0 + + +first: all +####### Build rules + +$(TARGET): ui_widget.h $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: tobacco_v1_0.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/sanitize.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/qconfig.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_accessibility_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_egl_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfsdeviceintegration_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_fb_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_fontdatabase_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_glx_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_input_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_kms_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_linuxaccessibility_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_service_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_theme_support_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_functions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf \ + .qmake.stash \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/toolchain.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resolve_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_post.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/warn_on.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resources.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/moc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/opengl.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/uic.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/thread.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qmake_use.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/file_copies.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/testcase_targets.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exceptions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf \ + tobacco_v1_0.pro \ + /usr/lib/x86_64-linux-gnu/libQt5Widgets.prl \ + /usr/lib/x86_64-linux-gnu/libQt5Gui.prl \ + /usr/lib/x86_64-linux-gnu/libQt5Network.prl \ + /usr/lib/x86_64-linux-gnu/libQt5Core.prl + $(QMAKE) -o Makefile tobacco_v1_0.pro +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/sanitize.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base-unix.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-base.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-unix.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/qconfig.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_accessibility_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_egl_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfsdeviceintegration_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_fb_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_fontdatabase_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_glx_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_input_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_kms_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_linuxaccessibility_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_service_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_theme_support_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_functions.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf: +.qmake.stash: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/toolchain.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resolve_config.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_post.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/warn_on.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resources.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/moc.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/opengl.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/uic.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/thread.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qmake_use.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/file_copies.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/testcase_targets.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exceptions.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf: +tobacco_v1_0.pro: +/usr/lib/x86_64-linux-gnu/libQt5Widgets.prl: +/usr/lib/x86_64-linux-gnu/libQt5Gui.prl: +/usr/lib/x86_64-linux-gnu/libQt5Network.prl: +/usr/lib/x86_64-linux-gnu/libQt5Core.prl: +qmake: FORCE + @$(QMAKE) -o Makefile tobacco_v1_0.pro + +qmake_all: FORCE + + +all: Makefile $(TARGET) + +dist: distdir FORCE + (cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar) && $(MOVE) `dirname $(DISTDIR)`/$(DISTNAME).tar.gz . && $(DEL_FILE) -r $(DISTDIR) + +distdir: FORCE + @test -d $(DISTDIR) || mkdir -p $(DISTDIR) + $(COPY_FILE) --parents $(DIST) $(DISTDIR)/ + $(COPY_FILE) --parents /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp $(DISTDIR)/ + $(COPY_FILE) --parents widget.h camera.h thread.h parameter.h $(DISTDIR)/ + $(COPY_FILE) --parents main.cpp widget.cpp camera.cpp thread.cpp parameter.cpp $(DISTDIR)/ + $(COPY_FILE) --parents widget.ui $(DISTDIR)/ + + +clean: compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) .qmake.stash + -$(DEL_FILE) Makefile + + +####### Sub-libraries + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +check: first + +benchmark: first + +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_moc_predefs_make_all: moc_predefs.h +compiler_moc_predefs_clean: + -$(DEL_FILE) moc_predefs.h +moc_predefs.h: /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp + g++ -pipe -O2 -Wall -W -dM -E -o moc_predefs.h /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp + +compiler_moc_header_make_all: moc_widget.cpp moc_camera.cpp moc_thread.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_widget.cpp moc_camera.cpp moc_thread.cpp +moc_widget.cpp: thread.h \ + camera.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h \ + parameter.h \ + widget.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -I/home/dt/tobacco_huaian/aaaaa/2022.8.21/2022.8.20/tobacco_v1_0 -I/opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include -I/usr/include/opencv2 -I/home/dt/下载/libmodbus-3.1.6/install/include/modbus -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include widget.h -o moc_widget.cpp + +moc_camera.cpp: /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h \ + camera.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -I/home/dt/tobacco_huaian/aaaaa/2022.8.21/2022.8.20/tobacco_v1_0 -I/opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include -I/usr/include/opencv2 -I/home/dt/下载/libmodbus-3.1.6/install/include/modbus -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include camera.h -o moc_camera.cpp + +moc_thread.cpp: camera.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h \ + thread.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -I/home/dt/tobacco_huaian/aaaaa/2022.8.21/2022.8.20/tobacco_v1_0 -I/opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include -I/usr/include/opencv2 -I/home/dt/下载/libmodbus-3.1.6/install/include/modbus -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include thread.h -o moc_thread.cpp + +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: ui_widget.h +compiler_uic_clean: + -$(DEL_FILE) ui_widget.h +ui_widget.h: widget.ui \ + /usr/lib/qt5/bin/uic + /usr/lib/qt5/bin/uic widget.ui -o ui_widget.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_predefs_clean compiler_moc_header_clean compiler_uic_clean + +####### Compile + +main.o: main.cpp widget.h \ + thread.h \ + camera.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h \ + parameter.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +widget.o: widget.cpp widget.h \ + thread.h \ + camera.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h \ + parameter.h \ + ui_widget.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o widget.o widget.cpp + +camera.o: camera.cpp camera.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o camera.o camera.cpp + +thread.o: thread.cpp thread.h \ + camera.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o thread.o thread.cpp + +parameter.o: parameter.cpp parameter.h \ + camera.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDevice.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvLinkLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvResult.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBaseLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfo.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterArray.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenICamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenString.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenParameterList.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenTypes.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenApi.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenInteger.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnum.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenEnumEntry.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenFloat.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCommand.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenBoolean.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenRegister.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvGenCategory.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEnums.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStream.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBuffer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvBufferLib.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPayloadType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImage.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvPixelType.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartContainer.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvMultiPartSection.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvChunkData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvImageJPEG.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvRawData.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvH264AccessUnit.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvStreamGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystem.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvSystemEventSink.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvNetworkAdapter.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvInterface.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoGEV.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoPleoraProtocol.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvUSBHostController.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoUSB.h \ + /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include/PvDeviceInfoU3V.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o parameter.o parameter.cpp + +moc_widget.o: moc_widget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_widget.o moc_widget.cpp + +moc_camera.o: moc_camera.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_camera.o moc_camera.cpp + +moc_thread.o: moc_thread.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_thread.o moc_thread.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/black b/black new file mode 100644 index 0000000..29faf47 Binary files /dev/null and b/black differ diff --git a/camera.cpp b/camera.cpp new file mode 100644 index 0000000..49acc0a --- /dev/null +++ b/camera.cpp @@ -0,0 +1,1173 @@ +/** + * @file camera.cpp + * @author DingKun & ChengLei + * @date 2022.3.8 + * @brief The file contains detailed implementation of class Camera + * @details + *
The file contains detailed implementation of class Camera.
+ * Such as initialize camera, enum camera, start capture, callback function, etc.
+ * which refers to the hyperspectral camera(FX10e).
+ */ + +#include "camera.h" +#include "unistd.h" + +float file_explosure; +vector mroi; +vector valid; +int R; +int G; +int B; + +Camera* camera; +RGB_Camera* rgb_camera; + +float* send_buf = nullptr; +float* send_temp_buf = nullptr; +float* send_valid_buf = nullptr; + +float* save_valid_buf = nullptr; + +QSemaphore ready_to_send(0); //光谱图像信号量 +QSemaphore ready_to_send_rgb(0); //rgb图像信号量 + +uint8_t* send_rgb_buf = nullptr; +//uint8_t* send_temp_rgb_buf = nullptr; + +uint8_t* channel_b = nullptr; +uint8_t* channel_g = nullptr; +uint8_t* channel_r = nullptr; +uint8_t* temp_rgb = nullptr; + +uint16_t* lines_buf = nullptr; + + +std::vector channel_rgb; + +/*test for callback function, not used +int on_data_callback(uint8_t* buffer, uint64_t frame_size, uint64_t frame_number) +{ + cout << ">>> frame_number: " << frame_number << " " << "frame_size: " << frame_size << endl; + cv::Mat mat(1000, 3840, CV_8UC1, buffer); + //cv::imwrite("./a.png", mat); + return 0; +} +*/ + +Camera::Camera(QObject *parent) : QObject(parent) +{ +} + +Camera::~Camera() +{ + free_stream_buffers(); + + if( lStream != nullptr ) + { + lStream->Close(); + PvStream::Free(lStream); + cout << ">>> close and free lstream >>>" << endl; + } + + if( lDevice != nullptr ) + { + lDevice->Disconnect(); + PvDevice::Free(lDevice); + cout << ">>> disconnect and free camera device >>>" << endl; + } + + if( capture_thread != nullptr) + delete capture_thread; + + delete [] send_buf; + delete [] send_temp_buf; + + delete [] white_buf; + delete [] black_buf; + + cout << "dkkkkkkkkkkkkkkk" << endl; +} + +/** + * @details
Steps to initialize the hyperspectral camera:
+ * 1. Enumerate and connect to the camera
+ * 2. Configure the camera parameters
+ * 3. Creates stream object
+ * 4. Configure stream for GigE Vision devices
+ * 5. Create stream buffers
+ * 6. Map the GenICam AcquisitionStart and AcquisitionStop commands
+ * 7. New object capture_thread
+ * 8. Allocate memory for every buffers
+ */
+int Camera::init_camera()
+{
+    // 1.Enumerate the camera
+    int status = enum_connect_camera();
+    if(status != 0)
+        return -1;
+
+    // 2.Configure the camera parameters
+    status = config_camera();
+    if(status != 0)
+        return -2;
+
+//    get_camera_parameters();
+
+    // 3.Creates stream object
+    status = open_stream();
+    if(status != 0)
+        return -3;
+
+    // 4.Configure stream for GigE Vision devices
+    status = configure_stream();
+    if(status != 0)
+        return -4;
+
+    // 5.Create stream buffers
+    create_stream_buffers();
+
+    // Get device parameters need to control streaming
+    PvGenParameterArray *lDeviceParams = lDevice->GetParameters();
+
+    // 6.Map the GenICam AcquisitionStart and AcquisitionStop commands
+    lStart = dynamic_cast( lDeviceParams->Get( "AcquisitionStart" ) );
+    lStop = dynamic_cast( lDeviceParams->Get( "AcquisitionStop" ) );
+
+    // 7.New object capture_thread
+    capture_thread = new CaptureThread();
+
+    //获取波段数
+    PvGenInteger* lheight = parameter_array->GetInteger("Height");
+
+    lheight->GetValue(m_height);
+
+    single_frame_size = SPEC_WIDTH * m_height;
+    multi_frame_size = single_frame_size * SPEC_HEIGHT;
+
+    // 8.Allocate memory for every buffers
+    white_buf = new float[single_frame_size];
+    black_buf = new float[single_frame_size];
+
+    send_buf = new float[multi_frame_size];
+    send_temp_buf = new float[multi_frame_size];
+    send_valid_buf = new float[SPEC_WIDTH * valid.size() * SPEC_HEIGHT];   //此处m_height要改成valid
+
+    sum_mat_for_calibration = cv::Mat(m_height, SPEC_WIDTH, CV_32F, cv::Scalar(0));
+    eps = cv::Mat(m_height, SPEC_WIDTH, CV_32F, cv::Scalar(0.00000001));   ///GetDeviceCount();
+
+        for ( uint32_t y = 0; y < lDeviceCount ; y++ )
+        {
+            lDeviceInfo = lSystem.GetInterface(x)->GetDeviceInfo( y );
+
+            cout << "    Display ID: " << lDeviceInfo->GetDisplayID().GetAscii() << endl;
+
+            const PvDeviceInfoGEV* lDeviceInfoGEV = dynamic_cast( lDeviceInfo );
+
+            if ( lDeviceInfoGEV != nullptr ) // Is it a GigE Vision device?
+            {
+//                cout << "    MAC Address: " << lDeviceInfoGEV->GetMACAddress().GetAscii() << endl;
+//                cout << "    IP Address: " << lDeviceInfoGEV->GetIPAddress().GetAscii() << endl;
+//                cout << "    Serial number: " << lDeviceInfoGEV->GetSerialNumber().GetAscii() << endl << endl;
+                if(!strcmp("70:f8:e7:b0:07:c4", lDeviceInfoGEV->GetMACAddress().GetAscii()))
+                {
+                    lResult = PvDeviceGEV::SetIPConfiguration("70:f8:e7:b0:07:c4", "192.168.123.3", "255.255.255.0", "192.168.123.1");
+                    while( !lResult.IsOK() ){
+//                        cout << "set ip again" << endl;
+                        lResult = PvDeviceGEV::SetIPConfiguration("70:f8:e7:b0:07:c4", "192.168.123.3", "255.255.255.0", "192.168.123.1");
+                    }
+                    cout << "set ip success" << endl;
+
+                    lDeviceInfo = lSystem.GetInterface(x)->GetDeviceInfo(y);
+                    lLastDeviceInfo = lDeviceInfo;
+                    break;
+                }
+                else
+                {
+//                    cout << "not this!" << endl;
+                    continue;
+                }
+            }    
+        }
+    }
+
+    // Connect to the last device found
+    if ( lLastDeviceInfo != nullptr )
+    {
+        // Creates and connects the device controller based on the selected device.
+        lDevice = PvDevice::CreateAndConnect( lLastDeviceInfo, &lResult );
+        if ( !lResult.IsOK() )
+        {
+            cout << "*** Unable to connect to " << lLastDeviceInfo->GetDisplayID().GetAscii() << endl;
+            if(lDevice != nullptr){
+                PvDevice::Free(lDevice);
+                lDevice = nullptr;
+            }
+            lLastDeviceInfo = nullptr;
+            return -1;
+        }
+        else
+        {
+            cout << ">>> Successfully connected to " << lLastDeviceInfo->GetDisplayID().GetAscii() << endl;
+            cout << endl;
+            // Load parameters of the camera
+            parameter_array = lDevice->GetParameters();
+
+            return 0;
+        }
+    }
+    else
+    {
+        cout << "*** No device found! ***" << endl;
+        return -2;
+    }
+}
+
+int Camera::open_stream()
+{
+    PvResult lResult;
+    // Open stream to the GigE Vision or USB3 Vision device
+//    cout << ">>> Opening stream to device." << endl;
+    lStream = PvStream::CreateAndOpen( lLastDeviceInfo->GetConnectionID(), &lResult);
+    if ( (lStream == nullptr) || !lResult.IsOK() )
+    {
+        cout << "*** Unable to stream from " << lLastDeviceInfo->GetDisplayID().GetAscii() << ". ***" << endl;
+        PvStream::Free(lStream);
+        PvDevice::Free(lDevice);
+        return -1;
+    }
+    return 0;
+}
+
+int Camera::configure_stream()
+{
+    // If this is a GigE Vision device, configure GigE Vision specific streaming parameters
+    PvDeviceGEV* lDeviceGEV = dynamic_cast( lDevice );
+    if ( lDeviceGEV != nullptr )
+    {
+        PvStreamGEV *lStreamGEV = static_cast( lStream );
+        // Negotiate packet size
+        lDeviceGEV->NegotiatePacketSize();
+        // Configure device streaming destination
+        lDeviceGEV->SetStreamDestination( lStreamGEV->GetLocalIPAddress(), lStreamGEV->GetLocalPort() );
+//        cout << ">>> configure stream successfully!" << endl;
+        return 0;
+    }
+    else
+    {
+        cout << "*** configure stream failed! ***" << endl;
+        return -1;
+    }
+}
+
+void Camera::create_stream_buffers()
+{
+    // Reading payload size from device
+    uint32_t lSize = lDevice->GetPayloadSize();
+
+    // Use BUFFER_COUNT or the maximum number of buffers, whichever is smaller
+    uint32_t lBufferCount = ( lStream->GetQueuedBufferMaximum() < BUFFER_COUNT ) ? lStream->GetQueuedBufferMaximum() : BUFFER_COUNT;
+    // Allocate buffers
+    for( uint32_t i=0; iAlloc( static_cast( lSize ) );
+
+        // Add to external list - used to eventually release the buffers
+        lbufferlist.push_back(lBuffer);
+    }
+//    cout << ">>> create stream buffers successfully" << endl;
+}
+
+void Camera::free_stream_buffers()
+{
+    bufferlist::iterator iter = lbufferlist.begin();
+    while( iter != lbufferlist.end() )
+    {
+        delete *iter;
+        iter++;
+    }
+    // Clear the buffer list
+    lbufferlist.clear();
+}
+
+
+void Camera::set_MROI(const vector &vec)
+{
+    bool mroi_status = false;
+    parameter_array->SetBooleanValue("MROI_Enable", mroi_status);
+
+    int n = vec.size() / 2;
+
+    parameter_array->SetIntegerValue("MROI_Index", n);
+    parameter_array->SetIntegerValue("MROI_Y", 1081);
+    parameter_array->SetIntegerValue("MROI_H", 0);
+
+    //{100, 5, 300, 5}
+    for( int i=0, j=0; iSetIntegerValue("MROI_Index", i);
+        parameter_array->SetIntegerValue("MROI_Y", vec[j]);
+        parameter_array->SetIntegerValue("MROI_H", vec[j+1]);
+    }
+
+
+    mroi_status = true;
+    parameter_array->SetBooleanValue("MROI_Enable", mroi_status);
+
+}
+
+int Camera::config_camera()
+{
+    PvResult lResult;
+    //实际测试发现,快men有时无法自动打开,需要使用以下代码人为打开
+    lResult = parameter_array->SetIntegerValue("MotorShutter_PulseFwd", 100);
+    ::sleep(1);
+    lResult = parameter_array->SetIntegerValue("MotorShutter_PulseRev", 100);
+    ::sleep(1);
+    lResult = parameter_array->SetIntegerValue("MotorShutter_PulseFwd", 200);
+    ::sleep(1);
+    lResult = parameter_array->SetIntegerValue("MotorShutter_PulseRev", 200);
+
+    //设置触发模式为 外触发,线路Line0,上升沿触发
+    lResult = parameter_array->SetEnumValue("TriggerMode", "On");
+    lResult = parameter_array->SetEnumValue("TriggerSource", "Line0");
+
+
+    //Set BinningVertical
+    lResult = parameter_array->SetIntegerValue("BinningVertical", 1);
+    if ( !lResult.IsOK() )
+    {
+        cout << "*** Unable to set  *** " << endl;
+        return -1;
+    }
+
+    //设置数据格式为12位
+    lResult = parameter_array->SetEnumValue("PixelFormat", "Mono12");
+    if ( !lResult.IsOK() )
+    {
+        cout << "*** Unable to set  *** " << endl;
+        return -1;
+    }
+
+    //Set gain
+    lResult = parameter_array->SetFloatValue("Gain", m_gain);
+    if ( !lResult.IsOK() )
+    {
+        cout << "*** Unable to set  *** " << endl;
+        return -1;
+    }
+
+    //Set MROI
+    set_MROI(mroi);
+
+    //Set ExposureTime
+    lResult = parameter_array->SetFloatValue("ExposureTime", file_explosure);
+    if ( !lResult.IsOK() )
+    {
+        cout << "*** Unable to set  *** " << endl;
+        return -1;
+    }
+    return 0;
+}
+
+
+void Camera::get_camera_parameters()
+{
+    PvResult lResult;
+
+    //Get BinningVertical
+    PvGenInteger* lbinningvertical = parameter_array->GetInteger("BinningVertical");
+    int64_t binning = 0;
+    lResult = lbinningvertical->GetValue(binning);
+    if( !lResult.IsOK() )
+        cout << "*** Unable to get  *** " << endl;
+    else
+        cout <<">>> BinningVertical: " << binning << endl;
+
+    //Get Gain
+    PvGenFloat* lgain = parameter_array->GetFloat("Gain");
+    double gain = 0.0f;
+    lResult = lgain->GetValue(gain);
+    if( !lResult.IsOK() )
+        cout << "*** Unable to get  *** " << endl;
+    else
+        cout <<">>> Gain: " << gain << endl;
+
+    //Get Height
+    PvGenInteger* lheight = parameter_array->GetInteger("Height");
+    int64_t height = 0;
+    lResult = lheight->GetValue(height);
+    if( !lResult.IsOK() )
+        cout << "*** Unable to get  *** " << endl;
+    else
+        cout <<">>> Height: " << height << endl;
+
+    //Get Width
+    PvGenInteger* lwidth = parameter_array->GetInteger("Width");
+    int64_t width = 0;
+    lResult = lwidth->GetValue(width);
+    if( !lResult.IsOK() )
+        cout << "*** Unable to get  *** " << endl;
+    else
+        cout <<">>> Width: " << width << endl;
+
+    //Get AcquisitionFrameRate
+    PvGenFloat* lframerate = parameter_array->GetFloat("AcquisitionFrameRate");
+    double framerate = 0.0f;
+    lResult = lframerate->GetValue(framerate);
+    if( !lResult.IsOK() )
+        cout << "*** Unable to get  *** " << endl;
+    else
+        cout <<">>> AcquisitionFrameRate: " << framerate << endl;
+
+    //Get ExposureTime
+    PvGenFloat* lexposuretime = parameter_array->GetFloat("ExposureTime");
+    double exposuretime = 0.0f;
+    lResult = lexposuretime->GetValue(exposuretime);
+    if( !lResult.IsOK() )
+        cout << "*** Unable to get  *** " << endl;
+    else
+        cout << ">>> ExposureTime: " << exposuretime << endl;
+
+    //查看触发模式
+    PvString mode;
+    PvGenEnum* ltriggermode = parameter_array->GetEnum("TriggerMode");
+    ltriggermode->GetValue(mode);
+    cout << ">>> TriggerMode: " << mode.GetAscii() << endl;
+    ltriggermode = parameter_array->GetEnum("TriggerSource");
+    ltriggermode->GetValue(mode);
+    cout << ">>> TriggerSource: " << mode.GetAscii() << endl;
+    cout << endl;
+}
+
+void Camera::start_acquisition()
+{
+    // Queue all buffers in the stream
+    bufferlist::iterator iter = lbufferlist.begin();
+    while( iter != lbufferlist.end() )
+    {
+        lStream->QueueBuffer(*iter);
+        iter++;
+    }
+    cout << "queue buffer successfully..." << endl;
+
+    // Enable streaming and send the AcquisitionStart command
+//    cout << "Enabling streaming and sending AcquisitionStart command." << endl;
+    lDevice->StreamEnable();
+    lStart->Execute();
+
+    // start a new thread CaptureThread
+    capture_thread->stop_mutex.lock();
+    capture_thread->m_stop = false;
+    capture_thread->stop_mutex.unlock();
+    capture_thread->start();
+}
+
+void Camera::stop_acquisition()
+{
+    //线程停止!
+    capture_thread->exit_thread();
+    capture_thread->wait();
+    if(capture_thread->isFinished())
+    {
+        cout << ">>> capture thread stopped successfully" << endl;
+    }
+}
+
+ void Camera::register_callback_calibration()
+ {
+     register_data_callback(onDataCallback_calibration);
+ }
+
+ void Camera::register_callback_acquisition()
+ {
+     register_data_callback(onDataCallback_acquisition);
+ }
+
+ int Camera::init_calibration_load()
+ {
+     FILE* fp = fopen("./white", "rb");
+     fread(white_buf, 4, single_frame_size, fp);
+     fclose(fp);
+     fp = fopen("./black", "rb");
+     fread(black_buf, 4, single_frame_size, fp);
+     fclose(fp);
+     white_mat = cv::Mat(m_height, SPEC_WIDTH, CV_32F, white_buf);
+     black_mat = cv::Mat(m_height, SPEC_WIDTH, CV_32F, black_buf);
+
+     cout << ">>> load calibration init success! >>> " << endl;
+//     emit camera->send_calibration_finished_message();
+     return 0;
+ }
+
+ void Camera::load_calibration()
+ {
+     cout << ">>> loading calibration file......" << endl;
+     FILE* fp = fopen("./white", "rb");
+     fread(white_buf, 4, single_frame_size, fp);
+     fclose(fp);
+     cout << ">>> white file loaded successfully! >>>" << endl;
+
+     fp = fopen("./black", "rb");
+     fread(black_buf, 4, single_frame_size, fp);
+     fclose(fp);
+     cout << ">>> black file loaded successfully! >>>" << endl;
+
+     white_mat = cv::Mat(m_height, SPEC_WIDTH, CV_32F, white_buf);
+     black_mat = cv::Mat(m_height, SPEC_WIDTH, CV_32F, black_buf);
+
+     cout << ">>> load calibration finished! >>> " << endl;
+     emit camera->send_calibration_finished_message();
+ }
+
+
+//definition of calibration callback function 校正回调函数
+static uint16_t calibration_frame_count = 0;
+int onDataCallback_calibration(uint8_t *buffer, uint64_t frame_size, uint64_t frame_number)
+{
+    //采集黑白帧
+    cout << ">>> acquisition number: " << calibration_frame_count << endl;
+    if( camera->capture_black_flag || camera->capture_white_flag )
+    {
+        if( calibration_frame_count != CALIBRATION_FRAMES )
+        {
+            cv::Mat temp = cv::Mat(camera->m_height, SPEC_WIDTH, CV_16U, buffer);
+            temp.convertTo(temp, CV_32F);
+            camera->sum_mat_for_calibration += temp;
+            calibration_frame_count++;
+            return 0;
+        }
+        else
+        {
+            camera->stop_acquisition();
+            if( camera->capture_black_flag )
+            {
+                camera->capture_black_flag = false;
+                camera->black_mat = camera->sum_mat_for_calibration / CALIBRATION_FRAMES;
+                FILE* fp = fopen("./black", "wb");
+                fwrite(camera->black_mat.data, camera->m_height*SPEC_WIDTH*4, 1, fp);
+                fclose(fp);
+                cout << ">>> black frame acquisition OK! >>>" << endl;
+                camera->sum_mat_for_calibration = cv::Mat(camera->m_height, SPEC_WIDTH, CV_32F, cv::Scalar(0));  //clear sum mat
+            }
+            else if( camera->capture_white_flag )
+            {
+                camera->capture_white_flag = false;
+                camera->white_mat = camera->sum_mat_for_calibration / CALIBRATION_FRAMES;
+                FILE* fp = fopen("./white", "wb");
+                fwrite(camera->white_mat.data, camera->m_height*SPEC_WIDTH*4, 1, fp);
+                fclose(fp);
+                cout << ">>> white frame acquisition OK! >>>" << endl;
+                camera->sum_mat_for_calibration = cv::Mat(camera->m_height, SPEC_WIDTH, CV_32F, cv::Scalar(0));  //clear sum mat
+            }
+            calibration_frame_count = 0;
+            camera->unregister_data_callback();
+            return 0;
+        }
+    }
+    return 0;
+}
+
+//definition of acquisition callback function 采集回调函数
+static uint16_t send_show_frame_count = 0;
+/**
+ * @brief Acquisition callback function
+ * @param buffer
+ * @param frame_size
+ * @param frame_number
+ * @return
+ * @details splice 256 buffers into a whole image,
+ */
+int onDataCallback_acquisition(uint8_t *buffer, uint64_t frame_size, uint64_t frame_number)
+{
+//    if(frame_number % REALHEIGHT == 0)
+//        cout << ">>> " << frame_number << endl;
+
+    memcpy(channel_r + send_show_frame_count * SPEC_WIDTH * 2, buffer+2048 * R, SPEC_WIDTH * 2);
+    memcpy(channel_g + send_show_frame_count * SPEC_WIDTH * 2, buffer+2048 * G, SPEC_WIDTH * 2);
+    memcpy(channel_b + send_show_frame_count * SPEC_WIDTH * 2, buffer+2048 * B, SPEC_WIDTH * 2);
+
+//    校正后图片拼接
+    cv::Mat img = cv::Mat(camera->m_height, SPEC_WIDTH, CV_16U, buffer);
+    img.convertTo(img, CV_32F);
+
+//    if(frame_size == 88)
+//    {
+//        img = camera->black_mat;
+//    }
+//   calibrate operation 校正操作
+    cv::Mat calibrated_img = (img - camera->black_mat) / (camera->white_mat - camera->black_mat + camera->eps);
+
+    memcpy( (send_temp_buf + send_show_frame_count * camera->single_frame_size), calibrated_img.data, camera->single_frame_size * 4);
+
+    send_show_frame_count++;
+
+    if( send_show_frame_count == SPEC_HEIGHT )
+    {
+        send_show_frame_count = 0;
+
+        channel_rgb.emplace_back(cv::Mat(SPEC_HEIGHT, SPEC_WIDTH, CV_16UC1, channel_r));
+        channel_rgb.emplace_back(cv::Mat(SPEC_HEIGHT, SPEC_WIDTH, CV_16UC1, channel_g));
+        channel_rgb.emplace_back(cv::Mat(SPEC_HEIGHT, SPEC_WIDTH, CV_16UC1, channel_b));
+
+        cv::Mat temp;
+        cv::merge(channel_rgb, temp);
+        memcpy(temp_rgb, temp.data, SPEC_HEIGHT * SPEC_WIDTH * 6);
+        channel_rgb.clear();
+
+        memcpy(send_buf, send_temp_buf, camera->multi_frame_size * 4);
+
+        //release semaphore
+        ready_to_send.release();
+
+        //emit to ui
+        camera->send_data_to_ui(temp_rgb);
+    }
+    return 0;
+}
+
+/*----------CaptureThread 采集线程----------*/
+ CaptureThread::CaptureThread(QObject *parent) : QThread(parent), m_stop(false)
+ {}
+
+ void CaptureThread::run()
+ {
+     /*----将线程绑定至8号cpu,提高线程效率----*/
+     cpu_set_t get;
+     cpu_set_t mask;
+     int num = sysconf(_SC_NPROCESSORS_CONF);
+//     pthread_t thread_id = pthread_self();
+//     cout << thread_id << endl;
+     CPU_ZERO(&mask);
+     CPU_SET(0, &mask);
+     sched_setaffinity(0, sizeof(mask), &mask);
+     CPU_ZERO(&get);
+     sched_getaffinity(0, sizeof(get), &get);
+     for(int i=0; ilStop->Execute();
+
+             // Disable streaming on the device
+             camera->lDevice->StreamDisable();
+
+             // Abort all buffers from the stream and dequeue
+             camera->lStream->AbortQueuedBuffers();
+
+             // Retrieve the buffers left in stream
+             while ( camera->lStream->GetQueuedBufferCount() > 0 )
+             {
+                 PvBuffer *lBuffer = nullptr;
+                 PvResult lOperationResult;
+                 camera->lStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
+             }
+             return;
+         }
+         stop_mutex.unlock();
+         PvBuffer *lBuffer = nullptr;
+         PvResult lOperationResult;
+
+         // Retrieve next buffer
+         PvResult lResult = camera->lStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
+         if ( lResult.IsOK() )
+         {
+             if ( lOperationResult.IsOK() )
+             {
+                 // We now have a valid buffer. This is where you would typically process the buffer.
+                 // Get image data
+//                 uint64_t frame_size = camera->lDevice->GetPayloadSize();
+                 uint8_t* image = lBuffer->GetDataPointer();
+
+                 //callback function
+                 camera->data_callback(image, 0, lBuffer->GetBlockID());
+             }
+             else
+             {
+//                 camera->data_callback(camera->padding_frame, 88, 0);
+//                 cout << "spec error: "<< lOperationResult.GetCodeString().GetAscii() << endl; // Non OK operational result
+
+             }
+
+             // Re-queue the buffer in the stream object
+             camera->lStream->QueueBuffer( lBuffer );
+         }
+//         else
+//             cout << "*** spec Retrieve buffer failurer: " << lResult.GetCodeString().GetAscii() << endl; // Retrieve buffer failure
+     }
+ }
+
+ void CaptureThread::exit_thread()
+ {
+     stop_mutex.lock();
+     m_stop = true;
+     stop_mutex.unlock();
+ }
+
+ /*-------------RGB_CAMERA---------------------*/
+ RGB_Camera::RGB_Camera(QObject *parent) : QObject(parent)
+ {
+ }
+
+ RGB_Camera::~RGB_Camera()
+ {
+     free_stream_buffers();
+
+     if( lStream != nullptr )
+     {
+         lStream->Close();
+         PvStream::Free(lStream);
+         cout << ">>> rgb_camera: close and free lstream >>>" << endl;
+     }
+
+     if( lDevice != nullptr )
+     {
+         lDevice->Disconnect();
+         PvDevice::Free(lDevice);
+         cout << ">>> rgb_camera: disconnect and free camera device >>>" << endl;
+     }
+
+     if( rgb_capture_thread != nullptr)
+         delete rgb_capture_thread;
+
+
+     cout << "rgb_camera: dkkkkkkkkkkkkkkk" << endl;
+ }
+
+ int RGB_Camera::init_camera()
+ {
+     int status = enum_connect_camera();
+     if(status != 0)
+         return -1;
+
+     status = config_camera();
+     if(status != 0)
+         return -2;
+
+//     get_camera_parameters();
+
+     status = open_stream();
+     if(status != 0)
+         return -3;
+
+     status = configure_stream();
+     if(status != 0)
+         return -4;
+
+     create_stream_buffers();
+
+     rgb_capture_thread = new RGB_CaptureThread();
+
+     send_rgb_buf = new uint8_t[RGB_HEIGHT * RGB_WIDTH * 3];
+
+     return 0;
+ }
+
+ int RGB_Camera::enum_connect_camera()
+ {
+     PvResult lResult;
+     lResult = lSystem.Find();
+     if ( !lResult.IsOK() )
+     {
+         cout << "*** PvSystem::Find Error: " << lResult.GetCodeString().GetAscii();
+         return -1;
+     }
+     uint32_t lInterfaceCount = lSystem.GetInterfaceCount();
+     for ( uint32_t x = 0; x < lInterfaceCount; x++ )
+     {
+         if(lLastDeviceInfo != nullptr)
+             break;
+         uint32_t lDeviceCount = lSystem.GetInterface(x)->GetDeviceCount();
+         for ( uint32_t y = 0; y < lDeviceCount ; y++ )
+         {
+             lDeviceInfo = lSystem.GetInterface(x)->GetDeviceInfo( y );
+
+             const PvDeviceInfoGEV* lDeviceInfoGEV = dynamic_cast( lDeviceInfo );
+             if ( lDeviceInfoGEV != nullptr ) // Is it a GigE Vision device?
+             {
+//                 cout << "    MAC Address: " << lDeviceInfoGEV->GetMACAddress().GetAscii() << endl;
+//                 cout << "    IP Address: " << lDeviceInfoGEV->GetIPAddress().GetAscii() << endl;
+//                 cout << "    Serial number: " << lDeviceInfoGEV->GetSerialNumber().GetAscii() << endl << endl;
+ //                lLastDeviceInfo = lDeviceInfo;
+                 if(!strcmp("00:26:ac:a1:00:9d", lDeviceInfoGEV->GetMACAddress().GetAscii()))
+                 {
+                     PvDeviceGEV::SetIPConfiguration("00:26:ac:a1:00:9d", "192.168.15.105", "255.255.255.0", "192.168.15.1");
+                     lLastDeviceInfo = lDeviceInfo;
+                     break;
+                 }
+                 else
+                 {
+//                     cout << "rgb: not this!" << endl;
+                     continue;
+                 }
+             }
+         }
+     }
+
+     // Connect to the last device found
+     if ( lLastDeviceInfo != nullptr )
+     {
+         cout << ">>> Connecting to " << lLastDeviceInfo->GetDisplayID().GetAscii() << endl;
+
+         // Creates and connects the device controller based on the selected device.
+         lDevice = PvDevice::CreateAndConnect( lLastDeviceInfo, &lResult );
+         if ( !lResult.IsOK() )
+         {
+             cout << "*** Unable to connect to " << lLastDeviceInfo->GetDisplayID().GetAscii() << endl;
+             PvDevice::Free(lDevice);
+             return -1;
+         }
+         else
+         {
+             cout << ">>> Successfully connected to " << lLastDeviceInfo->GetDisplayID().GetAscii() << endl;
+             cout << endl;
+             // Load parameters of the camera
+             parameter_array = lDevice->GetParameters();
+             return 0;
+         }
+     }
+     else
+     {
+         cout << "*** No device found! ***" << endl;
+         return -2;
+     }
+ }
+
+ void RGB_Camera::get_camera_parameters()
+ {
+     PvResult lResult;
+
+     //Get Height
+     PvGenInteger* lheight = parameter_array->GetInteger("SensorHeight");
+     int64_t height = 0;
+     lResult = lheight->GetValue(height);
+     if( !lResult.IsOK() )
+         cout << "*** Unable to get  *** " << endl;
+     else
+         cout <<">>> Height: " << height << endl;
+
+     //Get Width
+     PvGenInteger* lwidth = parameter_array->GetInteger("SensorWidth");
+     int64_t width = 0;
+     lResult = lwidth->GetValue(width);
+     if( !lResult.IsOK() )
+         cout << "*** Unable to get  *** " << endl;
+     else
+         cout <<">>> Width: " << width << endl;
+
+     //Get AcquisitionFrameRate
+     PvGenFloat* lframerate = parameter_array->GetFloat("AcquisitionLineRate");
+     double framerate = 0.0f;
+     lResult = lframerate->GetValue(framerate);
+     if( !lResult.IsOK() )
+         cout << "*** Unable to get  *** " << endl;
+     else
+         cout <<">>> AcquisitionLineRate: " << framerate << endl;
+
+     //Get ExposureTime
+     PvGenFloat* lexposuretime = parameter_array->GetFloat("CommonExposureTime");
+     double exposuretime = 0.0f;
+     lResult = lexposuretime->GetValue(exposuretime);
+     if( !lResult.IsOK() )
+         cout << "*** Unable to get  *** " << endl;
+     else
+         cout << ">>> ExposureTime: " << exposuretime << endl;
+
+     //查看触发模式
+     PvString mode;
+     PvGenEnum* ltriggermode = parameter_array->GetEnum("LineTriggerMode");
+     ltriggermode->GetValue(mode);
+     cout << ">>> TriggerMode: " << mode.GetAscii() << endl;
+     ltriggermode = parameter_array->GetEnum("LineTriggerSource");
+     ltriggermode->GetValue(mode);
+     cout << ">>> TriggerSource: " << mode.GetAscii() << endl;
+     cout << endl;
+ }
+
+ int RGB_Camera::open_stream()
+ {
+     PvResult lResult;
+     // Open stream to the GigE Vision or USB3 Vision device
+     lStream = PvStream::CreateAndOpen( lLastDeviceInfo->GetConnectionID(), &lResult);
+     if ( (lStream == nullptr) || !lResult.IsOK() )
+     {
+         cout << "*** Unable to stream from " << lLastDeviceInfo->GetDisplayID().GetAscii() << ". ***" << endl;
+         PvStream::Free(lStream);
+         PvDevice::Free(lDevice);
+         return -1;
+     }
+     return 0;
+ }
+
+ int RGB_Camera::config_camera()
+ {
+     PvGenParameterArray *lDeviceParams = lDevice->GetParameters();
+     lStart = dynamic_cast( lDeviceParams->Get( "AcquisitionStart" ) );
+     lStop = dynamic_cast( lDeviceParams->Get( "AcquisitionStop" ) );
+     lUserSetLoad = dynamic_cast( lDeviceParams->Get( "UserSetLoad" ) );
+     Whitecal = dynamic_cast( lDeviceParams->Get( "FFCCalPRNU" ) );
+     Blackcal = dynamic_cast( lDeviceParams->Get( "FFCCalFPN" ) );
+     lUserSave = dynamic_cast( lDeviceParams->Get( "UserSetSave" ) );
+     lFFCUserSetSave = dynamic_cast( lDeviceParams->Get( "FFCUserSetSave" ) );
+
+     PvResult lResult = parameter_array->SetEnumValue("UserSetSelector", "UserSet3");
+     if(!lResult.IsOK()){
+         cout << "set userset3 failed" << endl;
+         return -1;
+     }
+     lResult = lUserSetLoad->Execute();
+     if(!lResult.IsOK()){
+         cout << "userset load failed" << endl;
+         return -1;
+     }
+
+     //    //设置触发模式为 外触发,线路Line0,上升沿触发
+     lResult = parameter_array->SetEnumValue("LineTriggerMode", "On");
+     if(!lResult.IsOK()){
+         cout << "set triggermode failed" << endl;
+         return -1;
+     }
+
+     lResult = parameter_array->SetEnumValue("LineTriggerSource", "Line2");
+     if(!lResult.IsOK()){
+         cout << "set triggersource failed" << endl;
+         return -1;
+     }
+
+     return 0;
+ }
+
+ int RGB_Camera::configure_stream()
+ {
+     // If this is a GigE Vision device, configure GigE Vision specific streaming parameters
+     PvDeviceGEV* lDeviceGEV = dynamic_cast( lDevice );
+     if ( lDeviceGEV != nullptr )
+     {
+         PvStreamGEV *lStreamGEV = static_cast( lStream );
+         // Negotiate packet size
+         PvResult lresult =  lDeviceGEV->NegotiatePacketSize();
+         if( !lresult.IsOK() )
+             cout << "negotiate packet size failed" << endl;
+         // Configure device streaming destination
+         lresult = lDeviceGEV->SetStreamDestination( lStreamGEV->GetLocalIPAddress(), lStreamGEV->GetLocalPort() );
+         if( !lresult.IsOK() )
+             cout << "set stream destination failed" << endl;
+ //        cout << ">>> configure stream successfully!" << endl;
+         return 0;
+     }
+     else
+     {
+         cout << "*** configure stream failed! ***" << endl;
+         return -1;
+     }
+ }
+
+ void RGB_Camera::create_stream_buffers()
+ {
+     // Reading payload size from device
+     uint32_t lSize = lDevice->GetPayloadSize();
+//     cout << "payloadsize =  " << lSize << endl;
+ //    cout << lStream->GetQueuedBufferMaximum() << endl;
+
+     // Use BUFFER_COUNT or the maximum number of buffers, whichever is smaller
+     uint32_t lBufferCount = ( lStream->GetQueuedBufferMaximum() < 16 ) ? lStream->GetQueuedBufferMaximum() : 16;
+//     cout << "lbuffercount = " << lBufferCount << endl;
+
+     // Allocate buffers
+     for( uint8_t i=0; iAlloc( static_cast( lSize + 500 ) );
+         if(!lresult.IsOK())
+             cout << "dk failed" << endl;
+
+         // Add to external list - used to eventually release the buffers
+         lbufferlist.push_back(lBuffer);
+     }
+//     cout << ">>> rgb: create stream buffers successfully" << endl;
+ }
+
+ void RGB_Camera::free_stream_buffers()
+ {
+     bufferlist::iterator iter = lbufferlist.begin();
+     while( iter != lbufferlist.end() )
+     {
+         delete *iter;
+         iter++;
+     }
+     // Clear the buffer list
+     lbufferlist.clear();
+ }
+
+ void RGB_Camera::start_acquisition()
+ {
+     // Queue all buffers in the stream
+     bufferlist::iterator iter = lbufferlist.begin();
+     while( iter != lbufferlist.end() )
+     {
+         lStream->QueueBuffer(*iter);
+         iter++;
+     }
+     cout << "queue buffer successfully..." << endl;
+
+     // Enable streaming and send the AcquisitionStart command
+ //    cout << "Enabling streaming and sending AcquisitionStart command." << endl;
+     lDevice->StreamEnable();
+     lStart->Execute();
+
+     // start a new thread CaptureThread
+     rgb_capture_thread->stop_mutex.lock();
+     rgb_capture_thread->m_stop = false;
+     rgb_capture_thread->stop_mutex.unlock();
+     rgb_capture_thread->start();
+ }
+
+ void RGB_Camera::stop_acquisition()
+ {
+     //线程停止!
+     rgb_capture_thread->exit_thread();
+     rgb_capture_thread->wait();
+     if(rgb_capture_thread->isFinished())
+     {
+         cout << ">>>rgb capture thread stopped successfully" << endl;
+     }
+ }
+
+ /*--------rgb_capture thread---------------------*/
+ RGB_CaptureThread::RGB_CaptureThread(QObject *parent) : QThread(parent), m_stop(false)
+ {}
+
+ void RGB_CaptureThread::run()
+ {
+     /*----将线程绑定至6号cpu,提高线程效率----*/
+//     cpu_set_t get;
+//     cpu_set_t mask;
+//     int num = sysconf(_SC_NPROCESSORS_CONF);
+////     pthread_t thread_id = pthread_self();
+////     cout << thread_id << endl;
+//     CPU_ZERO(&mask);
+//     CPU_SET(1, &mask);
+//     sched_setaffinity(1, sizeof(mask), &mask);
+//     CPU_ZERO(&get);
+//     sched_getaffinity(1, sizeof(get), &get);
+//     for(int i=0; ilStop->Execute();
+
+             // Disable streaming on the device
+             rgb_camera->lDevice->StreamDisable();
+
+             // Abort all buffers from the stream and dequeue
+             rgb_camera->lStream->AbortQueuedBuffers();
+
+             // Retrieve the buffers left in stream
+             while ( rgb_camera->lStream->GetQueuedBufferCount() > 0 )
+             {
+                 PvBuffer *lBuffer = nullptr;
+                 PvResult lOperationResult;
+                 rgb_camera->lStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
+             }
+             return;
+         }
+         stop_mutex.unlock();
+         PvBuffer *lBuffer = nullptr;
+         PvResult lOperationResult;
+
+         // Retrieve next buffer
+         PvResult lResult = rgb_camera->lStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
+         if ( lResult.IsOK() )
+         {
+             if ( lOperationResult.IsOK() )
+             {
+                 // We now have a valid buffer. This is where you would typically process the buffer.
+                 // Get image data
+//                 uint64_t frame_size = camera->lDevice->GetPayloadSize();
+                 uint8_t* image = lBuffer->GetDataPointer();
+                 memcpy(send_rgb_buf, image, RGB_HEIGHT * RGB_WIDTH * 3);
+                 rgb_camera->send_rgbdata_to_ui(send_rgb_buf);
+
+                 ready_to_send_rgb.release();
+             }
+             else{
+//                  memset(send_rgb_buf, 0, RGB_HEIGHT * RGB_WIDTH * 3);
+//                  ready_to_send_rgb.release();
+//                cout << "rgb error: "<< lOperationResult.GetCodeString().GetAscii() << endl; // Non OK operational result
+             }
+             // Re-queue the buffer in the stream object
+             rgb_camera->lStream->QueueBuffer( lBuffer );
+         }
+//         else
+//             cout << "*** rgb Retrieve buffer failure: " << lResult.GetCodeString().GetAscii() << endl; // Retrieve buffer failure
+     }
+ }
+
+ void RGB_CaptureThread::exit_thread()
+ {
+     stop_mutex.lock();
+     m_stop = true;
+     stop_mutex.unlock();
+ }
diff --git a/camera.h b/camera.h
new file mode 100644
index 0000000..6f72bf8
--- /dev/null
+++ b/camera.h
@@ -0,0 +1,397 @@
+/**
+ * @file camera.h
+ * @author DingKun & ChengLei
+ * @date 2022.3.5
+ * @brief The file contains a class named Camera
+ * @details The file contains a class named Camera
+ * which refers to the hyperspectral camera(FX10e).
+ *
+ * The Camera class in this file contains the operation
+ * and parameters of the hyperspectral camera(FX10e).
+ */
+
+#ifndef CAMERA_H
+#define CAMERA_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "iostream"
+#include 
+#include 
+#include "opencv.hpp"
+#include 
+#include 
+#include 
+
+using namespace std;
+
+extern float file_explosure;
+extern vector mroi;
+extern vector valid;
+extern int R;
+extern int G;
+extern int B;
+
+class CaptureThread;
+//Ebus图像传输流队列的大小
+#define BUFFER_COUNT 64
+//光谱数据的宽度
+#define SPEC_WIDTH 1024
+//光谱数据的高度
+#define SPEC_HEIGHT 256
+//有效的谱段
+#define VALIDBANDS 22
+//采集校正时取平均的图像数
+#define CALIBRATION_FRAMES 35
+//光谱相机的数字增益
+#define GAIN 2.0f
+// 光谱mask高度宽度
+#define SPEC_MASK_HEIGHT 1024
+#define SPEC_MASK_WIDTH 1024
+// RGB mask高度宽度
+#define RGB_MASK_HEIGHT 1024
+#define RGB_MASK_WIDTH 1024
+// RGB图像的高度宽度
+#define RGB_HEIGHT 1024
+#define RGB_WIDTH 4096
+
+/**
+ * @brief Indicate a pointer to function
+ */
+typedef int(*callback_ptr)(uint8_t*, uint64_t, uint64_t);
+
+/**
+ * @brief List contains pointer to PvBuffer
+ */
+typedef std::list bufferlist;
+
+/**
+ * @brief Callback function runs when camera captures one frame
+ * @param buffer The image data in one frame
+ * @param frame_size The size of the buffer in one frame
+ * @param frame_number The number of the frame
+ * @return Indicate the status of operation
+ */
+int on_data_callback(uint8_t* buffer, uint64_t frame_size, uint64_t frame_number);
+
+int onDataCallback_calibration(uint8_t* buffer, uint64_t frame_size, uint64_t frame_number);
+
+int onDataCallback_acquisition(uint8_t* buffer, uint64_t frame_size, uint64_t frame_number);
+
+/**
+ * @brief The Camera class
+ * @details
+ * 
Hyperspectral camera model: Specim FX10e
+ * etThe class contains the operation and paramers of the hyperspectral camera(FX10e).
+ * Steps to control the hyperspectral camera:
+ * 1. Selects a device
+ * 2. Connect the PvDevice, opens the PvStream
+ * 3. Allocates the buffers
+ * 4. Starts acquistion
+ * 5. Retrieve/process/free incoming buffers
+ * 6. Stops acquisition
+ */ +class Camera : public QObject +{ + Q_OBJECT +public: + PvDevice* lDevice = nullptr; ///< Camera device handler + PvStream* lStream = nullptr; ///< Stream handler + bufferlist lbufferlist; ///< buffer list to manage memory + + PvGenCommand *lStart; ///< GenICam command to start capture + PvGenCommand *lStop; ///< GenICam command to stop capture + + PvSystem lSystem; + const PvDeviceInfo* lLastDeviceInfo = nullptr; ///< DeviceInfo handler + const PvDeviceInfo *lDeviceInfo = nullptr; + + PvGenParameterArray* parameter_array = nullptr; ///< ParameterArray handler + callback_ptr data_callback = nullptr; ///< Pointer to function which type is callback_ptr + + CaptureThread* capture_thread = nullptr; + + bool capture_black_flag = false; ///< flag to capture black frame + bool capture_white_flag = false; ///< flag to capture white frame + + cv::Mat sum_mat_for_calibration; + cv::Mat eps; ///The function contains all the needed operations before the camera works. + * Use function to initialize camera at first when you want to capture images.
+ */ + int init_camera(); + + /** + * @brief Enumerate and connect to the camera + * @return Status + * @retval 0 The camera is connected successfully + * @retval -1 lSystem.Find() error + * @retval -2 lLastDeviceInfo is NULL, camera not found + */ + int enum_connect_camera(); + + /** + * @brief Connect to the camera + * @details Be sure to enumerate the camera first and lLastDeviceInfo is not NULL + * @return Status + * @retval 0 Connect to the camera successfully + * @retval -1 PvDevice::CreateAndConnect() error + * @retval -2 lLastDeviceInfo is NULL + */ + int connect_camera(); + + /** + * @brief Get the parameters of camera + */ + void get_camera_parameters(); + + /** + * @brief Set MROI + * @details
Setting MROI needs to happen as following sequence of commands:
+     * 1. Disable MROI
+     * 2. Clear old MROI indexes & values
+     * 3. Set new MROI indexes & values
+     * 4. Set STOP INDEX after the last known MROI index
+     *    FX10/FX10e the STOP INDEX: MROI top offset = 1081, MROI height = 0
+     * 5. Enable MROI
+ * @param vec Vector contains mroi parameters + */ + void set_MROI(const vector &vec); + + /** + * @brief Config the parameters of camera + * @return Status + * @retval 0 Configure camera parameters successfully + * @retval -1 Failed to configure camera parameters + */ + int config_camera(); + + /** + * @brief Open stream to the GigE Vision or USB3 Vision device + * @return Status + * @retval 0 The stream is opened successfully + * @retval -1 lStream is NULL or PvStream::CreateAndOpen() error + */ + int open_stream(); + + /** + * @brief Configure streaming for GigE Vision devices + * @return Status + * @retval 0 Configure stream successfully + * @retval -1 lDeviceGEV is NULL + * @details First, we use a dynamic cast to determine if the PvDevice object represents a GigE Vision device. If it is a + * GigE Vision device, we do the required configuration. If it is a USB3 Vision device, no stream configuration is + * required for this sample. When we create a pointer to the PvStream object, we use a static cast (because we already + * know that the PvStream object represents a stream from a GigE Vision device (PvStreamGEV), and no checking is required) + */ + int configure_stream(); + + /** + * @brief Create stream buffers to allocate memory for the received images + * @details PvStream contains two buffer queues: an “input” queue and an “output” queue. First, we add PvBuffer + * objects to the input queue of the PvStream object by calling PvStream::QueueBuffer once per buffer. As images + * are received, PvStream populates the PvBuffers with images and moves them from the input queue to the output queue. + * The populated PvBuffers are removed from the output queue by the application (using PvStream::RetrieveBuffer), + * processed, and returned to the input queue (using PvStream::QueueBuffer) + * + * The memory allocated for PvBuffer objects is based on the resolution of the image and the bit depth of the + * pixels (the payload) retrieved from the device using PvDevice::GetPayloadSize. The device returns the number of bytes + * required to hold one buffer, based on the configuration of the device + */ + void create_stream_buffers(); + + /** + * @brief Start acquisition + * @author ChengLei + * @details The function send start command to camera in order to start acquisition. + * It will start a new thread CaptureThread to get image buffer from stream. + */ + void start_acquisition(); + + /** + * @brief Stop acquisition + * @author ChengLei + * @details The function send stop command to camera in order to stop acquisition. + */ + void stop_acquisition(); + + /** + * @brief Free stream buffers + * @author Chenglei + * @attention Remenber to free stream buffers before exiting the program + */ + void free_stream_buffers(); + + /** + * @brief Register callback function + * @param ptr Pointer to the callback function + */ + inline void register_data_callback(callback_ptr ptr){ + data_callback = ptr; + } + + /** + * @brief Unregister callback function + */ + void unregister_data_callback(){ + data_callback = nullptr; + } + + /** + * @brief Register callback function for calibration + */ + void register_callback_calibration(); + + /** + * @brief Register callback function for acquisition + */ + void register_callback_acquisition(); + + int init_calibration_load(); + +signals: + void send_calibration_finished_message(); + void send_data_to_ui(uint8_t*); + +public slots: + /** + * @brief Load calibration file for black frame and white frame + * @details read "./black" and "./white" files for black_buf and white_buf + */ + void load_calibration(); +}; + +/*--------------fx10 capturethread-------------------*/ + +/** + * @brief The CaptureThread class + * @details CaptureThread runs when camera starts capture. + * Processing to captured buffers depends on callback function which registered before + */ +class CaptureThread: public QThread +{ Q_OBJECT + +private: + + +protected: + /** + * @brief CaptureThread runs when camera starts capture + * @details Processing to captured buffers depends on callback function which registered before + */ + void run(); + + +public: + QMutex stop_mutex; + bool m_stop = false; + explicit CaptureThread(QObject *parent = NULL); + void exit_thread(); +}; + +/*-------------rgb_camera thread--------------*/ +class RGB_CaptureThread: public QThread +{ Q_OBJECT + +private: + + +protected: + /** + * @brief CaptureThread runs when camera starts capture + * @details Processing to captured buffers depends on callback function which registered before + */ + void run(); + + +public: + bool m_stop = false; + QMutex stop_mutex; + explicit RGB_CaptureThread(QObject *parent = NULL); + void exit_thread(); +}; + + +/* -----------------------RGB_CAMERA--------------------- */ +class RGB_Camera : public QObject +{ + Q_OBJECT +public: + PvDevice* lDevice = nullptr; ///< Camera device handler + PvStream* lStream = nullptr; ///< Stream handler + bufferlist lbufferlist; ///< buffer list to manage memory + + PvGenCommand *lStart; ///< GenICam command to start capture + PvGenCommand *lStop; ///< GenICam command to stop capture + PvGenCommand *lUserSetLoad; + PvGenCommand *Blackcal; + PvGenCommand *Whitecal; + PvGenCommand *lUserSave; + PvGenCommand *lFFCUserSetSave; + + PvSystem lSystem; + const PvDeviceInfo* lLastDeviceInfo = nullptr; ///< DeviceInfo handler + const PvDeviceInfo *lDeviceInfo = nullptr; + + PvGenParameterArray* parameter_array = nullptr; ///< ParameterArray handler + RGB_CaptureThread* rgb_capture_thread = nullptr; + +// double m_gain = 2; +// double m_exposuretime; +// double m_framerate; + + explicit RGB_Camera(QObject *parent = nullptr); + + ~RGB_Camera(); + + int init_camera(); + int enum_connect_camera(); + int connect_camera(); + int config_camera(); + void get_camera_parameters(); + int open_stream(); + int configure_stream(); + void create_stream_buffers(); + void start_acquisition(); + void stop_acquisition(); + void free_stream_buffers(); +signals: + void send_rgbdata_to_ui(uint8_t*); +}; + + +#endif // CAMERA_H diff --git a/log b/log new file mode 100644 index 0000000..fa73c7d --- /dev/null +++ b/log @@ -0,0 +1,34 @@ +2022 08.24 10:24:08 On +2022 08.24 10:25:16 Off +2022 08.24 10:30:59 On +2022 08.24 10:32:00 Off +2022 08.24 10:35:27 On +2022 08.24 10:36:37 Off +2022 08.24 10:38:57 On +2022 08.24 10:40:31 Off +2022 08.24 10:55:44 On +2022 08.24 10:55:48 Off +2022 08.24 10:56:33 On +2022 08.24 10:56:44 Off +2022 08.24 11:01:34 On +2022 08.24 11:06:28 On +2022 08.24 13:44:44 On +2022 08.24 14:11:26 On +2022 08.24 15:29:14 On +2022 08.24 15:41:32 On +2022 08.24 15:48:04 On +2022 08.24 15:58:33 On +2022 08.24 16:04:39 On +2022 08.24 16:08:21 On +2022 08.24 16:18:27 On +2022 08.24 16:20:15 On +2022 08.24 16:22:59 On +2022 08.24 16:25:58 On +2022 08.24 16:31:16 On +2022 08.24 16:32:35 On +2022 08.24 16:35:44 On +2022 08.24 16:37:29 On +2022 08.24 16:46:17 On +2022 08.24 17:10:04 Off +2022 08.24 17:15:07 On +2022 08.24 17:21:01 On diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..ddafc49 --- /dev/null +++ b/main.cpp @@ -0,0 +1,30 @@ +#include "widget.h" +#include +#include "pthread.h" +#include "unistd.h" +#include "sys/types.h" +#include "sys/sysinfo.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); +// cpu_set_t get; +// cpu_set_t mask; +// int num = sysconf(_SC_NPROCESSORS_CONF); +// pthread_t thread_id = pthread_self(); +// cout << thread_id << endl; +// CPU_ZERO(&mask); +// CPU_SET(6, &mask); +// sched_setaffinity(0, sizeof(mask), &mask); +// CPU_ZERO(&get); +// sched_getaffinity(0, sizeof(get), &get); +// for(int i=0; i + + + + +class Parameter{ +public: + QTime lamp_timer; + uint32_t lamp_used_time = 0; + string password; + vector file_info = vector(2); + uint32_t valve_cnt_vector[256] = {0}; + QDateTime current_time; +}; + + + + +#endif // PARAMETER_H diff --git a/read_buffer.py b/read_buffer.py new file mode 100644 index 0000000..54fbf63 --- /dev/null +++ b/read_buffer.py @@ -0,0 +1,20 @@ +import numpy as np +import matplotlib.pyplot as plt + +img_names = [f"mask_result{i}" for i in range(23, 40)] +mask_names = [f"padding_result{i}" for i in range(23, 40)] + +for img_name, mask_name in zip(img_names,mask_names): + with open(img_name, "rb") as f: + data = f.read() + with open(mask_name, "rb") as f: + data_mask = f.read() + img = np.frombuffer(data, dtype=np.uint8).reshape((1024, 256, -1)) + mask = np.frombuffer(data_mask, dtype=np.uint8).reshape((1024, 256, -1)) + fig, axs = plt.subplots(2, 1, constrained_layout=True) + axs[0].imshow(img) + #axs[0].set_title(f'mask_result{i}') + axs[1].imshow(mask) + #axs[1].set_title(f'padding_result{i}') + plt.title(f"img : {img_name}") + plt.show() diff --git a/start_qt.sh b/start_qt.sh new file mode 100644 index 0000000..f2a1250 --- /dev/null +++ b/start_qt.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "123456" | sudo -S dpkg -i /home/dt/eBUS_SDK_Ubuntu-18.04-x86_64-6.2.8-5877.deb +sleep 6 +echo "123456" | sudo -S chmod 777 /dev/ttyS0 +sleep 20 +cd /home/dt/tobacco_huaian/aaaaa/2022.8.21/2022.8.20/tobacco_v1_0 +./tobacco_v1_0 > /home/dt/tobacco_huaian/aaaaa/2022.8.21/2022.8.20/tobacco_v1_0/123.txt diff --git a/sys_parameter b/sys_parameter new file mode 100644 index 0000000..f2304a0 --- /dev/null +++ b/sys_parameter @@ -0,0 +1,2 @@ +151248 +100 diff --git a/thread.cpp b/thread.cpp new file mode 100644 index 0000000..14eae40 --- /dev/null +++ b/thread.cpp @@ -0,0 +1,376 @@ +/** + * @file thread.cpp + * @author DingKun & ChengLei + * @date 2022.3.15 + * @brief The file contains the details about implementation of three thread class SendThread,RecvThread,SaveThread and one class SaveBuf + * @details SendThread sends image to python.RecvThread receives mask image from python.SaveThread save three + * images by turns.SaveBuf maintenances the saved images. + */ + +#include "thread.h" +#include "unistd.h" +#include "fcntl.h" +#include "sys/types.h" +#include "sys/stat.h" +#include "modbus.h" + + +#define FIFO_PATH "/tmp/dkimg.fifo" +#define FIFO_MASK "/tmp/dkmask.fifo" +#define FIFO_RGB "/tmp/dkrgb.fifo" +#define FIFO_MASK_RGB "/tmp/dkmask_rgb.fifo" + +#define ACQUISITION_ENABLE + +extern QSemaphore ready_to_send; +extern QSemaphore ready_to_send_rgb; +extern int file_threshold; +extern int file_threshold_rgb; +extern int file_padding; + +extern float* send_buf; +extern float* send_valid_buf; + +extern uint8_t* send_rgb_buf; + +extern modbus_t* plc; + +uint8_t* recvbuf = nullptr; +uint8_t* recvbuf_rgb = nullptr; +extern uint8_t* temp_rgb; + +extern Camera* camera; + +SaveBuf* save_buf_queue = new SaveBuf(); + +uint8_t* merge_mask = new uint8_t[256 * 1024]; +uint8_t* merge_mask_rgb = new uint8_t[256 * 1024]; +//uint8_t* merge_bit2byte = new uint8_t[32 * 1024]; +//uint8_t* merge_bit2byte_rgb = new uint8_t[32 * 1024]; + +uint8_t* send_mask_guo = new uint8_t[32 * 1024]; + +SendThread::SendThread(QObject *parent) : QThread(parent) +{ + recvbuf = new uint8_t[SPEC_MASK_HEIGHT * SPEC_MASK_WIDTH]; + recvbuf_rgb = new uint8_t[RGB_MASK_HEIGHT * RGB_MASK_WIDTH]; +} + +SendThread::~SendThread() +{ + if( recvbuf ) delete recvbuf; + if( recvbuf_rgb ) delete recvbuf_rgb; +} + +void SendThread::run() +{ + //建立管道 + if(access(FIFO_PATH, F_OK) == -1) + { + int res = mkfifo(FIFO_PATH, 0777); + if(res < 0) + { + cout << "make img fifo failed!" << endl; + return; + } + } + if(access(FIFO_MASK, F_OK) == -1) + { + int res = mkfifo(FIFO_MASK, 0777); + if(res < 0) + { + cout << "make mask fifo failed!" << endl; + return; + } + } + if(access(FIFO_RGB, F_OK) == -1) + { + int res = mkfifo(FIFO_RGB, 0777); + if(res < 0) + { + cout << "make rgb fifo failed!" << endl; + return; + } + } + if(access(FIFO_MASK_RGB, F_OK) == -1) + { + int res = mkfifo(FIFO_MASK_RGB, 0777); + if(res < 0) + { + cout << "make mask_rgb fifo failed!" << endl; + return; + } + } + + int fd_img = open(FIFO_PATH, O_WRONLY); + int fd_rgb = open(FIFO_RGB, O_WRONLY); + + string str = to_string(file_threshold); + int ret = write(fd_img, str.c_str(), str.size()); + if(ret > 0) + cout << ">>> spec threshold " << file_threshold << " send to python" << endl; + + str = to_string(file_threshold_rgb); + ret = write(fd_rgb, str.c_str(), str.size()); + if(ret > 0) + cout << ">>> rgb threshold " << file_threshold_rgb << " send to python" << endl; + + uint8_t padding_hash[256] = {0}; + uint8_t padding_hash_rgb[256] = {0}; + + while(1) + { + ready_to_send.acquire(); //block if no send_buf is ready! + ready_to_send_rgb.acquire(); + + int k = 0; + for( int i = 0; i < SPEC_HEIGHT; i++ ) + { + for(uint j = 0; j < valid.size(); j++ ) + { + memcpy(send_valid_buf + SPEC_WIDTH * k, send_buf + (i * camera->m_height + valid[j]) * 1024, + sizeof(float) * SPEC_WIDTH); + k++; + } + } + /*存图功能*/ + + if(save_flag == true) + { + static int file_index = 0; + string spec_filename = "./saved_img/spec" + to_string(file_index); + FILE *fp = fopen(spec_filename.c_str(), "wb"); + fwrite(send_valid_buf, SPEC_HEIGHT * SPEC_WIDTH * valid.size() * 4, 1, fp); + fclose(fp); + string rgb_filename = "./saved_img/rgb" + to_string(file_index); + fp = fopen(rgb_filename.c_str(), "wb"); + fwrite(send_rgb_buf, RGB_HEIGHT * RGB_WIDTH * 3, 1, fp); + fclose(fp); + file_index++; + cout << "save img success!" << endl; + } + /////////////////////////////// + + //发送给python + write(fd_img, send_valid_buf, SPEC_WIDTH * valid.size() * SPEC_HEIGHT * sizeof(float)); + + write(fd_rgb, send_rgb_buf, RGB_HEIGHT * RGB_WIDTH * 3); + + int fd = open(FIFO_MASK, O_RDONLY); + read(fd, recvbuf, SPEC_MASK_HEIGHT * SPEC_MASK_WIDTH); + close(fd); + fd = open(FIFO_MASK_RGB, O_RDONLY); + read(fd, recvbuf_rgb, RGB_MASK_HEIGHT * RGB_MASK_WIDTH); + close(fd); + +// save_buf_queue->enqueue(send_valid_buf, (char*)recvbuf); + + //send mask to ui + emit send_mask((char*)recvbuf); //mask********************************************* + emit send_mask_rgb((char*)recvbuf_rgb); + + /*mask图像转换喷阀通道 宽度1024像素对应256个喷阀,1024/256=4,每一行转换为256个bit, + *总共32个字节,最终发送给下位机的数据大小为(32*1024字节)*/ + + //光谱mask阀通道转换 + int sum = 0; + for(int i=0; i 0) ? (merge_mask[i/4] = 1) : (merge_mask[i/4] = 0); + sum = 0; + } + //rgb mask阀通道转换 + sum = 0; + for(int i=0; i 0) ? (merge_mask_rgb[i/4] = 1) : (merge_mask_rgb[i/4] = 0); + sum = 0; + } + + //延长喷阀开启时间,纵向拉长像素 + uint8_t temp_buf[1024 * 256] = {0}; + for(int i=0; i<1024; ++i) + { + if(i == 0) + { + for(int j=0; j<256; ++j) + { + while(padding_hash[j] > 0) + { + temp_buf[padding_hash[j]*256 + j] = 1; + --padding_hash[j]; + } + } + } + for(int j=0; j<256; ++j) + { + if(merge_mask[i * 256 + j] == 1) + { + temp_buf[i * 256 + j] = 1; + int padding = 0; + while(padding < file_padding) + { + if(i + padding >= 1024) + { + padding_hash[j] = file_padding - padding; + break; + } + else + { + temp_buf[(i + padding) * 256 + j] = 1; + ++padding; + } + } + } + } + } + + uint8_t temp_buf_rgb[1024 * 256] = {0}; + for(int i=0; i<1024; ++i) + { + if(i == 0) + { + for(int j=0; j<256; ++j) + { + while(padding_hash_rgb[j] > 0) + { + temp_buf[padding_hash_rgb[j]*256 + j] = 1; + --padding_hash_rgb[j]; + } + } + } + for(int j=0; j<256; ++j) + { + if(merge_mask_rgb[i * 256 + j] == 1) + { + temp_buf_rgb[i * 256 + j] = 1; + int padding = 0; + while(padding < file_padding) + { + if(i + padding >= 1024) + { + padding_hash_rgb[j] = file_padding - padding; + break; + } + else + { + temp_buf_rgb[(i + padding) * 256 + j] = 1; + ++padding; + } + } + } + } + } + + //计算喷伐开启次数 + /* + for(int i=0; i=0; --j) +// temp = (temp << 1) | temp_buf[i + j]; +// merge_bit2byte[i/8] = temp; +// } +// for(int i=0; i<256*1024; i+=8) +// { +// uint8_t temp = 0; +// for(int j=7; j>=0; --j) +// temp = (temp << 1) | temp_buf_rgb[i + j]; +// merge_bit2byte_rgb[i/8] = temp; +// } + //合并两个mask + for(int i=0; i<256*1024; i+=8) + { + uint8_t temp = 0; + uint8_t temp_rgb = 0; + for(int j=7; j>=0; --j) + { + temp = (temp << 1) | temp_buf[i + j]; + temp_rgb = (temp_rgb << 1) | temp_buf_rgb[i + j]; + } + temp |= temp_rgb; + send_mask_guo[i/8] = temp; + } + + emit send_valve_data(send_mask_guo); + } +} + +SaveBuf::SaveBuf() +{ + buf = new float[SPEC_WIDTH * VALIDBANDS * SPEC_HEIGHT * SAVEIMGNUMBER]; + mask = new char[1024 * 256 * SAVEIMGNUMBER]; + buf_copy = new float[SPEC_WIDTH * VALIDBANDS * SPEC_HEIGHT * SAVEIMGNUMBER]; + mask_copy = new char[1024 * 256 * SAVEIMGNUMBER]; +} + +SaveBuf::~SaveBuf() +{ + delete [] buf; + delete [] mask; + delete [] buf_copy; + delete [] mask_copy; +} + +void SaveBuf::enqueue(float* buf_tmp, char* mask_tmp) +{ + mutex.lock(); + memcpy(buf + index * SPEC_WIDTH * VALIDBANDS * SPEC_HEIGHT, buf_tmp, SPEC_WIDTH * VALIDBANDS * SPEC_HEIGHT * 4); + memcpy(mask + index * 1024 * 1024, mask_tmp, 1024 * 1024); + mutex.unlock(); + index++; +// cout << "save index ==================" << index << endl; + if(index >= SAVEIMGNUMBER) + index = 0; +} + +void SaveBuf::save() +{ + mutex.lock(); + memcpy(buf_copy, buf, SPEC_WIDTH * VALIDBANDS * SPEC_HEIGHT * SAVEIMGNUMBER * 4); + memcpy(mask_copy, mask, 1024 * 1024 * SAVEIMGNUMBER); + mutex.unlock(); + char* filename; + QDateTime time = QDateTime::currentDateTime(); + QString str = time.toString("yyyyMMddhhmmss"); + for( int i = 0; i < SAVEIMGNUMBER; i++) + { + QString mask_name = str + "mask" + QString::number(i); + filename = mask_name.toLatin1().data(); + FILE* fp = fopen(filename, "wb"); + fwrite(mask_copy + i * 1024 * 1024, 1024 * 1024, 1, fp); + fclose(fp); + + QString buf_name = str + "buf" + QString::number(i) + ".raw"; + filename = buf_name.toLatin1().data(); + fp = fopen(filename, "wb"); + fwrite(buf_copy + i * SPEC_WIDTH * VALIDBANDS * SPEC_HEIGHT, SPEC_WIDTH * VALIDBANDS * SPEC_HEIGHT * 4, 1, fp); + fclose(fp); + cout << ">>> save success"; + } +} + +//savethread保存图片线程,该线程保持一个环形队列始终存放实时图像 +SaveThread::SaveThread(QObject *parent) : QThread(parent) +{} + +void SaveThread::run() +{ +// cout << "save thread running" << endl; + while (1) + { + + save_flag.acquire(); + save_buf_queue->save(); + cout << "acquired!!" << endl; + } +} + diff --git a/thread.h b/thread.h new file mode 100644 index 0000000..82fe736 --- /dev/null +++ b/thread.h @@ -0,0 +1,83 @@ +/** + * @file thread.h + * @author DingKun & ChengLei + * @date 2022.3.15 + * @brief The file contains three thread class SendThread,RecvThread,SaveThread and one class SaveBuf + * @details SendThread sends image to python.RecvThread receives mask image from python.SaveThread save three + * images by turns.SaveBuf maintenances the saved images. + */ + +#ifndef THREAD_H +#define THREAD_H + +#include +#include +#include +#include +#include +#include +#include "camera.h" + +#define SAVEIMGNUMBER 2 + +/** + * @brief The SendThread class + * @details SendThread contains a send_server and a send_socket connect to python process. + * It detects if send_buf is ready to send by semaphore.If send_buf is ready to send, it obtains valid + * bands in send_buf then send to python process by send_socket + */ +class SendThread: public QThread +{ Q_OBJECT +protected: + /** + * @brief It detects if send_buf is ready to send by semaphore.If send_buf is ready to send, it obtains valid + * bands in send_buf then send to python process by send_socket. Also, if the ACQUISITION_ENABLE flag is defined, + * it is responsible for saving both calibrated image and raw image, but the mission of sending to python is stopped. + */ + void run(); + +public: + explicit SendThread(QObject *parent = NULL); + ~SendThread(); + + volatile bool save_flag = false; + +signals: + void send_valve_data(uint8_t* spec_mask); + void send_to_up_machine(float*); + void send_mask(char* buf); + void send_mask_rgb(char* buf); +}; + + +class SaveBuf +{ +public: + SaveBuf(); + ~SaveBuf(); + void enqueue(float* buf_tmp, char* mask_tmp); + void save(); + +private: + QMutex mutex; + + float* buf; + char* mask; + float* buf_copy; + char* mask_copy; + + int index = 0; +}; + +class SaveThread: public QThread +{ Q_OBJECT +protected: + void run(); + +public: + explicit SaveThread(QObject *parent = NULL); + QSemaphore save_flag; +}; + + +#endif // THREAD_H diff --git a/tobacco_v1_0 b/tobacco_v1_0 new file mode 100644 index 0000000..e61a1b0 Binary files /dev/null and b/tobacco_v1_0 differ diff --git a/tobacco_v1_0.pro b/tobacco_v1_0.pro new file mode 100644 index 0000000..9ecbf90 --- /dev/null +++ b/tobacco_v1_0.pro @@ -0,0 +1,81 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-03-06T19:05:49 +# +#------------------------------------------------- + +QT += core gui network + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = tobacco_v1_0 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +UI_DIR += ./ + +SOURCES += \ + main.cpp \ + widget.cpp \ + camera.cpp \ + thread.cpp \ + parameter.cpp + +HEADERS += \ + widget.h \ + camera.h \ + thread.h \ + parameter.h + +FORMS += \ + widget.ui + + +LIBS += -L/opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/lib/ -lEbTransportLayerLib \ + -lPtUtilsLib \ + -lPvBase \ + -lPvCameraBridge \ + -lPvGenICam \ + -lPvPersistence \ + -lPvStream \ + -lPvTransmitter\ + -lSimpleImagingLib \ + -lEbUtilsLib \ + -lPtConvertersLib \ + -lPvAppUtils \ + -lPvBuffer \ + -lPvDevice \ + -lPvGUI \ + -lPvSerial \ + -lPvSystem \ + -lPvVirtualDevice + +INCLUDEPATH += /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include +DEPENDPATH += /opt/pleora/ebus_sdk/Ubuntu-18.04-x86_64/include + + +LIBS += -L/usr/lib/x86_64-linux-gnu/ -lopencv_core \ + -lopencv_imgproc \ + -lopencv_highgui \ + -lopencv_imgcodecs \ + +INCLUDEPATH += /usr/include/opencv2 +DEPENDPATH += /usr/include/opencv2 + +LIBS += -L/usr/lib/x86_64-linux-gnu/ -lmodbus +INCLUDEPATH += /home/dt/下载/libmodbus-3.1.6/install/include/modbus + +#RESOURCES += \ +# image_use.qrc + + diff --git a/tobacco_v1_0.pro.user b/tobacco_v1_0.pro.user new file mode 100644 index 0000000..157fb79 --- /dev/null +++ b/tobacco_v1_0.pro.user @@ -0,0 +1,216 @@ + + + + + + EnvironmentId + {3134a746-b29c-4a8f-8071-aa79d42fc02d} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + 桌面 + 桌面 + {3bf39791-694f-41b0-8dcf-bfce0aa84de8} + 0 + 0 + 0 + + /home/dt/2022.8.1/tobacco_v1_0 + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 1 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + 在本地部署 + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + tobacco_v1_0 + + Qt4ProjectManager.Qt4RunConfiguration:/home/dt/tobacco_huaian/aaaaa/2022.8.21/2022.8.20/tobacco_v1_0/tobacco_v1_0.pro + true + + tobacco_v1_0.pro + false + + /home/dt/2022.8.1/tobacco_v1_0 + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/tobacco_v1_0.pro.user.3134a74 b/tobacco_v1_0.pro.user.3134a74 new file mode 100644 index 0000000..6f04505 --- /dev/null +++ b/tobacco_v1_0.pro.user.3134a74 @@ -0,0 +1,216 @@ + + + + + + EnvironmentId + {3134a746-b29c-4a8f-8071-aa79d42fc02d} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + 桌面 + 桌面 + {3bf39791-694f-41b0-8dcf-bfce0aa84de8} + 0 + 0 + 0 + + /home/dt/2022.8.1/tobacco_v1_0 + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 1 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + 在本地部署 + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + tobacco_v1_0 + + Qt4ProjectManager.Qt4RunConfiguration:/home/dt/2022.8.1/tobacco_v1_0/tobacco_v1_0.pro + true + + tobacco_v1_0.pro + false + + /home/dt/2022.8.1/tobacco_v1_0 + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/tobacco_v1_0.pro.user.501d48d b/tobacco_v1_0.pro.user.501d48d new file mode 100644 index 0000000..25ae13a --- /dev/null +++ b/tobacco_v1_0.pro.user.501d48d @@ -0,0 +1,216 @@ + + + + + + EnvironmentId + {501d48d5-9987-478d-af86-7722c8e8d808} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + 桌面 + 桌面 + {12453195-ba84-48d3-aaa4-8461ede8ab5c} + 0 + 0 + 0 + + /home/lzy/2022.6.14/tobacco_v1_0 + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 1 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + 在本地部署 + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + tobacco_v1_0 + tobacco_v1_02 + Qt4ProjectManager.Qt4RunConfiguration:/home/lzy/2022.8.1/tobacco_v1_0/tobacco_v1_0.pro + true + + tobacco_v1_0.pro + false + + /home/lzy/2022.6.14/tobacco_v1_0 + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/tobacco_v1_0.pro.user.9db08b5 b/tobacco_v1_0.pro.user.9db08b5 new file mode 100644 index 0000000..227f286 --- /dev/null +++ b/tobacco_v1_0.pro.user.9db08b5 @@ -0,0 +1,216 @@ + + + + + + EnvironmentId + {9db08b5e-f7e3-4ec9-8b00-e647974b4cff} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {c3ee8908-68b5-4ade-bc91-1c663943909c} + 0 + 0 + 0 + + /home/chenglei/Documents/Tobacco_project/2022.8.9_restart/tobacco_v1_0 + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 1 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + 在本地部署 + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + tobacco_v1_0 + tobacco_v1_02 + Qt4ProjectManager.Qt4RunConfiguration:/home/chenglei/Documents/Tobacco_project/2022.8.20/2022.8.14/tobacco_v1_0/tobacco_v1_0.pro + true + + tobacco_v1_0.pro + false + + /home/chenglei/Documents/Tobacco_project/2022.8.9_restart/tobacco_v1_0 + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/tobacco_v1_0.pro.user.cfde348 b/tobacco_v1_0.pro.user.cfde348 new file mode 100644 index 0000000..4bf81d2 --- /dev/null +++ b/tobacco_v1_0.pro.user.cfde348 @@ -0,0 +1,216 @@ + + + + + + EnvironmentId + {cfde348c-c666-4b94-a936-53deb6e48232} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {e3fa18b5-f763-4038-947c-caf36c58ed7b} + 0 + 0 + 0 + + /home/nvidia/tobacco_v1_0 + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 1 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + tobacco_v1_0 + + Qt4ProjectManager.Qt4RunConfiguration:/home/nvidia/tobacco_v1_0/tobacco_v1_0.pro + true + + tobacco_v1_0.pro + false + + /home/nvidia/tobacco_v1_0 + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/white b/white new file mode 100644 index 0000000..e8111f9 Binary files /dev/null and b/white differ diff --git a/widget.cpp b/widget.cpp new file mode 100644 index 0000000..4182a97 --- /dev/null +++ b/widget.cpp @@ -0,0 +1,1537 @@ +#include "widget.h" +#include "ui_widget.h" +#include "camera.h" +#include "QDebug" +#include +#include +#include +#include +#include "fcntl.h" +#include "unistd.h" + +#define parameter_file "./parameter" +#define log_file "./log" +#define sys_file "./sys_parameter" + +#define LONG_SEND 100 + +extern Camera* camera; +extern RGB_Camera* rgb_camera; +int file_encoder; +int file_delay; +int file_delay_rgb; +int file_valve; +int file_threshold; +int file_threshold_rgb; +string file_mroi; +string file_valid; + +int file_padding; + +modbus_t* plc; + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + + /*--- set spinbox ---*/ + set_spinbox_range(); + + /*--- ui init ---*/ + set_ui(true); + + /*--- connect to plc, open power ---*/ + int s = connect_modbus(); + if(s == 0) + ui->lab_plc_isconnect->setStyleSheet("QLabel{background-color: rgb(0, 255, 0);}"); + + /*--- client socket to monitor ---*/ + connect_monitor(); + + /*--- server socket to guo ---*/ + server_to_lowermachine = new QTcpServer(); + server_to_lowermachine->listen(QHostAddress::Any, 13452); + //---------------------------- + + /*--- load parameter document ---*/ + load_parameter_doc(); + + /*--- load system parameter ---*/ + parameter = new Parameter(); + load_system_parameter(); + + /*--- camera init ---*/ + camera = new Camera(); + rgb_camera = new RGB_Camera(); + + /* thread init */ + send_thread = new SendThread(); +// save_thread = new SaveThread(); + + cout << " welcome dk ! " << endl; + int res = 0; + res = camera->init_camera(); + while(res != 0) + { + static int cnt_1 = 0; + cnt_1++; + if(cnt_1 == 5) + { + cout << "camera init failed for 5 times!" << endl; + break; + } + cout << "*** init camera error, error code: " << res << " ***" << endl; + cout << ">>> try to init camera again... >>>" << endl; + res = camera->init_camera(); + } + if(res == 0) + { + if(camera->init_calibration_load() == 0) + ui->lab_info->setText("校正已完成"); + ui->lab_spec_isconnect->setStyleSheet("QLabel{background-color:rgb(0, 255, 0);}"); + } + + res = rgb_camera->init_camera(); + while(res != 0) + { + static int cnt_2 = 0; + cnt_2++; + if(cnt_2 == 3) + { + cout << "camera init failed for 3 times!" << endl; + break; + } + cout << "*** init rgb_camera error, error code: " << res << " ***" << endl; + cout << ">>> try to init rgb_camera again... >>>" << endl; + res = rgb_camera->init_camera(); + } + if(res == 0) + ui->lab_rgb_isconnect->setStyleSheet("QLabel{background-color:rgb(0, 255, 0);}"); + +// time_log(1); + + cout << ">>> init camera successfully " << endl; + + connect_signal(); + + /* thread run */ + send_thread->start(); +// save_thread->start(); + /* everything seems to be ok ?*/ + cout << " hello dk ! " << endl; + if(up_machine != nullptr && up_machine->isWritable()) + { + uint8_t send_buf[3] = {0}; + send_buf[0] = 0xAA; + send_buf[1] = '6'; + send_buf[2] = 0xBB; + up_machine->write((const char*)send_buf, 3); + up_machine->flush(); + } +} + +Widget::~Widget() +{ +// time_log(0); + + modbus_close(plc); + modbus_free(plc); + + if( camera != nullptr ) + delete camera; + if( rgb_camera != nullptr ) + delete rgb_camera; + + if( server_to_lowermachine != nullptr ) + delete server_to_lowermachine; + if( lower_machine != nullptr ) + delete lower_machine; + if( up_machine != nullptr ) + delete up_machine; + if( send_thread != nullptr ) + delete send_thread; + if( save_thread != nullptr ) + delete save_thread; + if( ui != nullptr) + delete ui; + if( parameter != nullptr ) + delete parameter; +} + +void Widget::set_spinbox_range() +{ + ui->spinbox_explosure->setRange(0.0f, 2000.0f); + ui->spinbox_explosure->setDecimals(2); + ui->spinbox_encoder->setRange(0, 1000); + ui->spinbox_delaytime->setRange(0, 9999); + ui->spinbox_delaytime_rgb->setRange(0, 9999); + ui->spinbox_valve->setRange(0, 9999); + ui->spinbox_R->setRange(0, 500); + ui->spinbox_G->setRange(0, 500); + ui->spinbox_B->setRange(0, 500); + ui->spinBox_channel->setRange(1, 256); + ui->spinBox_channel->setWrapping(true); + ui->spinbox_threshold->setRange(1,16); + ui->spinbox_threshold->setWrapping(true); + ui->spinbox_threshold_rgb->setRange(1,16); + ui->spinbox_threshold_rgb->setWrapping(true); +} + +void Widget::set_ui(bool fullscreen) +{ + ui->tabWidget->findChildren().at(0)->hide(); + ui->tabWidget->setCurrentIndex(0); + if(fullscreen) + this->showFullScreen(); + ui->spinBox_channel->setValue(1); + ui->btn_stop->setEnabled(false); + ui->btn_save_disenable->setEnabled(false); + ui->btn_capture->setEnabled(false); + ui->btn_close_conveyor->setEnabled(false); + ui->btn_close_lamp->setEnabled(false); +} + +void Widget::connect_monitor() +{ + up_machine = new QTcpSocket(); + up_machine->connectToHost("192.168.11.4", 9001); + uint8_t cnt = 0; + while(!up_machine->waitForConnected(-1)) + { + if(cnt == 1) + { + delete up_machine; +// up_machine = nullptr; + return; + } + cout << ">>> trying to connect monitor again... >>>" << endl; + up_machine->connectToHost("192.168.10.4", 9001); + sleep(1); + cnt++; + } + + cout << ">>> connect to monitor successfully! >>> " << endl; + connect(up_machine, SIGNAL(readyRead()), this, SLOT(readfrom_up_machine())); + ui->lab_upmachine_isconnect_2->setStyleSheet("QLabel{background-color:rgb(0, 255, 0);}"); +} + +void Widget::load_parameter_doc() +{ + ifstream fin; + fin.open(parameter_file); + string str; + vector config; + while(getline(fin, str)) + config.push_back(str); + + /* 1.曝光时间 + * 2.分频系数 + * 3.延时时间 + * 4.rgb延时时间 + * 5.喷阀分频系数 + * 6.MROI + * 789.RGB + * 10.有效谱段 + * 11.threshold_for_model + * 12.threshold_rgb + * 13.padding + */ + file_explosure = atof(config[0].c_str()); + file_encoder = atoi(config[1].c_str()); + file_delay = atoi(config[2].c_str()); + file_delay_rgb = atoi(config[3].c_str()); + file_valve = atoi(config[4].c_str()); + file_mroi = config[5]; + R = atoi(config[6].c_str()); + G = atoi(config[7].c_str()); + B = atoi(config[8].c_str()); + file_valid = config[9]; + file_threshold = atoi(config[10].c_str()); + file_threshold_rgb = atoi(config[11].c_str()); + file_padding = atoi(config[12].c_str()); + + ui->lineEdit_MROI->setText(QString::fromStdString(file_mroi)); + ui->lineEdit_VALID->setText(QString::fromStdString(file_valid)); + + const char* s = file_mroi.c_str(); + char* p; + + p = strtok((char*)s, ","); + do + { + mroi.push_back(atoi(p)); + p = strtok(NULL, ","); + }while(p); + + s = file_valid.c_str(); + p = strtok((char*)s, ","); + do + { + valid.push_back(atoi(p)); + p = strtok(NULL, ","); + }while(p); + + ui->spinbox_explosure->setValue(file_explosure); + ui->spinbox_delaytime->setValue(file_delay); + ui->spinbox_delaytime_rgb->setValue(file_delay_rgb); + ui->spinbox_encoder->setValue(file_encoder); + ui->spinbox_valve->setValue(file_valve); + ui->spinbox_R->setValue(R); + ui->spinbox_G->setValue(G); + ui->spinbox_B->setValue(B); + ui->spinbox_threshold->setValue(file_threshold); + ui->spinbox_threshold_rgb->setValue(file_threshold_rgb); + ui->spinbox_padding->setValue(file_padding); +} + +void Widget::load_system_parameter() +{ + ifstream fin; + string str_tmp; + /*sys_file存储形式 + 1.光源时长 + 2.密码 + */ + fin.open(sys_file); + int index = 0; + while(getline(fin, str_tmp)){ + parameter->file_info[index] = str_tmp; + ++index; + } + fin.close(); + parameter->lamp_used_time = std::stol(parameter->file_info[0]); + parameter->current_time = QDateTime::currentDateTime(); + + cout << ">>> load system parameter successfully! >>> " << endl; +} + +void Widget::connect_signal() +{ + connect(ui->btn_goto_sort, &QPushButton::clicked, this, + [=]() + { + ui->tabWidget->setCurrentIndex(1); + } + ); + connect(ui->btn_3to0, &QPushButton::clicked, this, + [=](){ui->tabWidget->setCurrentIndex(0);} + ); + + connect(ui->btn_start, SIGNAL(clicked()), this, SLOT(On_btn_start_clicked())); + connect(ui->btn_stop, SIGNAL(clicked()), this, SLOT(On_btn_stop_clicked())); + connect(ui->btn_1to0, &QPushButton::clicked, this, + [=](){ui->tabWidget->setCurrentIndex(0);} + ); + connect(ui->btn_0to3, &QPushButton::clicked, this, + [=](){ui->tabWidget->setCurrentIndex(3);} + ); + + connect(ui->btn_black, SIGNAL(clicked()), this, SLOT(On_btn_black_clicked())); + connect(ui->btn_white, SIGNAL(clicked()), this, SLOT(On_btn_white_clicked())); + connect(ui->btn_1to2, &QPushButton::clicked, this, + [=](){ui->tabWidget->setCurrentIndex(4);} + ); + connect(ui->btn_2to1, &QPushButton::clicked, this, + [=](){ui->tabWidget->setCurrentIndex(1);} + ); + + connect(ui->btn_exit, &QPushButton::clicked, this, + [=]() + { + if(up_machine != nullptr && up_machine->isWritable()) + { + uint8_t send_buf[3] = {0}; + send_buf[0] = 0xAA; + send_buf[1] = '4'; + send_buf[2] = 0xBB; + up_machine->write((const char*)send_buf, 3); + up_machine->flush(); + } + if(lower_machine != nullptr) + lower_machine->close(); + sleep(1); + system("poweroff"); + } + ); + + connect(ui->btn_load_calibration, SIGNAL(clicked()), camera, SLOT(load_calibration())); + connect(ui->btn_capture, SIGNAL(clicked()), this, SLOT(On_btn_capture_clicked())); + + connect(camera, SIGNAL(send_data_to_ui(uint8_t*)), this, SLOT(get_data(uint8_t*))); + connect(rgb_camera, SIGNAL(send_rgbdata_to_ui(uint8_t*)), this, SLOT(get_rgb_data(uint8_t*))); + connect(send_thread, SIGNAL(send_mask(char*)), this, SLOT(get_mask(char*))); + connect(send_thread, SIGNAL(send_mask_rgb(char*)), this, SLOT(get_mask_rgb(char*))); + + connect(camera, &Camera::send_calibration_finished_message, this, + [=]() + { + cout << "fsdfsd" << endl; + QMessageBox::information(this, "提示", "load success!"); + ui->lab_info->setText("加载校正文件成功"); + } + ); + + connect(server_to_lowermachine, &QTcpServer::newConnection, this, + [=]() + { + cout << "new connection to lower machine!" << endl; + lower_machine = server_to_lowermachine->nextPendingConnection(); + ui->lab_lowermachine_isconnect->setStyleSheet("QLabel{background-color:rgb(0, 255, 0);}"); + connect(lower_machine, SIGNAL(readyRead()), this, SLOT(readfrom_lower_machine())); + } + ); + connect(send_thread, SIGNAL(send_valve_data(uint8_t*)), this, SLOT(get_valve_data(uint8_t*))); +// connect(send_thread, SIGNAL(send_to_up_machine(float*)), this, SLOT(get_send_to_up_machine(float*))); +// connect(up_machine, SIGNAL(readyRead()), this, SLOT(readfrom_up_machine())); + connect(ui->btn_send_single, SIGNAL(clicked()), this, SLOT(On_btn_sendsingle_clicked())); +// connect(ui->btn_autosend, SIGNAL(clicked()), this, SLOT(On_btn_autosend_clicked())); + connect(ui->btn_threshold_ok, SIGNAL(clicked()), this, SLOT(On_btn_threshold_clicked())); + //2022.8.8 +// connect(lower_machine, SIGNAL(readyRead()), this, SLOT(readfrom_lower_machine())); + +} + +void Widget::send_after_start() +{ + QString delay_time = QString::fromStdString((to_string(file_delay))); + if(delay_time.size() == 0) + return; +// QString delay_time_rgb = QString::fromStdString((to_string(file_delay_rgb))); +// if(delay_time_rgb.size() == 0) +// return; + QString divide_parameter = QString::fromStdString((to_string(file_encoder))); + if(divide_parameter.size() == 0) + return; + QString sv_parameter = QString::fromStdString((to_string(file_valve))); + if(sv_parameter.size() == 0) + return; + int len_delay = delay_time.size(); +// int len_delay_rgb = delay_time_rgb.size(); + int len_divide = divide_parameter.size(); + int len_sv = sv_parameter.size(); + QByteArray delay_byte = delay_time.toLatin1(); +// QByteArray delay_byte_rgb = delay_time_rgb.toLatin1(); + QByteArray divide_byte = divide_parameter.toLatin1(); + QByteArray sv_byte = sv_parameter.toLatin1(); + + uint8_t* delay_buf = new uint8_t[len_delay + 8]; + delay_buf[0] = 0xAA; + delay_buf[1] = 0x00; + delay_buf[2] = len_delay + 2; + delay_buf[3] = 's'; + delay_buf[4] = 'a'; + memcpy(delay_buf + 5, delay_byte.data(), len_delay); + delay_buf[len_delay + 5] = 0xFF; + delay_buf[len_delay + 6] = 0xFF; + delay_buf[len_delay + 7] = 0xBB; + if(lower_machine->isWritable()) + lower_machine->write((const char*)delay_buf, len_delay+8); + delete [] delay_buf; + +// uint8_t* delay_rgb_buf = new uint8_t[len_delay_rgb + 8]; +// delay_rgb_buf[0] = 0xAA; +// delay_rgb_buf[1] = 0x00; +// delay_rgb_buf[2] = len_delay_rgb + 2; +// delay_rgb_buf[3] = 's'; +// delay_rgb_buf[4] = 'b'; +// memcpy(delay_rgb_buf + 5, delay_byte_rgb.data(), len_delay_rgb); +// delay_rgb_buf[len_delay_rgb + 5] = 0xFF; +// delay_rgb_buf[len_delay_rgb + 6] = 0xFF; +// delay_rgb_buf[len_delay_rgb + 7] = 0xBB; +// if(lower_machine->isWritable()) +// lower_machine->write((const char*)delay_rgb_buf, len_delay_rgb+8); +// delete [] delay_rgb_buf; + + uint8_t* divide_buf = new uint8_t[len_divide + 8]; + divide_buf[0] = 0xAA; + divide_buf[1] = 0x00; + divide_buf[2] = len_divide + 2; + divide_buf[3] = 's'; + divide_buf[4] = 'c'; + memcpy(divide_buf + 5, divide_byte.data(), len_divide); + divide_buf[len_divide + 5] = 0xFF; + divide_buf[len_divide + 6] = 0xFF; + divide_buf[len_divide + 7] = 0xBB; + if(lower_machine->isWritable()) + lower_machine->write((const char*)divide_buf, len_divide+8); + delete [] divide_buf; + + uint8_t* valve_divide_buf = new uint8_t[len_sv + 8]; + valve_divide_buf[0] = 0xAA; + valve_divide_buf[1] = 0x00; + valve_divide_buf[2] = len_sv + 2; + valve_divide_buf[3] = 's'; + valve_divide_buf[4] = 'v'; + memcpy(valve_divide_buf + 5, sv_byte.data(), len_sv); + valve_divide_buf[len_sv + 5] = 0xFF; + valve_divide_buf[len_sv + 6] = 0xFF; + valve_divide_buf[len_sv + 7] = 0xBB; + if(lower_machine->isWritable()) + lower_machine->write((const char*)valve_divide_buf, 12); + delete [] valve_divide_buf; + + uint8_t start_command[9] = {0}; + start_command[0] = 0xAA; + start_command[1] = 0x00; + start_command[2] = 0x03; + start_command[3] = 's'; + start_command[4] = 't'; + start_command[5] = 0xFF; + start_command[6] = 0xFF; + start_command[7] = 0xFF; + start_command[8] = 0xBB; + if(lower_machine != nullptr && lower_machine->isWritable()) + lower_machine->write((const char*)start_command, 9); +} + +void Widget::On_btn_start_clicked() +{ + ui->btn_stop->setEnabled(true); + ui->btn_start->setEnabled(false); + ui->btn_black->setEnabled(false); + ui->btn_rgb_black->setEnabled(false); + ui->btn_white->setEnabled(false); + ui->btn_rgb_white->setEnabled(false); + + qApp->processEvents(); + + //设置触发模式为 外触发,线路Line0,上升沿触发 + PvResult lResult; + lResult = camera->parameter_array->SetEnumValue("TriggerMode", "On"); + if ( !lResult.IsOK() ) + { + cout << "*** Set Internal TriggerMode Failed! *** " << endl; + return; + } + lResult = camera->parameter_array->SetEnumValue("TriggerSource", "Line0"); + if ( !lResult.IsOK() ) + { + cout << "*** Set Internal TriggerSource Failed! *** " << endl; + return; + } + + lResult = rgb_camera->parameter_array->SetEnumValue("LineTriggerMode", "On"); + if(!lResult.IsOK()){ + cout << "set triggermode failed" << endl; + return; + } + + lResult = rgb_camera->parameter_array->SetEnumValue("LineTriggerSource", "Line2"); + if(!lResult.IsOK()){ + cout << "set triggersource failed" << endl; + return; + } + + //plc + plc_auto_start(); + + /*记录时长开始*/ + parameter->lamp_timer.start(); + + camera->register_callback_acquisition(); + + camera->start_acquisition(); + + rgb_camera->start_acquisition(); + + ui->lab_info->setText("开始"); + cout << ">>> start acquisition >>>" << endl; + ui->btn_1to2->setEnabled(false); + //send to lower_machine + if(lower_machine != nullptr && lower_machine->isWritable()) + send_after_start(); + is_running = true; + if(up_machine != nullptr && up_machine->isWritable()) + { + uint8_t send_buf[3] = {0}; + send_buf[0] = 0xAA; + send_buf[1] = '1'; + send_buf[2] = 0xBB; + up_machine->write((const char*)send_buf, 3); + up_machine->flush(); + } +// camera->get_camera_parameters(); +} + +void Widget::On_btn_stop_clicked() +{ + camera->stop_acquisition(); + rgb_camera->stop_acquisition(); + + uint8_t stop_command[9] = {0}; + stop_command[0] = 0xAA; + stop_command[1] = 0x00; + stop_command[2] = 0x03; + stop_command[3] = 's'; + stop_command[4] = 'p'; + stop_command[5] = 0xFF; + stop_command[6] = 0xFF; + stop_command[7] = 0xFF; + stop_command[8] = 0xBB; + if(lower_machine != nullptr && lower_machine->isWritable()) + { + lower_machine->write((const char*)stop_command, 9); + lower_machine->flush(); + } + is_running = false; + if(up_machine != nullptr && up_machine->isWritable()) + { + uint8_t send_buf[3] = {0}; + send_buf[0] = 0xAA; + send_buf[1] = '2'; + send_buf[2] = 0xBB; + up_machine->write((const char*)send_buf, 3); + up_machine->flush(); + } + + plc_auto_stop(); + + /*停止计时器记录时长*/ + uint32_t time_elapsed = parameter->lamp_timer.elapsed() / 1000; + parameter->lamp_used_time += time_elapsed; + + camera->unregister_data_callback(); + ui->lab_info->setText("停止"); + cout << ">>> stop acquisition >>>" << endl; + ui->btn_1to2->setEnabled(true); + + parameter->file_info[0] = to_string(parameter->lamp_used_time); + ofstream fout; + fout.open(sys_file, ios::out | ios::trunc); + for(auto s : parameter->file_info) + fout << s << endl; + fout.close(); +// cout << "used time: " << parameter->file_info[0] << endl; + ui->btn_start->setEnabled(true); + ui->btn_stop->setEnabled(false); + ui->btn_black->setEnabled(true); + ui->btn_rgb_black->setEnabled(true); + ui->btn_white->setEnabled(true); + ui->btn_rgb_white->setEnabled(true); +} + + +void Widget::On_btn_black_clicked() +{ + //更改触发模式并设置行频 + PvResult lResult; + lResult = camera->parameter_array->SetEnumValue("TriggerMode", "Off"); + if ( !lResult.IsOK() ) + { + cout << "*** Set Internal TriggerMode Failed! *** " << endl; + return; + } + lResult = camera->parameter_array->SetFloatValue("AcquisitionFrameRate", 100.0); + if ( !lResult.IsOK() ) + { + cout << "*** Unable to set *** " << endl; + return; + } + ui->lab_info->setText("正在校正..."); + qApp->processEvents(); + + camera->register_callback_calibration(); + camera->capture_black_flag = true; + camera->start_acquisition(); + ui->lab_info->setText("校正完成"); +} + +void Widget::On_btn_white_clicked() +{ + //更改触发模式并设置行频 + PvResult lResult; + lResult = camera->parameter_array->SetEnumValue("TriggerMode", "Off"); + if ( !lResult.IsOK() ) + { + cout << "*** Set Internal TriggerMode Failed! *** " << endl; + return; + } + lResult = camera->parameter_array->SetFloatValue("AcquisitionFrameRate", 100.0); + if ( !lResult.IsOK() ) + { + cout << "*** Unable to set *** " << endl; + return; + } + ui->lab_info->setText("正在校正..."); + qApp->processEvents(); + + camera->register_callback_calibration(); + camera->capture_white_flag = true; + camera->start_acquisition(); + ui->lab_info->setText("校正完成"); +} + +void Widget::On_btn_capture_clicked() +{ + save_thread->save_flag.release(1); +} + +void Widget::get_data(uint8_t *buff) +{ + img = cv::Mat(SPEC_HEIGHT, SPEC_WIDTH, CV_16UC3, buff); + img.convertTo(img, CV_32FC3); + img = img / 4095 * 255; + img.convertTo(img, CV_8UC3); + +// const unsigned char *pSrc = (const unsigned char*)img.data; +// QImage image(pSrc, img.cols, img.rows, img.step, QImage::Format_RGB888); //三通道 +// QPixmap pix = QPixmap::fromImage(image.scaled(ui->lab_show_img->width(), ui->lab_show_img->height(), Qt::KeepAspectRatio)); +// ui->lab_show_img->setPixmap(pix); +// ui->lab_show_img->show(); +} + +void Widget::get_rgb_data(uint8_t *buff) +{ + img_rgb = cv::Mat(RGB_HEIGHT, RGB_WIDTH, CV_8UC3, buff); +} + +void Widget::get_mask(char *get_buf) +{ + //256*1024 + /*异物显示为rgb全白,再与原始图像叠加,白色像素代表异物*/ + std::vector mask_rgb; + cv::Mat mask_show = cv::Mat(SPEC_MASK_HEIGHT, SPEC_MASK_WIDTH, CV_8UC3); + cv::Mat mask = cv::Mat(SPEC_MASK_HEIGHT, SPEC_MASK_WIDTH, CV_8UC1, get_buf); + mask *= 255; + mask_rgb.push_back(mask); + mask_rgb.push_back(mask); + mask_rgb.push_back(mask); + cv::merge(mask_rgb, mask_show); + cv::resize(mask_show, mask_show, cv::Size(SPEC_WIDTH, SPEC_HEIGHT), 0, 0, cv::INTER_LINEAR); + cv::Mat add_img = cv::Mat(SPEC_HEIGHT, SPEC_WIDTH, CV_8UC3); + cv::add(img, mask_show, add_img); + + const unsigned char *pSrc_img = (const unsigned char*)add_img.data; + QImage image_img(pSrc_img, add_img.cols, add_img.rows, add_img.step, QImage::Format_RGB888); //三通道 + QPixmap pix_img = QPixmap::fromImage(image_img.scaled(ui->lab_show_img->width(), ui->lab_show_img->height(), Qt::KeepAspectRatio)); + ui->lab_show_img->setPixmap(pix_img); + ui->lab_show_img->show(); + //mask,暂时用不到了 +// const unsigned char *pSrc_mask = (const unsigned char*)mask_show.data; +// QImage image_mask(pSrc_mask, mask_show.cols, mask_show.rows, mask_show.step, QImage::Format_RGB888); +// QPixmap pix_mask = QPixmap::fromImage(image_mask.scaled(ui->lab_show_mask->width(),ui->lab_show_mask->height(),Qt::KeepAspectRatio)); +// ui->lab_show_rgb->setPixmap(pix_mask); +// ui->lab_show_rgb->show(); + + /* + //灰度图显示,白色为杂质,取消了RGB显示功能,有利于速度提升,内存减少占用 + //修改于2022年6月21日 + cv::Mat mask = cv::Mat(REALHEIGHT, REALWIDTH, CV_8UC1, get_buf); + mask *= 255; + const unsigned char *pSrc = (const unsigned char*)mask.data; + QImage image(pSrc, mask.cols, mask.rows, mask.step, QImage::Format_Grayscale8); + QPixmap pix = QPixmap::fromImage(image.scaled(ui->lab_show_mask->width(),ui->lab_show_mask->height(),Qt::KeepAspectRatio)); + ui->lab_show_mask->setPixmap(pix); + ui->lab_show_mask->show(); + */ +} + +void Widget::get_mask_rgb(char *get_buf) +{ + std::vector mask_rgb; + cv::Mat mask_show = cv::Mat(RGB_MASK_HEIGHT, RGB_MASK_WIDTH, CV_8UC3); + cv::Mat mask = cv::Mat(RGB_MASK_HEIGHT, RGB_MASK_WIDTH, CV_8UC1, get_buf); + mask *= 255; + mask_rgb.push_back(mask); + mask_rgb.push_back(mask); + mask_rgb.push_back(mask); + cv::merge(mask_rgb, mask_show); + cv::resize(mask_show, mask_show, cv::Size(RGB_WIDTH, RGB_HEIGHT), 0, 0, cv::INTER_LINEAR); + cv::Mat add_img = cv::Mat(RGB_HEIGHT, RGB_WIDTH, CV_8UC3); + cv::add(img_rgb, mask_show, add_img); + + const unsigned char *pSrc_img = (const unsigned char*)add_img.data; + QImage image_img(pSrc_img, add_img.cols, add_img.rows, add_img.step, QImage::Format_RGB888); //三通道 + QPixmap pix_img = QPixmap::fromImage(image_img.scaled(ui->lab_show_img->width(), ui->lab_show_img->height(), Qt::KeepAspectRatio)); + ui->lab_show_rgb->setPixmap(pix_img); + ui->lab_show_rgb->show(); +} + +void Widget::get_valve_data(uint8_t *valve_data) +{ + uint8_t* mask_buf = new uint8_t[32 * 1024 + 8]; + mask_buf[0] = 0xAA; + //mask_buf[1]和mask_buf[2]表示数据长度 + mask_buf[1] = 0x80; + mask_buf[2] = 0x02; + mask_buf[3] = 'd'; + mask_buf[4] = 'a'; + memcpy(mask_buf + 5, valve_data, 32*1024); + mask_buf[32*1024+5] = 0xFF; + mask_buf[32*1024+6] = 0xFF; + mask_buf[32*1024+7] = 0xBB; + + if(lower_machine != nullptr && lower_machine->state() == QAbstractSocket::ConnectedState) + { + lower_machine->write((const char*)mask_buf, 1024 * 32 + 8); + lower_machine->flush(); +// lower_machine->write((const char*)mask_buf_rgb, 1024 * 32 + 8); +// lower_machine->flush(); +// cout << ">>> send to guoyiren successfully! >>>" << endl; + } + else + { + camera->stop_acquisition(); + rgb_camera->stop_acquisition(); + //up_machine->write("111"); + cout << "*** lower machine connect failed! *** " << endl; + ui->lab_lowermachine_isconnect->setStyleSheet("QLabel{background-color: rgb(237, 212, 0);}"); + } + + delete [] mask_buf; +} + + +void Widget::get_send_to_up_machine(float* sendbuf) +{ + cout << "suuuuuuuu" << endl; + if(connect_to_monitor && send_to_up_machine) + { + cout << SPEC_HEIGHT*SPEC_WIDTH*valid.size()*sizeof(float) << endl; + uint32_t len = up_machine->write((const char*)sendbuf, SPEC_HEIGHT*SPEC_WIDTH*valid.size()*sizeof(float)); + up_machine->flush(); + cout << ">>> send img finished! >>>" << len << endl; + } +} + +void Widget::readfrom_up_machine() +{ + cout << "receive message from suhandong" << endl; + char recvbuf[4] = {0}; + up_machine->read(recvbuf, 4); + char ch = recvbuf[0]; + switch (ch) + { + //开始 + case '1': + cout << "start" << endl; + if(is_running == false) + { + ui->tabWidget->setCurrentIndex(1); + On_btn_start_clicked(); + } + break; + //停止 + case '2': + cout << "stop" << endl; + if(is_running == true) + On_btn_stop_clicked(); + break; + case '3': + cout << "lamp" << endl; + send_lamp_time_to_monitor(); + break; //灯光时长 + //关机 + case '4': + cout << "poweroff" << endl; + if(is_running == true) + { + On_btn_stop_clicked(); + } + sleep(2); + if(up_machine != nullptr && up_machine->isWritable()) + { + uint8_t send_buf[3] = {0}; + send_buf[0] = 0xAA; + send_buf[1] = '4'; + send_buf[2] = 0xBB; + up_machine->write((const char*)send_buf, 3); + up_machine->flush(); + } + system("poweroff"); + break; + default:break; + } +} + +void Widget::readfrom_lower_machine()//2022.8.8 +{ + if(is_running == false) + return; + cout << ">>> receive error >>>" << endl; + char recvbuf[8] = {0}; + int ret = lower_machine->read(recvbuf, 8); + if(ret > 0){ //收到error信息 + //执行restart操作 + restart_from_error(); + cout << ">>> restart ! >>>" << endl; + } + +} + +void Widget::On_btn_sendsingle_clicked() +{ + int val = ui->spinBox_channel->value() - 1; + QString valve_x = QString::fromStdString(to_string(val)); + int len_valve_x = valve_x.size(); + QByteArray valve_byte = valve_x.toLatin1(); + uint8_t* sendbuf = new uint8_t[len_valve_x + 8]; + sendbuf[0] = 0xAA; + sendbuf[1] = 0x00; + sendbuf[2] = len_valve_x + 2; + sendbuf[3] = 't'; + sendbuf[4] = 'e'; + memcpy(sendbuf + 5, valve_byte.data(), len_valve_x); + sendbuf[len_valve_x + 5] = 0xFF; + sendbuf[len_valve_x + 6] = 0xFF; + sendbuf[len_valve_x + 7] = 0xBB; + if(lower_machine != nullptr) + { + lower_machine->write((const char*)sendbuf, len_valve_x + 8); +// cout << "send single " << val+1 << " success" << endl; + } + delete [] sendbuf; +} + +void Widget::On_btn_autosend_clicked() +{ + uint8_t start_test[11] = {0}; + start_test[0] = 0xAA; + start_test[1] = 0x00; + start_test[2] = 0x05; + start_test[3] = 't'; + start_test[4] = 'e'; + start_test[5] = '2'; + start_test[6] = '5'; + start_test[7] = '7'; + start_test[8] = 0xFF; + start_test[9] = 0xFF; + start_test[10] = 0xBB; + if(lower_machine != nullptr) + { + lower_machine->write((const char*)start_test, 11); + cout << "send autosend success" << endl; + } +} + +void Widget::on_btn_1_clicked() +{ + parameter->password += "1"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_2_clicked() +{ + parameter->password += "2"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_3_clicked() +{ + parameter->password += "3"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_4_clicked() +{ + parameter->password += "4"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_5_clicked() +{ + parameter->password += "5"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_6_clicked() +{ + parameter->password += "6"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_7_clicked() +{ + parameter->password += "7"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_8_clicked() +{ + parameter->password += "8"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_9_clicked() +{ + parameter->password += "9"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_0_clicked() +{ + parameter->password += "0"; + int len = parameter->password.size(); + ui->line_password->setText(QString(len, '*')); +} + +void Widget::on_btn_clear_clicked() +{ + parameter->password.clear(); + ui->line_password->setText(""); +} + +void Widget::on_btn_del_clicked() +{ + int len = parameter->password.size(); + if(len > 0){ + parameter->password.pop_back(); + --len; + ui->line_password->setText(QString(len, '*')); + } +} + +void Widget::on_btn_ensure_clicked() +{ + if(parameter->password != parameter->file_info[1]){ + //密码错误 + QMessageBox::information(this, "提示", "密码错误!"); + parameter->password.clear(); + ui->line_password->setText(""); + } + else{ + //密码正确 + parameter->password.clear(); + ui->line_password->setText(""); + ui->tabWidget->setCurrentIndex(2); + ui->btn_capture->setEnabled(true); + } +} + +void Widget::on_btn_back_clicked() +{ + parameter->password.clear(); + ui->tabWidget->setCurrentIndex(0); +} + +void Widget::on_btn_send_plus_clicked() +{ + int send_val = 0; + int val = ui->spinBox_channel->value(); + send_val = val - 1; + QString valve_x = QString::fromStdString(to_string(send_val)); + int len_valve_x = valve_x.size(); + QByteArray valve_byte = valve_x.toLatin1(); + uint8_t* sendbuf = new uint8_t[len_valve_x + 8]; + sendbuf[0] = 0xAA; + sendbuf[1] = 0x00; + sendbuf[2] = len_valve_x + 2; + sendbuf[3] = 't'; + sendbuf[4] = 'e'; + memcpy(sendbuf + 5, valve_byte.data(), len_valve_x); + sendbuf[len_valve_x + 5] = 0xFF; + sendbuf[len_valve_x + 6] = 0xFF; + sendbuf[len_valve_x + 7] = 0xBB; + if(lower_machine != nullptr) + { + lower_machine->write((const char*)sendbuf, len_valve_x + 8); +// cout << "send single " << val << " success" << endl; + } + val += 1; + if(val == 257) + val = 1; + ui->spinBox_channel->setValue(val); + delete [] sendbuf; +} + +void Widget::on_btn_send_min_clicked() +{ + int send_val = 0; + int val = ui->spinBox_channel->value(); + send_val = val - 1; + QString valve_x = QString::fromStdString(to_string(send_val)); + int len_valve_x = valve_x.size(); + QByteArray valve_byte = valve_x.toLatin1(); + uint8_t* sendbuf = new uint8_t[len_valve_x + 8]; + sendbuf[0] = 0xAA; + sendbuf[1] = 0x00; + sendbuf[2] = len_valve_x + 2; + sendbuf[3] = 't'; + sendbuf[4] = 'e'; + memcpy(sendbuf + 5, valve_byte.data(), len_valve_x); + sendbuf[len_valve_x + 5] = 0xFF; + sendbuf[len_valve_x + 6] = 0xFF; + sendbuf[len_valve_x + 7] = 0xBB; + if(lower_machine != nullptr) + { + lower_machine->write((const char*)sendbuf, len_valve_x + 8); + cout << "send single " << val << " success" << endl; + } + val -= 1; + if(val == 0) + val = 256; + ui->spinBox_channel->setValue(val); + delete [] sendbuf; +} + +void Widget::time_log(int state) +{ + ofstream logfile; + logfile.open(log_file, ios::app); + QDateTime current_time = QDateTime::currentDateTime(); + string str = current_time.toString("yyyy MM.dd hh:mm:ss").toStdString(); + if(state == 1) + logfile << str << " On" << endl; + else + logfile << str << " Off" << endl; + logfile.close(); +} + +void Widget::send_lamp_time_to_monitor() +{ + uint8_t send_buf[6] = {0}; + send_buf[0] = 0xAA; + memcpy(send_buf+1, (uint8_t*)¶meter->lamp_used_time, 4); + send_buf[5] = 0xBB; + if(up_machine != nullptr) + { + up_machine->write((const char*)send_buf, 6); + up_machine->flush(); + cout << "send lamp" << endl; + } +} + +void Widget::On_btn_threshold_clicked() +{ + file_threshold = ui->spinbox_threshold->value(); + int fd = open("/tmp/dkimg.fifo", O_WRONLY); + string str = to_string(file_threshold); + int ret = write(fd, str.c_str(), str.size()); + if(ret > 0) + cout << "threshold send success " << file_threshold << endl; + + file_threshold_rgb = ui->spinbox_threshold_rgb->value(); + fd = open("/tmp/dkrgb.fifo", O_WRONLY); + str = to_string(file_threshold_rgb); + ret = write(fd, str.c_str(), str.size()); + if(ret > 0) + cout << "threshold send success " << file_threshold_rgb << endl; + +} + +void Widget::on_btn_set_lower_clicked() +{ + file_delay = ui->spinbox_delaytime->value(); + file_delay_rgb = ui->spinbox_delaytime_rgb->value(); + file_encoder = ui->spinbox_encoder->value(); + file_valve = ui->spinbox_valve->value(); + file_padding = ui->spinbox_padding->value(); +} + +void Widget::on_btn_set_camera_clicked() +{ + file_explosure = ui->spinbox_explosure->value(); + file_delay = ui->spinbox_delaytime->value(); + file_delay_rgb = ui->spinbox_delaytime_rgb->value(); + file_encoder = ui->spinbox_encoder->value(); + file_valve = ui->spinbox_valve->value(); + file_mroi = ui->lineEdit_MROI->text().toStdString(); + file_valid = ui->lineEdit_VALID->text().toStdString(); + R = ui->spinbox_R->value(); + G = ui->spinbox_G->value(); + B = ui->spinbox_B->value(); + file_threshold = ui->spinbox_threshold->value(); + file_threshold_rgb = ui->spinbox_threshold_rgb->value(); + file_padding = ui->spinbox_padding->value(); + +} + +void Widget::on_btn_set_clicked() +{ + //保存配置文件至本地 + file_explosure = ui->spinbox_explosure->value(); + file_encoder = ui->spinbox_encoder->value(); + file_delay = ui->spinbox_delaytime->value(); + file_delay_rgb = ui->spinbox_delaytime_rgb->value(); + file_valve = ui->spinbox_valve->value(); + file_mroi = ui->lineEdit_MROI->text().toStdString(); + file_valid = ui->lineEdit_VALID->text().toStdString(); + R = ui->spinbox_R->value(); + G = ui->spinbox_G->value(); + B = ui->spinbox_B->value(); + file_threshold = ui->spinbox_threshold->value(); + file_threshold_rgb = ui->spinbox_threshold_rgb->value(); + file_padding = ui->spinbox_padding->value(); + + vector config; + config.push_back(to_string(file_explosure)); + config.push_back(to_string(file_encoder)); + config.push_back(to_string(file_delay)); + config.push_back(to_string(file_delay_rgb)); + config.push_back(to_string(file_valve)); + config.push_back(file_mroi); + config.push_back(to_string(R)); + config.push_back(to_string(G)); + config.push_back(to_string(B)); + config.push_back(file_valid); + config.push_back(to_string(file_threshold)); + config.push_back(to_string(file_threshold_rgb)); + config.push_back(to_string(file_padding)); + + ofstream outfile; + outfile.open(parameter_file, ios::out | ios::trunc); + for(auto s : config) + outfile << s << endl; +} + +void Widget::on_btn_rgb_white_clicked() +{ + //设置触发模式为 内触发 + ui->lab_info->setText("正在校正..."); + ui->btn_rgb_black->setEnabled(false); + ui->btn_rgb_white->setEnabled(false); + qApp->processEvents(); + PvResult lResult = rgb_camera->parameter_array->SetEnumValue("LineTriggerMode", "Off"); + if(!lResult.IsOK()){ + cout << "set triggermode failed" << endl; + return; + } + lResult = rgb_camera->parameter_array->SetFloatValue("AcquisitionLineRate", 4800.0f); + + lResult = rgb_camera->Whitecal->Execute(); + sleep(6); + rgb_camera->lFFCUserSetSave->Execute(); + + lResult = rgb_camera->parameter_array->SetEnumValue("LineTriggerMode", "On"); + lResult = rgb_camera->parameter_array->SetEnumValue("LineTriggerSource", "Line2"); + rgb_camera->lUserSave->Execute(); + + ui->btn_rgb_black->setEnabled(true); + ui->btn_rgb_white->setEnabled(true); + ui->lab_info->setText("校正完成"); +} + +void Widget::on_btn_rgb_black_clicked() +{ + cout << "rgb_black" << endl; + ui->btn_rgb_black->setEnabled(false); + ui->btn_rgb_white->setEnabled(false); + //设置触发模式为 外触发,线路Line0,上升沿触发 + PvResult lResult = rgb_camera->parameter_array->SetEnumValue("LineTriggerMode", "Off"); + if(!lResult.IsOK()){ + cout << "set triggermode failed" << endl; + return; + } + lResult = rgb_camera->parameter_array->SetFloatValue("AcquisitionLineRate", 4800.0f); + + lResult = rgb_camera->Blackcal->Execute(); + sleep(6); + ui->btn_rgb_black->setEnabled(true); + ui->btn_rgb_white->setEnabled(true); +} + +void Widget::on_btn_save_enable_clicked() +{ + send_thread->save_flag = true; + ui->btn_save_enable->setEnabled(false); + ui->btn_save_disenable->setEnabled(true); +} + +void Widget::on_btn_save_disenable_clicked() +{ + send_thread->save_flag = false; + ui->btn_save_enable->setEnabled(true); + ui->btn_save_disenable->setEnabled(false); +} + +void Widget::restart_from_error()//2022.8.8 +{ + //停止相机采图 + camera->stop_acquisition(); + rgb_camera->stop_acquisition(); + //给下位机发送停止命令 + uint8_t stop_command[9] = {0}; + stop_command[0] = 0xAA; + stop_command[1] = 0x00; + stop_command[2] = 0x03; + stop_command[3] = 's'; + stop_command[4] = 'p'; + stop_command[5] = 0xFF; + stop_command[6] = 0xFF; + stop_command[7] = 0xFF; + stop_command[8] = 0xBB; + if(lower_machine != nullptr && lower_machine->isWritable()) + { + lower_machine->write((const char*)stop_command, 9); + lower_machine->flush(); + } + is_running = false; + //延时1s + sleep(1); + //开始相机采集 + camera->start_acquisition(); + rgb_camera->start_acquisition(); + + if(lower_machine != nullptr && lower_machine->isWritable()) + send_after_start(); + is_running = true; + cout << "restart success" << endl; +} + +int Widget::connect_modbus() +{ + int status = 0; + plc = modbus_new_rtu("/dev/ttyS0", 9600, 'N', 8, 1); + modbus_set_slave(plc, 16); //设置modbus从机地址 + status = modbus_connect(plc); + if(status == -1) + { + cout << "modbus connect failed" << endl; + return -1; + } + modbus_set_response_timeout(plc, 0, 1000000); + cout << "connect plc success" << endl; + + return 0; +} + +int Widget::plc_command(int times, int coil_addr, int status) +{ + int ret; + while (times--) + { + ret = modbus_write_bit(plc, coil_addr, status); + if(ret == 1) + return 0; + } + + cout << "write plc failed" << endl; + return -1; + +} + +int Widget::plc_open_power() +{ + int state; + state = plc_command(1, MODE_SET_ADDR, 0); //自动模式 + state = plc_command(1, POWER_AUTO_ADDR, 1); + if(state != 0){ + cout << "open power failed" << endl; + return -1; + } + return 0; +} + +int Widget::plc_close_power() +{ + int state; + state = plc_command(1, MODE_SET_ADDR, 0); //自动模式 + state = plc_command(1, POWER_AUTO_ADDR, 0); + if(state != 0){ + cout << "close power failed" << endl; + return -1; + } + return 0; +} + +void Widget::on_btn_open_conveyor_clicked() +{ + int state; + state = plc_command(3, MODE_SET_ADDR, 1); //手动模式 + sleep(1); + state = plc_command(3, BRUSH_ADDR, 1); + state = plc_command(3, CONVEYOR_ADDR, 1); + + ui->btn_open_conveyor->setEnabled(false); + ui->btn_close_conveyor->setEnabled(true); +} + +void Widget::on_btn_close_conveyor_clicked() +{ + int state; + state = plc_command(3, MODE_SET_ADDR, 1); //手动模式 + sleep(1); + state = plc_command(3, BRUSH_ADDR, 0); + state = plc_command(3, CONVEYOR_ADDR, 0); + + ui->btn_open_conveyor->setEnabled(true); + ui->btn_close_conveyor->setEnabled(false); +} + +void Widget::on_btn_open_lamp_clicked() +{ + int state; + state = plc_command(3, MODE_SET_ADDR, 1); //手动模式 + sleep(1); + state = plc_command(3, DRAUGHT_FAN_ADDR, 1); + state = plc_command(3, LAMP_FORCE, 1); + + ui->btn_open_lamp->setEnabled(false); + ui->btn_close_lamp->setEnabled(true); +} + +void Widget::on_btn_close_lamp_clicked() +{ + int state; + state = plc_command(3, MODE_SET_ADDR, 1); //手动模式 + sleep(1); + state = plc_command(3, DRAUGHT_FAN_ADDR, 0); + state = plc_command(3, LAMP_FORCE, 0); + + ui->btn_open_lamp->setEnabled(true); + ui->btn_close_lamp->setEnabled(false); +} + +int Widget::plc_auto_start() +{ + int state; + state = plc_command(3, MODE_SET_ADDR, 0); //自动模式 + sleep(1); + state = plc_command(3, BRUSH_AUTO_ADDR, 1); + state = plc_command(3, DRAUGHT_FAN_AUTO_ADDR, 1); + state = plc_command(3, CONVEYOR_AUTO_ADDR, 1); + sleep(2); + state = plc_command(3, LAMP_AUTO_ADDR, 1); + sleep(2); + ui->btn_open_lamp->setEnabled(false); + ui->btn_close_lamp->setEnabled(true); + ui->btn_open_conveyor->setEnabled(false); + ui->btn_close_conveyor->setEnabled(true); + return 0; +} + +int Widget::plc_auto_stop() +{ + int state; + state = plc_command(3, MODE_SET_ADDR, 0); //自动模式 + sleep(1); + state = plc_command(3, BRUSH_AUTO_ADDR, 0); + state = plc_command(3, DRAUGHT_FAN_AUTO_ADDR, 0); + state = plc_command(3, CONVEYOR_AUTO_ADDR, 0); + state = plc_command(3, LAMP_AUTO_ADDR, 0); + ui->btn_open_lamp->setEnabled(true); + ui->btn_close_lamp->setEnabled(false); + ui->btn_open_conveyor->setEnabled(true); + ui->btn_close_conveyor->setEnabled(false); + return 0; +} + +void Widget::on_btn_exit_2_clicked() +{ + if(up_machine != nullptr && up_machine->isWritable()) + { + uint8_t send_buf[3] = {0}; + send_buf[0] = 0xAA; + send_buf[1] = '4'; + send_buf[2] = 0xBB; + up_machine->write((const char*)send_buf, 3); + up_machine->flush(); + } + if(lower_machine != nullptr) + lower_machine->close(); + sleep(1); + system("reboot"); +} + +void Widget::on_btn_0to3_2_clicked() +{ + up_machine = new QTcpSocket(); + up_machine->connectToHost("192.168.11.4", 9001); + if(up_machine->waitForConnected(1000)) + { + cout << ">>> connect to monitor successfully! >>> " << endl; + connect(up_machine, SIGNAL(readyRead()), this, SLOT(readfrom_up_machine())); + ui->lab_upmachine_isconnect_2->setStyleSheet("QLabel{background-color:rgb(0, 255, 0);}"); + if(up_machine != nullptr && up_machine->isWritable()) + { + uint8_t send_buf[3] = {0}; + send_buf[0] = 0xAA; + send_buf[1] = '7'; //重新连接 + send_buf[2] = 0xBB; + up_machine->write((const char*)send_buf, 3); + up_machine->flush(); + } + } + else + { + cout << "connect to monitor failed" << endl; + delete up_machine; + } +} + +void Widget::on_btn_send_single_long_clicked() +{ + int val = ui->spinBox_channel->value() - 1; + QString valve_x = QString::fromStdString(to_string(val)); + int len_valve_x = valve_x.size(); + QByteArray valve_byte = valve_x.toLatin1(); + uint8_t* sendbuf = new uint8_t[len_valve_x + 8]; + sendbuf[0] = 0xAA; + sendbuf[1] = 0x00; + sendbuf[2] = len_valve_x + 2; + sendbuf[3] = 't'; + sendbuf[4] = 'e'; + memcpy(sendbuf + 5, valve_byte.data(), len_valve_x); + sendbuf[len_valve_x + 5] = 0xFF; + sendbuf[len_valve_x + 6] = 0xFF; + sendbuf[len_valve_x + 7] = 0xBB; + int cnt = 0; + if(lower_machine != nullptr) + { + while(++cnt <= LONG_SEND) + { + lower_machine->write((const char*)sendbuf, len_valve_x + 8); + lower_machine->flush(); + usleep(50000); + } + } + delete [] sendbuf; +} + +void Widget::on_btn_autosend_valve_clicked() +{ + if(lower_machine == nullptr) + return; + ui->btn_autosend_valve->setEnabled(false); + ui->btn_3to0->setEnabled(false); + qApp->processEvents(); + for(int i=0; i<256; ++i) + { + string str_index = to_string(i); + string show = to_string(i+1); + int len_valve_x = str_index.size(); + uint8_t* sendbuf = new uint8_t[len_valve_x + 8]; + sendbuf[0] = 0xAA; + sendbuf[1] = 0x00; + sendbuf[2] = len_valve_x + 2; + sendbuf[3] = 't'; + sendbuf[4] = 'e'; + memcpy(sendbuf + 5, str_index.data(), len_valve_x); + sendbuf[len_valve_x + 5] = 0xFF; + sendbuf[len_valve_x + 6] = 0xFF; + sendbuf[len_valve_x + 7] = 0xBB; + ui->label_valve_index->setText((const char*)show.c_str()); + qApp->processEvents(); + lower_machine->write((const char*)sendbuf, len_valve_x + 8); + lower_machine->flush(); + delete [] sendbuf; + usleep(300000); + } + ui->btn_autosend_valve->setEnabled(true); + ui->btn_3to0->setEnabled(true); +} + + +void Widget::on_radioButton_manul_2_clicked(bool checked) +{ + ui->groupBox_2->setEnabled(checked); + ui->groupBox->setEnabled(!checked); + ui->btn_autosend_valve->setEnabled(checked); +} + +void Widget::on_radioButton_manul_clicked(bool checked) +{ + ui->groupBox->setEnabled(checked); + ui->groupBox_2->setEnabled(!checked); +} diff --git a/widget.h b/widget.h new file mode 100644 index 0000000..7cb9b28 --- /dev/null +++ b/widget.h @@ -0,0 +1,188 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include +#include "thread.h" +#include "camera.h" +#include "fstream" +#include "parameter.h" +#include "modbus.h" + +#define MODE_SET_ADDR 0x0800 +#define CONVEYOR_ADDR 0x0A0F +#define LAMP_ADDR 0x0A0E +#define POWER_ADDR 0x0A12 +#define DRAUGHT_FAN_ADDR 0x0A13 +#define BRUSH_ADDR 0x0A14 +#define LAMP_FORCE 0x0814 + +#define CONVEYOR_AUTO_ADDR 0x0A26 +#define LAMP_AUTO_ADDR 0x0A27 +#define BRUSH_AUTO_ADDR 0x0A28 +#define POWER_AUTO_ADDR 0x0A29 +#define DRAUGHT_FAN_AUTO_ADDR 0x0A2A + +namespace Ui { +class Widget; +} +// THIS IS THE FIRST M +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = 0); + ~Widget(); + + SendThread* send_thread = nullptr; + SaveThread* save_thread = nullptr; + + cv::Mat img; + cv::Mat img_rgb; + QTcpServer* server_to_lowermachine = nullptr; + QTcpSocket* lower_machine = nullptr; + + QTcpSocket* up_machine = nullptr; //上位机socket + + Parameter* parameter = nullptr; + + bool connect_to_monitor = false; + bool send_to_up_machine = false; + + volatile bool is_running = false; + + void set_spinbox_range(); + void set_ui(bool fullscreen); + void connect_monitor(); + void load_parameter_doc(); + void load_system_parameter(); + void connect_signal(); + + //communication protocal 通信协议 + void send_after_start(); + + //记录相机开启关闭日志 + void time_log(int state); + + void send_lamp_time_to_monitor(); + + void restart_from_error();//2022.8.8 + + int connect_modbus(); + + int plc_command(int times, int coil_addr, int status); + + int plc_open_power(); + + int plc_close_power(); + + int plc_auto_start(); + + int plc_auto_stop(); + +private slots: + void get_data(uint8_t* buff); + void get_rgb_data(uint8_t* buff); + + void On_btn_start_clicked(); + + void On_btn_stop_clicked(); + + void On_btn_black_clicked(); //采集黑帧图片 + + void On_btn_white_clicked(); //采集白帧图片 + + void On_btn_capture_clicked(); + + void get_mask(char* get_buf); + + void get_mask_rgb(char* get_buf); + + void get_valve_data(uint8_t* valve_data); + + void get_send_to_up_machine(float* sendbuf); + + void readfrom_up_machine(); + + void readfrom_lower_machine();//2022.8.8 + + void On_btn_sendsingle_clicked(); + + void On_btn_autosend_clicked(); + + void on_btn_1_clicked(); + + void on_btn_2_clicked(); + + void on_btn_3_clicked(); + + void on_btn_4_clicked(); + + void on_btn_5_clicked(); + + void on_btn_6_clicked(); + + void on_btn_7_clicked(); + + void on_btn_8_clicked(); + + void on_btn_9_clicked(); + + void on_btn_0_clicked(); + + void on_btn_clear_clicked(); + + void on_btn_del_clicked(); + + void on_btn_ensure_clicked(); + + void on_btn_back_clicked(); + + void on_btn_send_plus_clicked(); + + void on_btn_send_min_clicked(); + + void On_btn_threshold_clicked(); + + void on_btn_set_lower_clicked(); + + void on_btn_set_camera_clicked(); + + void on_btn_set_clicked(); + + void on_btn_rgb_white_clicked(); + + void on_btn_rgb_black_clicked(); + + void on_btn_save_enable_clicked(); + + void on_btn_save_disenable_clicked(); + + + + void on_btn_open_conveyor_clicked(); + + void on_btn_close_conveyor_clicked(); + + void on_btn_open_lamp_clicked(); + + void on_btn_close_lamp_clicked(); + + + void on_btn_exit_2_clicked(); + + void on_btn_0to3_2_clicked(); + + void on_btn_send_single_long_clicked(); + + void on_btn_autosend_valve_clicked(); + + void on_radioButton_manul_2_clicked(bool checked); + + void on_radioButton_manul_clicked(bool checked); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/widget.ui b/widget.ui new file mode 100644 index 0000000..53d0aa3 --- /dev/null +++ b/widget.ui @@ -0,0 +1,2099 @@ + + + Widget + + + + 0 + 0 + 1024 + 768 + + + + Widget + + + + + 0 + 0 + 1024 + 768 + + + + 3 + + + + Tab 1 + + + + + 220 + 120 + 691 + 81 + + + + + 36 + + + + 欢迎使用烟梗异物智能分选系统 + + + + + + 150 + 340 + 181 + 81 + + + + + 24 + + + + 进入分选 + + + + + + 710 + 340 + 181 + 81 + + + + + 24 + + + + 喷阀测试 + + + + + + 220 + 530 + 551 + 94 + + + + 连接状态: + + + + + 0 + 32 + 100 + 50 + + + + + 100 + 50 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 14 + + + + 上位机: + + + + + + 80 + 40 + 31 + 31 + + + + + 31 + 31 + + + + + 10 + + + + background-color: rgb(237, 212, 0); + + + + + + + + + 100 + 32 + 100 + 50 + + + + + 100 + 50 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 14 + + + + 下位机: + + + + + + 180 + 40 + 31 + 31 + + + + + 31 + 31 + + + + + 10 + + + + background-color: rgb(237, 212, 0); + + + + + + + + + 220 + 32 + 100 + 50 + + + + + 100 + 50 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 14 + + + + PLC: + + + + + + 260 + 40 + 31 + 31 + + + + + 31 + 31 + + + + + 10 + + + + background-color: rgb(237, 212, 0); + + + + + + + + + 300 + 30 + 100 + 50 + + + + + 100 + 50 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 14 + + + + 光谱相机: + + + + + + 385 + 40 + 31 + 31 + + + + + 31 + 31 + + + + + 10 + + + + background-color: rgb(237, 212, 0); + + + + + + + + + 420 + 30 + 100 + 50 + + + + + 100 + 50 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 14 + + + + 彩色相机: + + + + + + 505 + 40 + 31 + 31 + + + + + 31 + 31 + + + + + 10 + + + + background-color: rgb(237, 212, 0); + + + + + + + + + + 20 + 60 + 191 + 191 + + + + + + + image/njfu.jpg + + + + + + 830 + 560 + 121 + 51 + + + + + 14 + + + + 重新连接 + + + + + + Tab 2 + + + + + 310 + 220 + 111 + 31 + + + + + 14 + + + + UpArrowCursor + + + color: rgb(52, 101, 164); + + + 光谱图像 + + + Qt::AlignCenter + + + + + + 310 + 450 + 101 + 31 + + + + + 14 + + + + UpArrowCursor + + + color: rgb(52, 101, 164); + + + 彩色图像 + + + Qt::AlignCenter + + + + + + 10 + 490 + 700 + 175 + + + + background-color: rgb(238, 238, 236); + + + + + + + + + 570 + 690 + 131 + 31 + + + + + 10 + + + + + + + + + + 10 + 260 + 700 + 175 + + + + background-color: rgb(238, 238, 236); + + + + + + + + + 710 + 160 + 301 + 531 + + + + + 20 + + + + 命令窗口 + + + + + 10 + 50 + 130 + 50 + + + + + 20 + + + + background-color: rgb(115, 210, 22); + + + 开始分选 + + + + + + 160 + 50 + 130 + 50 + + + + + 20 + + + + background-color: rgb(245, 121, 0); + + + 停止分选 + + + + + + 160 + 150 + 130 + 50 + + + + + 20 + + + + 彩色白场 + + + + + + 10 + 150 + 130 + 50 + + + + + 20 + + + + 彩色黑场 + + + + + + 160 + 220 + 130 + 50 + + + + + 20 + + + + 光谱白场 + + + + + + 10 + 220 + 130 + 50 + + + + + 20 + + + + 光谱黑场 + + + + + + 10 + 460 + 130 + 50 + + + + + 20 + + + + 参数设置 + + + + + + 160 + 460 + 130 + 50 + + + + + 20 + + + + 返回 + + + + + + 10 + 320 + 130 + 50 + + + + + 20 + + + + 开传送带 + + + + + + 160 + 320 + 130 + 50 + + + + + 20 + + + + 关传送带 + + + + + + 10 + 390 + 130 + 50 + + + + + 20 + + + + 开启光源 + + + + + + 160 + 390 + 130 + 50 + + + + + 20 + + + + 关闭光源 + + + + + + + 10 + 10 + 191 + 190 + + + + + 0 + 190 + + + + + + + image/njfu.jpg + + + + + + 210 + 90 + 741 + 41 + + + + + 24 + + + + UpArrowCursor + + + color: rgb(52, 101, 164); + + + 南京林业大学机械电子工程学院智能分选团队研发 + + + Qt::AlignCenter + + + + + + Tab3 + + + + + 0 + 0 + 301 + 71 + + + + + 28 + + + + 参数设置界面 + + + + + + 680 + 500 + 170 + 70 + + + + + 36 + + + + 返回 + + + + + + 480 + 500 + 170 + 70 + + + + + 20 + + + + 保存配置文件 + + + + + + 10 + 60 + 401 + 311 + + + + + 16 + + + + 相机参数 + + + + + 10 + 20 + 131 + 81 + + + + + 24 + + + + 曝光时间 + + + + + + 160 + 39 + 120 + 51 + + + + + + + 10 + 100 + 111 + 81 + + + + + 24 + + + + MROI + + + + + + 10 + 170 + 141 + 81 + + + + + 24 + + + + 谱段索引 + + + + + + 160 + 190 + 231 + 50 + + + + + + + 160 + 120 + 231 + 51 + + + + + + + 250 + 250 + 131 + 51 + + + + + 16 + + + + 保存后请重启 + + + + + + + 10 + 370 + 401 + 321 + + + + + 16 + + + + 下位机参数 + + + + + 250 + 200 + 120 + 41 + + + + + + + 250 + 40 + 120 + 41 + + + + + + + 20 + 190 + 191 + 41 + + + + + 24 + + + + 喷阀分频系数 + + + + + + 20 + 140 + 231 + 41 + + + + + 24 + + + + 编码器分频系数 + + + + + + 250 + 140 + 120 + 41 + + + + + + + 20 + 40 + 201 + 41 + + + + + 24 + + + + 光谱延时时间 + + + + + + 250 + 250 + 121 + 51 + + + + + 26 + + + + 确认 + + + + + + 150 + 250 + 81 + 41 + + + + + + + 20 + 250 + 121 + 41 + + + + + 24 + + + + padding + + + + + + 20 + 90 + 201 + 41 + + + + + 24 + + + + RGB延时时间 + + + + + + 250 + 90 + 120 + 41 + + + + + + + + 470 + 40 + 431 + 91 + + + + + 16 + + + + 彩色图像显示谱段设置 + + + + + 20 + 50 + 41 + 31 + + + + + 24 + + + + R + + + + + + 50 + 40 + 81 + 41 + + + + + + + 160 + 50 + 41 + 31 + + + + + 24 + + + + G + + + + + + 190 + 40 + 81 + 41 + + + + + + + 300 + 50 + 41 + 31 + + + + + 24 + + + + B + + + + + + 330 + 40 + 81 + 41 + + + + + + + + 470 + 150 + 431 + 151 + + + + + 16 + + + + 模型参数设置 + + + + + 10 + 40 + 131 + 41 + + + + + 24 + + + + 光谱阈值 + + + + + + 150 + 40 + 120 + 41 + + + + + + + 280 + 100 + 101 + 41 + + + + + 20 + + + + 确认 + + + + + + 10 + 100 + 131 + 41 + + + + + 24 + + + + 彩色阈值 + + + + + + 150 + 100 + 120 + 41 + + + + + + + + 480 + 330 + 141 + 61 + + + + + 20 + + + + 保存图片 + + + + + + 640 + 330 + 141 + 61 + + + + + 20 + + + + 不保存图片 + + + + + + 480 + 410 + 130 + 50 + + + + + 20 + + + + 加载 + + + + + + 640 + 410 + 130 + 50 + + + + + 20 + + + + 抓取图片 + + + + + + 780 + 620 + 181 + 81 + + + + + 24 + + + + background-color: rgb(239, 41, 41); + + + 关机 + + + + + + 570 + 620 + 181 + 81 + + + + + 24 + + + + background-color: rgb(245, 121, 0); + + + 重启 + + + + + + Tab4 + + + + + 700 + 440 + 170 + 70 + + + + + 36 + + + + 返回 + + + + + true + + + + 80 + 260 + 551 + 91 + + + + + 16 + + + + 手动喷阀测试 + + + + + 20 + 40 + 71 + 41 + + + + + 24 + + + + 通道 + + + + + + 220 + 40 + 101 + 41 + + + + + 20 + + + + 测试 + + + + + + 100 + 40 + 111 + 41 + + + + + + + 330 + 40 + 41 + 41 + + + + + 20 + + + + + + + + + + + 380 + 40 + 41 + 41 + + + + + 20 + + + + - + + + + + + 430 + 40 + 101 + 41 + + + + + 18 + + + + 连续测试 + + + + + + false + + + + 80 + 390 + 541 + 161 + + + + + 16 + + + + 自动喷阀测试 + + + + + 20 + 40 + 221 + 41 + + + + + 24 + + + + 所有通道1-256 + + + + + + 170 + 100 + 67 + 41 + + + + + 24 + + + + 1 + + + + + + 20 + 100 + 161 + 41 + + + + + 24 + + + + 当前通道: + + + + + false + + + + 250 + 40 + 101 + 41 + + + + + 20 + + + + 测试 + + + + + + + 90 + 10 + 301 + 71 + + + + + 36 + + + + 喷阀测试界面 + + + + + + 80 + 100 + 171 + 111 + + + + + 16 + + + + 选择模式 + + + + + 20 + 40 + 112 + 23 + + + + 手动模式 + + + true + + + + + + 20 + 80 + 112 + 23 + + + + 自动模式 + + + false + + + + + + + Tab5 + + + + + 380 + 80 + 261 + 51 + + + + + + + 380 + 150 + 80 + 80 + + + + + 28 + + + + 1 + + + + + + 470 + 150 + 80 + 80 + + + + + 28 + + + + 2 + + + + + + 560 + 150 + 80 + 80 + + + + + 28 + + + + 3 + + + + + + 380 + 240 + 80 + 80 + + + + + 28 + + + + 4 + + + + + + 470 + 240 + 80 + 80 + + + + + 28 + + + + 5 + + + + + + 560 + 240 + 80 + 80 + + + + + 28 + + + + 6 + + + + + + 380 + 330 + 80 + 80 + + + + + 28 + + + + 7 + + + + + + 470 + 330 + 80 + 80 + + + + + 28 + + + + 8 + + + + + + 560 + 330 + 80 + 80 + + + + + 28 + + + + 9 + + + + + + 470 + 420 + 80 + 80 + + + + + 28 + + + + 0 + + + + + + 560 + 420 + 80 + 80 + + + + + 28 + + + + background-color: rgb(239, 41, 41); + + + <— + + + + + + 650 + 330 + 80 + 80 + + + + + 28 + + + + background-color: rgb(115, 210, 22); + + + 确认 + + + + + + 380 + 420 + 80 + 80 + + + + + 28 + + + + CLR + + + + + + 650 + 420 + 80 + 80 + + + + + 28 + + + + + + + 返回 + + + + + + + + +