#pragma once #include "MyCameraBase.h" #include "./MVS_SDK/MvCameraControl.h" #include class MVSCamera : public MyCamera { public: MVSCamera(void); ~MVSCamera(void); private: volatile static int TotalCameraCount; public: HANDLE m_hCam; //´ò¿ªµÄÏà»ú¾ä±ú UINT m_nFPS; //! Ö¡ÂÊ BOOL m_bTrigCont; //! Á¬Ðø´¥·¢Ä£Ê½ int m_nTimeCostMax; //! ´Ó·¢³ö´¥·¢Ö¸Áîµ½µÃµ½Í¼ÏñËù»¨·Ñʱ¼äµÄ×î´óÖµ float m_fExpo; //! Æعâʱ¼ä,uS volatile int Grabok; volatile int TrigeredCount; volatile int BackCallCount; volatile int SnapCount; unsigned char* pImageBuf; int pImageBufSize; static int InitLib(); int GetCameraCount(){return TotalCameraCount;} int GetCameraInfo(int index, MyCameraInfo * pMyCameraInfo); int OpenCamera(int Index); int CloseCamera(); int GetCameraWidthHeight(int * nWidth, int * nHeight) { *nWidth=m_nWidth; *nHeight=m_nHeight; return CameraOk; }; int GetCameraPixelFormat() { return m_PixelFormat; }; int GetExposureTime(double *ExposureTime); int SetExposureTime(double ExposeTime); int GetWidth(int *nWidth) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"Width", &iValue); if (nRet!=MV_OK) return CameraError; *nWidth = iValue.nCurValue; return CameraOk; }; int GetWidthRange(int *WidthMin,int *WidthMax) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"Width", &iValue); if (nRet!=MV_OK) return CameraError; *WidthMin = iValue.nMin; *WidthMax = iValue.nMax; return CameraOk; }; int GetWidthInc(int *WidthInc) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"Width", &iValue); if (nRet!=MV_OK) return CameraError; *WidthInc = iValue.nInc; return CameraOk; }; int SetWidth(int nWidth) { int nRet = MV_CC_SetIntValue(m_hCam,"Width", nWidth); if (nRet!=MV_OK) return CameraError; return CameraOk; }; int GetHeight(int *nHeight) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"Height", &iValue); if (nRet!=MV_OK) return CameraError; *nHeight = iValue.nCurValue; return CameraOk; }; int GetHeightRange(int *HeightMin,int *HeightMax) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"Height", &iValue); if (nRet!=MV_OK) return CameraError; *HeightMin = iValue.nMin; *HeightMax = iValue.nMax; return CameraOk; }; int GetHeightInc(int *HeightInc) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"Height", &iValue); if (nRet!=MV_OK) return CameraError; *HeightInc = iValue.nInc; return CameraOk; }; int SetHeight(int nHeight) { int nRet = MV_CC_SetIntValue(m_hCam,"Height", nHeight); if (nRet!=MV_OK) return CameraError; return CameraOk; }; int GetOffsetX(int *nOffsetX) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"OffsetX", &iValue); if (nRet!=MV_OK) return CameraError; *nOffsetX = iValue.nCurValue; return CameraOk; }; int GetOffsetXRange(int *OffsetXMin,int *OffsetXMax) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"OffsetX", &iValue); if (nRet!=MV_OK) return CameraError; *OffsetXMin = iValue.nMin; *OffsetXMax = iValue.nMax; return CameraOk; }; int SetOffsetX(int nOffsetX) { int nRet = MV_CC_SetIntValue(m_hCam,"OffsetX", nOffsetX); if (nRet!=MV_OK) return CameraError; return CameraOk; }; int GetOffsetY(int *nOffsetY) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"OffsetY", &iValue); if (nRet!=MV_OK) return CameraError; *nOffsetY = iValue.nCurValue; return CameraOk; }; int GetOffsetYRange(int *OffsetYMin,int *OffsetYMax) { MVCC_INTVALUE iValue; int nRet = MV_CC_GetIntValue(m_hCam,"OffsetY", &iValue); if (nRet!=MV_OK) return CameraError; *OffsetYMin = iValue.nMin; *OffsetYMax = iValue.nMax; return CameraOk; }; int SetOffsetY(int nOffsetY) { int nRet = MV_CC_SetIntValue(m_hCam,"OffsetY", nOffsetY); if (nRet!=MV_OK) return CameraError; return CameraOk; }; int SetROI(int nOffsetX, int nOffsetY, int nWidth, int nHeight) { int WidthMax,WidthMin,WidthInc,HeightMax,HeigtMin,OffsetXMin,OffsetXMax,OffsetYMin,OffsetYMax; if (GetWidthRange(&WidthMin,&WidthMax)!=CameraOk) return CameraError; if (GetWidthInc(&WidthInc)!=CameraOk) return CameraError; if (WidthInc==0) return CameraError; if (GetHeightRange(&HeigtMin,&HeightMax)!=CameraOk) return CameraError; if (GetOffsetXRange(&OffsetXMin,&OffsetXMax)!=CameraOk) return CameraError; if (GetOffsetYRange(&OffsetYMin,&OffsetYMax)!=CameraOk) return CameraError; if (nWidthWidthMax) return CameraError; if ((nWidth%WidthInc)!=0) return CameraError; if (nHeightHeightMax) return CameraError; if (nOffsetXOffsetXMax) return CameraError; if (nOffsetYOffsetYMax) return CameraError; if (nOffsetX+nWidth>WidthMax) return CameraError; if (nOffsetY+nHeight>HeightMax) return CameraError; if (SetOffsetX(0)!=CameraOk) return CameraError; if (SetOffsetY(0)!=CameraOk) return CameraError; if (SetWidth(nWidth)!=CameraOk) return CameraError; if (SetHeight(nHeight)!=CameraOk) return CameraError; if (SetOffsetX(nOffsetX)!=CameraOk) return CameraError; if (SetOffsetY(nOffsetY)!=CameraOk) return CameraError; return CameraOk; }; int GetGain(double *nGain) { MVCC_FLOATVALUE fValue; int nRet = MV_CC_GetFloatValue(m_hCam,"Gain", &fValue); if (nRet!=MV_OK) return CameraError; *nGain = fValue.fCurValue; return CameraOk; }; int GetGainRange(double *GainMin,double *GainMax) { MVCC_FLOATVALUE fValue; int nRet = MV_CC_GetFloatValue(m_hCam,"Gain", &fValue); if (nRet!=MV_OK) return CameraError; *GainMin = fValue.fMin; *GainMax = fValue.fMax; return CameraOk; }; int SetGain(float Gain) { int nRet = MV_CC_SetFloatValue(m_hCam,"Gain", Gain); if (nRet!=MV_OK) return CameraError; return CameraOk; }; int GetGamma(double *nGamma) { MVCC_FLOATVALUE fValue; int nRet = MV_CC_GetFloatValue(m_hCam,"Gamma", &fValue); if (nRet!=MV_OK) return CameraError; *nGamma = fValue.fCurValue; return CameraOk; }; int GetGammaRange(double *GammaMin,double *GammaMax) { MVCC_FLOATVALUE fValue; int nRet = MV_CC_GetFloatValue(m_hCam,"Gamma", &fValue); if (nRet!=MV_OK) return CameraError; *GammaMin = fValue.fMin; *GammaMax = fValue.fMax; return CameraOk; }; int SetGamma(float Gamma) { int nRet = MV_CC_SetFloatValue(m_hCam,"Gamma", Gamma); if (nRet!=MV_OK) return CameraError; return CameraOk; }; int GetLUTEnable(int *bIsEnable) { bool v; int nRet = MV_CC_GetBoolValue(m_hCam,"LUTEnable", &v); if (nRet!=MV_OK) return CameraError; *bIsEnable = v; return CameraOk; }; int SetLUTEnable(int bIsEnable) { bool v = (bIsEnable != 0); int nRet = MV_CC_SetBoolValue(m_hCam,"LUTEnable", v); if (nRet!=MV_OK) return CameraError; return CameraOk; }; int SetLUT(int *pBuf,int nCount) { int nRet; for (int i=0;i