#pragma once #include #include "ImproModeCalAndCor.h" #include typedef enum _Mode_Status { Mode_Init, Mode_Idle, Mode_Correction, Mode_Calibration, }Mode_Status; typedef enum _RET_Status { RET_ERROR_INPUT = -9, //输入参数错误 RET_ERROR_BUFFER_Malloc, //内存分配失败 RET_ERROR_BUFFER_Empty, //buffer为空 RET_ERROR_LOGIC, //逻辑错误 RET_ERROR_OFFSET, //offset相关失败 RET_ERROR_GAIN, //gain相关失败 RET_ERROR_DEFECT, //defect失败 RET_ERROR_GATELINE, //gateline失败 RET_STATUS_NONE, //不做操作 RET_STATUS_CONTINUE = 0, //继续调用此函数 RET_STATUS_FINISH //函数调用完成 }RET_Status; class FPDCalibration_API CModeMgr { private: void * m_pXMLFile; Mode_Status m_stModeStatus; CImgFrame* m_pFrameTemp; int m_nModeCount; int m_nCorrectType; int m_nCalibationType; int m_nModeNow; int m_nExpWinNow; bool m_bGateLineEnable; //int m_nStep; bool m_bSpeedupEnable; int m_nSpeedupType; unsigned int m_BinningOrZoomFlag; bool m_bGainUseOffset; //int m_nRefPoint; int m_nOffsetStep; unsigned int m_nOffsetAvgNum; int m_nGainStep; unsigned int m_nGainAvgNum; int m_nDefectStep; void *m_pSpeedUp; void *m_pCOffset; void *m_pCGain; void *m_pCDefect; int *m_ImgKindFlag; string *m_path; deque * m_pDqMapIs; mutex *m_pLock; WORD *ImageTmp; int OffsetCorret(CImgFrameSeq* &pSeqInfo, unsigned int nListNum, int nXrayFlag,int * &pImgFlag, bool bPreEnable = false); int GateLineCorret(CImgFrameSeq* &pSeqInfo, unsigned int nListNum, int nXrayFlag); int GainCorret(CImgFrameSeq* &pSeqInfo, unsigned int nListNum, int nXrayFlag); int DefectCorret(CImgFrameSeq* &pSeqInfo, unsigned int nListNum, int nXrayFlag); int FirstLine(CImgFrameSeq* &pSeqInfo, CImgFrame * &pImgResult, unsigned int nListNum, int nXrayFlag); int TwiceLine(CImgFrameSeq* &pSeqInfo, CImgFrame * &pImgResult, unsigned int nListNum, int nXrayFlag); int CreatOffsetMap(CImgFrameSeq* &pCaliSeqInfo, unsigned int nListNum); int CreatGainMap(CImgFrameSeq* &pCaliSeqInfo, unsigned int nListNum, unsigned int nRefPoint); int CreatDefectMap(CImgFrameSeq* &pCaliSeqInfo, unsigned int nListNum); bool ReduceImg(float* pSrcImg, float* pDstImg, int nSrcWidth, int nSrcHeight, int nDstWidth, int nDstHeight); bool ReduceImg(WORD* pSrcImg, WORD* pDstImg, int nSrcWidth, int nSrcHeight, int nDstWidth, int nDstHeight); int initialization(void* XMLFile); bool GetModeInfo(int nModeIndex, DetectorModeInfo* const pMode); //获取指定mode信息 public: CModeMgr(); virtual ~CModeMgr(); DetectorModeInfo* m_pModeList; CImgFrame * m_pFrameList; //返回值为int类型函数,返回值为1正常。返回值0一般为不做任何操作。返回负值为异常。 //mode相关的操作 size_t GetModeCount( ); //获取Mode的总数,返回值mode总数 size_t GetCurrentMode(); //获取当前mode index.返回当前mode index //int LoadMode( const char *pConfigName); bool LoadMode( void* XMLFile ); //加载mode map及配置文件 bool SelectMode(int nIndex); //选取mode索引 // 目前通过配置文件对mode进行增加、删除、更新。 //int UpdateMode(int nModeIndex, DetectorModeInfo* pMode); //更新指定Mode。 //int AddMode(int nModeIndex, DetectorModeInfo* pMode); //创建新mode,并设置信息 //int DeleteMode(int nModeIndex); //删除指定Mode. ////Correction相关 //int ActiveCorrection(int nIndex); // Correction激活某个Mode bool ActiveCorrection( ); // Correction激活某个Mode bool UnActiveCorrection(); // Correction取消激活某个Mode RET_Status GetCorrectionFrameSeq(CImgFrameSeq* &pSeqInfo); // 获Correction取队列及信息 bool SetCorrectionType(int nCaliType); //设置Correction校正类型 RET_Status CorrectFrameData(CImgFrameSeq* pSeqInfo, CImgFrame * pImgResult, bool bFrameDataEx = false); //bFrameDataEx 异常(X图像采集结束,后期暗场图像没有采集到,而Acq停止),默认false. ////Calibration相关 bool ActiveCalibration(); //int ActiveCalibration(int nModeIndex); // Calibration激活某个Mode bool UnActiveCalibration(); // Calibration取消激活某个Mode bool SetCalibrationType(int CaliType); // 设置Calibration校正类型 RET_Status CalibrateData(CImgFrameSeq* pCaliSeqInfo); // CalibrationData //int StartCalSeq(); // Calibration队列开始 //int StopCalSeq(); // Calibration队列结束 RET_Status GetCalibrationFrameSeq(CImgFrameSeq* &pCaliSeqInfo); // 获取队列及信息 ////其它 int CheckFrameData(CImgFrameSeq* pCaliSeqInfo, float fArea = 0.5);//返回值1为亮场图,0为暗场图,负值异常。 bool SetWorkPath(const char* path); //校正文件。 Mode_Status GetModuleStase(); //获取模块状态。 void EnterLock(); void LeaveUnLock(); ////常用操作 //pFrameSeq为 CImgFrameSeq* //siez_t size = pFrameSeq->size(); 获取Seq里Frame总数,pFrameSeq[index]为Seq里的单个frame, 0< indexSetXwindowReq(XWINDOWREQ XwindowReq); 设置曝光时长等。 bool ChooseExpWindow(float fExpWindow); bool ChooseFrameRate(float fFrameRate); bool SetBinningOrZoom(unsigned int flag); int ThreeImageforCreatDefectMap(WORD *dark, WORD *low, WORD *high, double bias); bool GetuGyRequest(float &DoseReq); bool SetGainUseOffset(bool flag); }; //template //inline void safe_delete(T *&target) //{ // if (nullptr != target) // { // delete []target; // target = nullptr; // } //} template inline void safe_delete_void_ptr(void *&target) { if (nullptr != target) { T* temp = static_cast(target); delete []temp; temp = nullptr; target = nullptr; } } //__declspec(dllexport) CImgFrame* MallocFrameList(int nCout, IMAGESIZEINFO *pStImageSizeInfo, IMAGEDEADLINEINFO *pStDeadLineInfo); //__declspec(dllexport) void FreeFrameList( CImgFrame *pFrame); //__declspec(dllexport) CImgFrameSeq* MallocFrameSeq(IMGPROCESSTYPE stImgProType, CImgFrame*pFrame, int nCount); //__declspec(dllexport) void FreeFrameSeq(CImgFrameSeq *pList); FPDCalibration_C_API CImgFrame* MallocFrame(); FPDCalibration_C_API void FreeFrame(CImgFrame *pFrame); FPDCalibration_C_API CImgFrameSeq* MallocFrameSeq(); FPDCalibration_C_API void FreeFrameSeq(CImgFrameSeq *pList); FPDCalibration_C_API CModeMgr * MallocModeMgr(); FPDCalibration_C_API void FreeModeMgr(CModeMgr * pModeMgr);