#pragma once
|
#include "../ImageFunc/ImageFunc.h"
|
enum enumGrabResult
|
{
|
GrabUndenfined=-1,
|
GrabOK=0
|
};
|
enum eCameraResult
|
{
|
CameraError=-1,
|
CameraOk=0,
|
};
|
typedef struct stMyCameraInfo
|
{
|
unsigned char camIp[4]; //!<Ïà»úµÄIPµØÖ·
|
unsigned char camMac[6]; //!<Ïà»úµÄMACµØÖ·
|
unsigned char ifIp[4]; //!<¼ÆËã»úºÍÏà»úÁ¬½ÓµÄÍø¿¨IPµØÖ·
|
unsigned char ifMac[6]; //!<¼ÆËã»úºÍÏà»úÁ¬½ÓµÄÍø¿¨MACµØÖ·
|
char mMfgName[32]; //!<Ïà»ú³§ÉÌÃû³Æ
|
char mModelName[32]; //!<Ïà»úÐͺÅ
|
char mSerialNumber[16]; //!<Ïà»úÐòÁкÅ
|
char mUserDefinedName[16]; //!<Óû§ÉèÖõÄÏà»úÃû³Æ
|
CString sMfgName;
|
CString sModelName;
|
CString sSerialNumber;
|
CString sUserDefinedName;
|
|
stMyCameraInfo()
|
{
|
memset(camIp,0,sizeof(camIp));
|
memset(camMac,0,sizeof(camMac));
|
memset(ifIp,0,sizeof(ifIp));
|
memset(ifMac,0,sizeof(ifMac));
|
memset(mMfgName,0,sizeof(mMfgName));
|
memset(mModelName,0,sizeof(mModelName));
|
memset(mSerialNumber,0,sizeof(mSerialNumber));
|
memset(mUserDefinedName,0,sizeof(mUserDefinedName));
|
sMfgName = _T("");
|
sModelName = _T("");
|
sSerialNumber = _T("");
|
sUserDefinedName = _T("");
|
};
|
}MyCameraInfo;
|
|
|
class MyCamera
|
{
|
public:
|
MyCamera(void);
|
~MyCamera(void);
|
private:
|
|
public:
|
int Idx; //Ïà»úÔÚËùÓÐÏà»úÁбíÀïµÄϱê
|
int m_IsCameraOpened; //Ïà»úÊÇ·ñÒѾ´ò¿ª
|
int m_nWidth; //Ïà»úͼÏñ¿í¶È
|
int m_nHeight; //Ïà»úͼÏñ¸ß¶È
|
int m_XOffset; //
|
int m_YOffset;
|
int m_ROIWidth; //ROIÇøÓò¿í¶È
|
int m_ROIHeight; //ROIÇøÓò¸ß¶È
|
int m_PixelFormat;
|
|
int m_nWaitTime; //µÈ´ýÏà»ú³¬Ê±Ê±¼ä;
|
|
MyImage Image1;
|
CString ResultStr;
|
|
virtual int GetCameraCount(){return 0;};
|
virtual int GetCameraInfo(int index, MyCameraInfo * pMyCameraInfo){return CameraError;};
|
virtual int OpenCamera(int){return CameraError;};
|
virtual int CloseCamera(){return CameraError;};
|
virtual int GetCameraWidthHeight(int* Width, int * Height){return CameraError;};
|
virtual int GetCameraPixelFormat(){return CameraError;};
|
virtual int SetCameraPixelFormat(int *PixelFormat){return CameraError;};
|
virtual int GetExposureTime(double *ExposureTime){return CameraError;};
|
virtual int SetExposureTime(double ExposureTime1){return CameraError;};
|
|
virtual int GetWidth(int *Width){return CameraError;}
|
virtual int GetWidthRange(int *WidthMin,int *WidthMax){return CameraError;};
|
virtual int GetWidthInc(int *WidthInc){return CameraError;};
|
virtual int GetWidthRangeInc(int *WidthMin,int *WidthMax,int *WidthInc)
|
{
|
if (GetWidthRange(WidthMin,WidthMax)==CameraOk&&GetWidthInc(WidthInc)==CameraOk)
|
return CameraOk;
|
else return CameraError;
|
}
|
virtual int SetWidth(int nWidth){return CameraError;}
|
|
virtual int GetHeight(int *Height){return CameraError;}
|
virtual int GetHeightRange(int *HeightMin, int *HeightMax){return CameraError;};
|
virtual int GetHeightInc(int *HeightInc){return CameraError;};
|
virtual int GetHeightRangeInc(int *HeightMin, int *HeightMax, int *HeightInc)
|
{
|
if (GetHeightRange(HeightMin,HeightMax)==CameraOk&&GetHeightInc(HeightInc)==CameraOk)
|
return CameraOk;
|
else return CameraError;
|
}
|
virtual int SetHeight(int nHeight){return CameraError;}
|
|
virtual int GetOffsetXRange(int *OffsetXMin,int *OffsetXMax){return CameraError;};
|
virtual int GetOffsetYRange(int *OffsetYMin,int *OffsetYMax){return CameraError;};
|
virtual int GetOffsetX(int *OffsetX){return CameraError;}
|
virtual int GetOffsetY(int *OffsetY){return CameraError;}
|
virtual int GetOffsetXY(int *OffsetX, int *OffsetY){return CameraError;};
|
|
virtual int SetOffsetX(int nOffsetX){return CameraError;}
|
virtual int SetOffsetY(int nOffsetY){return CameraError;}
|
virtual int SetROI(int nOffsetX,int nOffsetY,int nWidth,int nHeight){return CameraError;};
|
|
virtual int GetGain(double *Gain){return CameraError;};
|
virtual int GetGainRange(double *GainMin,double *GainMax) {return CameraError;};
|
virtual int SetGain(double Gain){return CameraError;};
|
|
virtual int GetGamma(double *gamma){return CameraError;};
|
virtual int GetGammaRange(double *gammaMin,double *gammaMax){return CameraError;};
|
virtual int SetGamma(double gamma){return CameraError;};
|
|
virtual int GetLUTEnable(int *bIsEnable){return CameraError;};
|
virtual int SetLUTEnable(int bIsEnable){return CameraError;};
|
virtual int SetLUT(int *pBuf,int nCount){return CameraError;};
|
|
virtual int SetSim(CString sLangFileName, int pixeltype, int w=0, int h=0){return CameraError;};
|
|
virtual int StartGrab(){return CameraError;};
|
virtual int StopGrab(){return CameraError;};
|
virtual int WaitForGrabFinish(int nTimeWait=500){return CameraError;};
|
virtual int FetchImageData(){return CameraError;};
|
|
int GrabOne(int nWaitTime=1000)
|
{
|
if (m_IsCameraOpened)
|
{
|
int j;
|
ResultStr.Empty();
|
double time1=GetTickCountmS();
|
Image1.Clear();
|
|
j=StartGrab();
|
double time2=GetTickCountmS();
|
if (j!=CameraOk) {ResultStr.AppendFormat(_T("ÅÄÕÕʧ°Ü %.1fmS"),time2-time1);return j;}
|
|
j=WaitForGrabFinish(nWaitTime);
|
double time3=GetTickCountmS();
|
if (j!=CameraOk) {ResultStr.AppendFormat(_T("µÈ´ý³¬Ê± %.1fmS ×Üʱ %.1fmS"),time3-time2,time3-time1);return j;}
|
|
j=FetchImageData();
|
double time4=GetTickCountmS();
|
if (j!=CameraOk) {ResultStr.AppendFormat(_T("»ñÈ¡Êý¾Ýʧ°Ü %.1fmS ×Üʱ %.1fmS"),time4-time3,time4-time1);return j;}
|
|
ResultStr.AppendFormat(_T("ÅÄÕÕ %.1fmS µÈ´ý %.1fms È¡Êý¾Ý %.1fmS ×Üʱ¼ä %.1fmS"),time2-time1,time3-time2,time4-time3,time4-time1);
|
return CameraOk;
|
}
|
else
|
{
|
ResultStr.Format(_T("ÅÄÕÕʧ°Ü Ïà»úδ´ò¿ª"));
|
return CameraError;
|
}
|
return CameraError;
|
}
|
};
|
|
class MySimCamera : public MyCamera
|
{
|
public:
|
MySimCamera();
|
~MySimCamera();
|
MySimCamera(CString);
|
|
CString ImageFilePathName; //Ä£ÄâÔËÐÐÎļþ·¾¶ºÍͨÅä·û
|
CString CurFilePathName;
|
int nTotalImageFileCount;
|
int nCurImageFileIndex;
|
|
int InitLib(){return CameraOk;};
|
int GetCameraCount(){return 1;};
|
int OpenCamera(int);
|
int CloseCamera();
|
int GetCameraWidthHeight(int* nWidth, int * nHeight)
|
{
|
*nWidth=m_nWidth;
|
*nHeight=m_nHeight;
|
return CameraOk;
|
}
|
int GetCameraPixelFormat(){return m_PixelFormat;};
|
int SetExposureTime(double ExposeTime1);
|
int SetGain(double Gain){return CameraOk;};
|
int SetROI(int nOffsetX,int nOffsetY,int nWidth,int nHeight)
|
{
|
return CameraOk;
|
}
|
|
int StartGrab();
|
int StopGrab();
|
int WaitForGrabFinish(int nTimeWait);
|
int FetchImageData();
|
|
int SetSim(CString sFilePathName, int pixeltype, int w=0, int h=0);
|
int GetNextFilePathName();
|
|
};
|