2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
445 lines
13 KiB
C++
445 lines
13 KiB
C++
#ifndef MAINWINDOW_H
|
||
#define MAINWINDOW_H
|
||
|
||
#include <QMainWindow>
|
||
#include <QComboBox>
|
||
#include <QTimer>
|
||
|
||
#include <thread>
|
||
using namespace std;
|
||
|
||
#include "AdvanceMode/SettingsPanel.h"
|
||
#include "AdvanceMode/SettingsControl.h"
|
||
#include "AdvanceMode/GetSystemCode.h"
|
||
#include "UserMode/UnCoolDevSettings.h"
|
||
|
||
#include "GCycleQueue.h"
|
||
#include "IO/FileStream/Raw/FileStream.h"
|
||
|
||
#include "IO/DeviceStream/CameraLink/CameraLinkDealer.h"
|
||
|
||
#include "RecordThread.h"
|
||
#include "Arith/ImgProcessDll.h"
|
||
#include "OpenGLView.h"
|
||
#include "GdImageLib.h"
|
||
|
||
#include "Arith/Test.h"
|
||
#include "Arith/GetNETDrate.h"
|
||
#include "Arith/GetIndexofY16.h"
|
||
#include "Arith/GetIndexofY8.h"
|
||
#include "Arith/GetAvg.h"
|
||
#include "Arith/BadpointsDll.h"
|
||
#include "Arith/GetNumofBadpoint.h"
|
||
|
||
#include <QVBoxLayout>
|
||
#include <FrameParams.h>
|
||
#include "CommSerialDef.h"
|
||
#include "TGAirthProcess.h"
|
||
#include "UserMode/UserControl.h"
|
||
#include "IO/DeviceStream/GDeviceReader.h"
|
||
#include "UIHelp/ConfigHelp.h"
|
||
|
||
|
||
#include "./../../Common/GdImageLib.h"
|
||
#include "qcustomplotcommon.h"
|
||
#include "GdImageLib.h"
|
||
#include <QFrame>
|
||
|
||
//const int PONTNUM = 100;
|
||
#define MaxSize_IRSensorTool (4096*2048)
|
||
|
||
#define Max_X_TimeDomain_NUM 20
|
||
|
||
namespace Ui {
|
||
class MainWindow;
|
||
}
|
||
|
||
#ifndef __byte_def__
|
||
#define __byte_def__
|
||
typedef unsigned char BYTE, Byte, byte;
|
||
#endif
|
||
|
||
const int c_nFRAME_SIZE = (32*1024*1024); // 32MB (当前常见最小硬盘Cache为64MB,此处取一半)
|
||
|
||
enum enumUpgradeStatus
|
||
{
|
||
eUS_FlashReady_True = 1,
|
||
eUS_FlashReady_False,
|
||
eUS_UpgradeFinished_True,
|
||
eUS_UpgradeFinished_False,
|
||
eUS_None = 0,
|
||
};
|
||
|
||
#define CHANNEL_COUNT 1
|
||
#define MULTI_CHANNEL 0
|
||
|
||
class FileOperator;
|
||
class FlashData;
|
||
class MainWindow : public QMainWindow
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit MainWindow(QWidget *parent = 0);
|
||
~MainWindow();
|
||
|
||
bool ReadReg(UINT index,DWORD offset,UINT*outdata);
|
||
bool WriteReg(UINT index,DWORD offset,UINT indata);
|
||
|
||
//
|
||
void ResetUpgrade();
|
||
enumUpgradeStatus GetUpgradeStatus();
|
||
bool SendUpgradeData(char* lpszCmd, int nLen);
|
||
void SetSystemType(EUSetSystemType type);
|
||
|
||
private:
|
||
void InitStyle();
|
||
void InitPara();
|
||
void InitOpenGLView();
|
||
void Connect();
|
||
void Disconnect();
|
||
void UpdateImgFormat();
|
||
void InitImageQualityAssess();
|
||
|
||
void LimitValue(int& nX, int& nY, int& nW, int& nH);
|
||
|
||
void SetProgress(/*int iID,*/ int nFrameIndex, int nFrameCount);
|
||
static void OnProgress(/*int iID,*/ int nFrameIndex, int nFrameCount, void* pOwner);
|
||
|
||
//图像预处理
|
||
void ImgUnsignedProcess(unsigned short *pSrc, unsigned char *pDst, int nWidth, int nHeight);
|
||
//
|
||
void ImgShowProcess(unsigned char *pDstShow, unsigned char *pSrc, int nWidth, int nHeight);
|
||
|
||
|
||
protected:
|
||
bool eventFilter(QObject *obj, QEvent *event);
|
||
void showEvent(QShowEvent *event);
|
||
|
||
private:
|
||
bool BrowseRawFile(bool isDir);
|
||
void SetPlayOrPauseButton(bool bPlay);
|
||
|
||
signals:
|
||
void sigVideoRect(ImageAssessRect imageAssessRect);
|
||
void sigShowRectImage(QImage varImage, int nWidth, int nHeight);
|
||
|
||
void sigBackVideoRect(ImageAssessRect BackRect);
|
||
|
||
void SigConvertResult(QString str);
|
||
void SigConvertProgress(int value);
|
||
|
||
private slots:
|
||
void OnSlotFetureChanged(bool bl);
|
||
void OnButtonClicked();
|
||
void OnButtonClicked_TG();
|
||
void OnButtonClicked_Playback();
|
||
void OnButtonClicked_Capture();
|
||
void OnComboxIndexChanged(int nIndex);
|
||
void OnSliderValueChanged(int nVal);
|
||
void OnButtonIsChecked(bool isCheck);
|
||
void OnTimer();
|
||
void OnTimer_Play();
|
||
void OnExitTimer();
|
||
void OnConfirm_File(bool bOK, const GFrameFormat& varFrameFormat_File);
|
||
void OnConfirm_CPL64(bool bOK, const GFrameFormat_CPL64& varFrameFormat_CPL64);
|
||
void OnConfirm_VideoRect(ImageAssessRect imageAssessRect);
|
||
void OnConfirm_BackVideoRect(ImageAssessRect BackRect);
|
||
|
||
void OnButtonReleased();
|
||
void OnButtonPressed();
|
||
|
||
|
||
|
||
private:
|
||
typedef void (MainWindow::*ThreadRunFunPtr)();
|
||
static void ThreadEntry(ThreadRunFunPtr pRunFun, void* pOwner);
|
||
|
||
void ThreadFun_CaptureDeviceData();
|
||
void ThreadFun_ProcessDeviceData_Ch0(); //0通道采集数据处理线程
|
||
void ThreadFun_ProcessDeviceData_Ch1(); //1通道采集数据处理线程
|
||
|
||
void ThreadFun_FetchRawFileData();
|
||
void ThreadFun_ProcessRawFileData();
|
||
|
||
void ThreadFun_ShowData();
|
||
|
||
void ThreadFun_SendCmd();
|
||
|
||
bool StartThread_DealDeviceData();
|
||
void StopThread_DealDeviceData();
|
||
|
||
bool StartThread_DealRawFileData();
|
||
void StopThread_DealRawFileData();
|
||
|
||
bool StartThread_SendCmd();
|
||
void StopThread_SendCmd();
|
||
|
||
//计算各参数
|
||
void ThreadFun_ImageQualityParam();
|
||
|
||
|
||
private:
|
||
Ui::MainWindow *ui;
|
||
|
||
QPoint m_varPointStart; //矩形框起始点--目标框
|
||
QPoint m_varPointEnd; //矩形框结束点--目标框
|
||
bool m_bRectDraw; //是否开始绘制矩形框--目标框
|
||
bool m_bBackRectDraw; //是否绘制背景矩形框(Y16)
|
||
|
||
QPoint m_varBackPointStart; //矩形框起始点--背景框
|
||
QPoint m_varBackPointEnd; //矩形框结束点--背景框
|
||
|
||
SettingsPanel* m_pSettingsPanel;
|
||
bool m_bShowSettingsPanel;
|
||
|
||
SettingsControl* m_pSettingsControl;
|
||
bool m_bShowSettingsControl;
|
||
|
||
GetSystemCode* m_pGetSystemCode;
|
||
bool m_bShowGetSystemCode;
|
||
|
||
UnCoolDevSettings* m_pUnCoolDevSettings;
|
||
bool m_bShowUnCoolDev;
|
||
|
||
bool m_bImageQualityAssess;
|
||
|
||
bool m_bTGSettings;
|
||
|
||
QPoint m_ptMouse;
|
||
bool m_bMousePressed;
|
||
|
||
QTimer m_varTimer;
|
||
double m_dFPS[CHANNEL_COUNT];
|
||
GCycleQueue m_varCaptureData[CHANNEL_COUNT]; // 设备采集数据 双通道
|
||
GCycleQueue m_varRawFileData[CHANNEL_COUNT]; // 文件读取数据
|
||
GCycleQueue m_varY8DataShow_IN; //输入的原始Y8数据用于show
|
||
GCycleQueue m_varImageQualityParamData_IN; //输入的原始数据--计算质量评估的参数
|
||
|
||
|
||
FrameParams* m_pFrameParams;
|
||
QString m_strCurrentFilePath; // 当前文件路径
|
||
GFrameFormat m_varGFrameFormat;
|
||
GFrameFormat_CPL64 m_varGFrameFormatCap;
|
||
|
||
GCycleQueue m_varY16Data[CHANNEL_COUNT];
|
||
|
||
|
||
QVector<QVector<QRgb> > m_varColorTable;
|
||
|
||
QVBoxLayout* m_pGridLayout;
|
||
int m_nScreenWidthMax;
|
||
int m_nScreenHeightMax;
|
||
int m_nOpenGLWidth;
|
||
int m_nOpenGLHeight;
|
||
|
||
//
|
||
OpenGLView* m_pOpenGLView;
|
||
|
||
bool m_bShowRect; //是否显示目标矩形框
|
||
bool m_bShowBackRect; //是否显示背景框
|
||
|
||
bool m_bFullScreen; //是否全屏显示
|
||
|
||
|
||
// 设备处理对象
|
||
GDeviceReader* m_pDevCap;
|
||
|
||
bool m_bIsRecord;
|
||
RecordThread* m_recordThread[CHANNEL_COUNT];
|
||
|
||
//
|
||
bool m_bRecyclePlay;
|
||
bool m_bBrowseFile;
|
||
bool m_bTriggerPausedState;
|
||
FileStream* m_pRawFileStream[CHANNEL_COUNT];
|
||
|
||
bool m_bUpdateProgress;
|
||
int m_nProgress_FrameIndex;
|
||
int m_nProgress_FrameCount;
|
||
int m_nProgressFrameIndex;
|
||
int m_nProgressFrameCount_Sync;
|
||
int m_nProgressFrameCount[CHANNEL_COUNT];
|
||
|
||
//
|
||
bool m_bCaptureData;
|
||
bool m_bInjectData;
|
||
bool m_bEnableAurora;
|
||
|
||
//
|
||
enumUpgradeStatus m_eUpgradeStatus;
|
||
bool m_bFiberLinked;
|
||
|
||
//
|
||
bool m_bThreadRunning_CaptureDeviceData;
|
||
std::thread* m_ptrThread_CaptureDeviceData;
|
||
|
||
bool m_bThreadRunning_ProcessDeviceData;
|
||
std::thread* m_ptrThread_ProcessDeviceData_Ch0;
|
||
std::thread* m_ptrThread_ProcessDeviceData_Ch1;
|
||
|
||
|
||
bool m_bThreadRunning_FetchRawFileData;
|
||
std::thread* m_ptrThread_FetchRawFileData;
|
||
|
||
bool m_bThreadRunning_ProcessRawFileData;
|
||
std::thread* m_ptrThread_ProcessRawFileData;
|
||
|
||
bool m_bThreadRunning_ShowImg;
|
||
std::thread* m_ptrThread_MappingData_Ch0;
|
||
std::thread* m_ptrThread_MappingData_Ch1;
|
||
|
||
std::thread* m_ptrThread_ShowImg;
|
||
|
||
|
||
bool m_bThreadRunning_SendCmd;
|
||
std::thread* m_ptrThread_SendCmd;
|
||
|
||
QAction *aboutAction;
|
||
|
||
QTimer m_varTimerUpdate;
|
||
int m_iPlayState;//0stop;1play;2pause;3next;4pro;5close
|
||
bool m_bOpenFile;
|
||
QTimer m_varExitTimer;
|
||
|
||
byte* m_ImgProcBuf;
|
||
|
||
QVBoxLayout* layoutIR;
|
||
|
||
QMutex m_mutexRawFile;
|
||
|
||
TGAirthProcess* m_pTGAirthProcess;
|
||
|
||
UserControl* m_pUserControl;
|
||
|
||
bool m_bThreadRunning_ImageQuality;
|
||
std::thread* m_ptrThread_ImageQuality;
|
||
|
||
bool m_bConnectFlag;
|
||
SerialMovement* m_SerialHelp;
|
||
ComSettings m_CurrentSettings;
|
||
SerialPortScan* m_SerialPortScan;
|
||
|
||
//升级文件转换
|
||
QString m_strFilePathDat;
|
||
QString m_strFilePathHex;
|
||
QString m_strFilePathHexSave;
|
||
|
||
FileOperator* m_pFileConvert;
|
||
bool m_bConvertRes;
|
||
|
||
//文件转换线程
|
||
void StartConvertThread(QString strSaveName);
|
||
void ThreadFun(QString strSaveName);
|
||
|
||
FileOperator* m_pFileHexConvert;
|
||
bool m_bHexRes;
|
||
|
||
unsigned char* m_pHexBuf;
|
||
|
||
//升级--新协议
|
||
FileOperator* m_pFileFun;
|
||
bool m_bUpdateRes;
|
||
|
||
//机芯版本型号
|
||
EUSetSystemType m_pEUSetSystemType;
|
||
|
||
private:
|
||
|
||
void InitCustomplot();
|
||
void InitAllCurves();
|
||
void CustomPlot_DrawLine(double CurrentData);
|
||
void ShowY16BackRect(bool bl);
|
||
|
||
void SetColorIndex(int value);
|
||
void EnterColorTable(int value);
|
||
void LeaveColorTable();
|
||
|
||
void ConvertToHexData();
|
||
|
||
int ScaleImageFormat(BYTE* pSrc, int nSrcWidth, int nSrcHeight, BYTE* pDst, int nDstWidth, int nDstHeight , long lSrcType, long lDstType);
|
||
|
||
private:
|
||
|
||
//图像质量评估
|
||
ImageAssessRect m_varImageAssessRect;
|
||
ImageAssessRect m_varImageAssessBackRect;
|
||
unsigned short m_uLeftThrow; //左抛点
|
||
unsigned short m_uRightThrow; //右抛点
|
||
|
||
QTimer m_timerDrawLine;
|
||
double m_dLineBuff[PONTNUM]; //曲线绘制数据缓冲数组
|
||
int m_nFlag;
|
||
double* m_pLineArrayValues;
|
||
bool m_bIsDrawLines[MAX_QUALITY_PARAMS];
|
||
|
||
QCustomPlotCommon *m_pPlotCommon[MAX_QUALITY_PARAMS];
|
||
float m_fOldMax;
|
||
|
||
|
||
ushort* m_pY16Data_B1;
|
||
byte* m_pY8Data_B1;
|
||
ushort* m_pY16Data_B2;
|
||
byte* m_pY8Data_B2;
|
||
byte* m_pRGBA;
|
||
ushort* m_pY16Data_KList;
|
||
ushort* m_pY16Data_BPList;
|
||
|
||
byte* m_pY8BadPointData; //Y8 坏点计算数据
|
||
|
||
|
||
bool m_bY8AirSpaceDeviation; //是否计算Y8空域标准差
|
||
bool m_bY8MeanValue; //是否计算Y8均值
|
||
bool m_bY8DynamicRange; //是否计算动态范围
|
||
|
||
ImageX16Mix m_varImageX16Mix;
|
||
ImageY8BadPoint m_varImageY8BadPoint;
|
||
|
||
bool m_bX16TimeSpaceDeviation; //是否计算X16的时域标准差
|
||
bool m_bIsCaculateImageQuality; //是否开启图像质量参数计算
|
||
|
||
int m_nColorIndex; //调色板编号
|
||
int m_nOldColorIndex;
|
||
|
||
bool m_bTGArithOpen;
|
||
QMutex m_mutex;
|
||
|
||
private:
|
||
void updateComSettings();
|
||
|
||
signals:
|
||
void sigSendQualityParamShow(double* data);
|
||
void sigSendQualityImageShow(QImage varImage, int nWidth, int nHeight);
|
||
|
||
void sigSendFPS(QString fps);
|
||
|
||
private slots:
|
||
|
||
void OnDrawLineTimer();
|
||
void OnRecvQualityParamShow(double* dataArray);
|
||
void OnRecvQualityImageShow(QImage varImage, int nWidth, int nHeight);
|
||
void OnRecvFPS(QString fps);
|
||
|
||
/*
|
||
* @brief 调色板点击
|
||
*/
|
||
void OnColorTableClicked();
|
||
|
||
|
||
void onNewPortList(QStringList portName);
|
||
void SendInquery();
|
||
|
||
void ShowSendCmd(QString str);
|
||
void ShowRecvCmd(QString str);
|
||
void OnSlotConvertResult(QString str);
|
||
void OnSlotConvertProgress(int value);
|
||
|
||
//升级数据发送
|
||
void OnSlotUpgradeData(int nFrameNum);
|
||
|
||
//打印升级过程
|
||
void OnSlotShowRecvStr(QString str);
|
||
};
|
||
|
||
#endif // MAINWINDOW_H
|