提交 | 用户 | age
|
4b03ae
|
1 |
#pragma once
|
Q |
2 |
//MV_EM 1400C 相机开发包
|
|
3 |
#include "MyCameraBase.h"
|
|
4 |
#ifdef _WIN64
|
|
5 |
#include ".\MV_SDK64\MVGigE.h"
|
|
6 |
#include ".\MV_SDK64\MVImage.h"
|
|
7 |
#else
|
|
8 |
#include ".\MV_SDK\MVGigE.h"
|
|
9 |
#include ".\MV_SDK\MVImage.h"
|
|
10 |
#endif
|
|
11 |
#include <gdiplus.h>
|
|
12 |
|
|
13 |
//#include "Gdiplus.h"
|
|
14 |
// 多MV相机类文件
|
|
15 |
|
|
16 |
class MVCamera2 : public MyCamera
|
|
17 |
{
|
|
18 |
public:
|
|
19 |
MVCamera2(void);
|
|
20 |
~MVCamera2(void);
|
|
21 |
|
|
22 |
private:
|
|
23 |
volatile static int LabInited; //程序库是否已经初始化,以及初始化的次数。
|
|
24 |
volatile static int TotalCameraCount;
|
|
25 |
|
|
26 |
public:
|
|
27 |
HANDLE m_hCam; //打开的相机句柄
|
|
28 |
|
|
29 |
MVImage m_Raw; //原始图像
|
|
30 |
MVImage m_image; //正常图像
|
|
31 |
|
|
32 |
double m_fExpo; //! 曝光时间,uS
|
|
33 |
|
|
34 |
volatile int Grabok;
|
|
35 |
volatile int TrigeredCount;
|
|
36 |
volatile int BackCallCount;
|
|
37 |
|
|
38 |
static int InitLib();
|
|
39 |
int GetCameraCount(){return TotalCameraCount;}
|
|
40 |
int GetCameraInfo(int index, MyCameraInfo * pMyCameraInfo);
|
|
41 |
|
|
42 |
int OpenCamera(int Index);
|
|
43 |
int CloseCamera();
|
|
44 |
int GetCameraWidthHeight(int * nWidth, int * nHeight)
|
|
45 |
{
|
|
46 |
*nWidth=m_nWidth;
|
|
47 |
*nHeight=m_nHeight;
|
|
48 |
return CameraOk;
|
|
49 |
};
|
|
50 |
int GetCameraPixelFormat()
|
|
51 |
{
|
|
52 |
return m_PixelFormat;
|
|
53 |
};
|
|
54 |
int GetExposureTime(double *ExposureTime);
|
|
55 |
int SetExposureTime(double ExposeTime);
|
|
56 |
|
|
57 |
int GetWidth(int *nWidth)
|
|
58 |
{
|
|
59 |
if (MVGetWidth(m_hCam,nWidth)==MVST_SUCCESS) return CameraOk;
|
|
60 |
else return CameraError;
|
|
61 |
};
|
|
62 |
int GetWidthRange(int *WidthMin,int *WidthMax)
|
|
63 |
{
|
|
64 |
if (MVGetWidthRange(m_hCam,WidthMin,WidthMax)==MVST_SUCCESS) return CameraOk;
|
|
65 |
else return CameraError;
|
|
66 |
};
|
|
67 |
int GetWidthInc(int *WidthInc)
|
|
68 |
{
|
|
69 |
if (MVGetWidthInc(m_hCam,WidthInc)==MVST_SUCCESS) return CameraOk;
|
|
70 |
else return CameraError;
|
|
71 |
};
|
|
72 |
int SetWidth(int nWidth)
|
|
73 |
{
|
|
74 |
if (MVSetWidth(m_hCam,nWidth)==MVST_SUCCESS) return CameraOk;
|
|
75 |
else return CameraError;
|
|
76 |
};
|
|
77 |
|
|
78 |
int GetHeight(int *nHeight)
|
|
79 |
{
|
|
80 |
if (MVGetHeight(m_hCam,nHeight)==MVST_SUCCESS) return CameraOk;
|
|
81 |
else return CameraError;
|
|
82 |
};
|
|
83 |
int GetHeightRange(int *HeightMin,int *HeightMax)
|
|
84 |
{
|
|
85 |
if (MVGetHeightRange(m_hCam,HeightMin,HeightMax)==MVST_SUCCESS) return CameraOk;
|
|
86 |
else return CameraError;
|
|
87 |
};
|
|
88 |
int GetHeightInc(int *HeightInc)
|
|
89 |
{
|
|
90 |
return CameraError;
|
|
91 |
};
|
|
92 |
int SetHeight(int nHeight)
|
|
93 |
{
|
|
94 |
if (MVSetHeight(m_hCam,nHeight)==MVST_SUCCESS) return CameraOk;
|
|
95 |
else return CameraError;
|
|
96 |
};
|
|
97 |
int GetOffsetXRange(int *OffsetXMin,int *OffsetXMax)
|
|
98 |
{
|
|
99 |
if (MVGetOffsetXRange(m_hCam,OffsetXMin,OffsetXMax)==MVST_SUCCESS) return CameraOk;
|
|
100 |
else return CameraError;
|
|
101 |
};
|
|
102 |
int GetOffsetYRange(int *OffsetYMin,int *OffsetYMax)
|
|
103 |
{
|
|
104 |
if (MVGetOffsetYRange(m_hCam,OffsetYMin,OffsetYMax)==MVST_SUCCESS) return CameraOk;
|
|
105 |
else return CameraError;
|
|
106 |
};
|
|
107 |
int GetOffsetX(int *OffsetX)
|
|
108 |
{
|
|
109 |
if (MVGetOffsetX(m_hCam,OffsetX)==MVST_SUCCESS) return CameraOk;
|
|
110 |
else return CameraError;
|
|
111 |
};
|
|
112 |
int GetOffsetY(int *OffsetY)
|
|
113 |
{
|
|
114 |
if (MVGetOffsetY(m_hCam,OffsetY)==MVST_SUCCESS) return CameraOk;
|
|
115 |
else return CameraError;
|
|
116 |
};
|
|
117 |
int SetOffsetX(int nOffsetX)
|
|
118 |
{
|
|
119 |
if (MVSetOffsetX(m_hCam,nOffsetX)==MVST_SUCCESS) return CameraOk;
|
|
120 |
else return CameraError;
|
|
121 |
}
|
|
122 |
int SetOffsetY(int nOffsetY)
|
|
123 |
{
|
|
124 |
if (MVSetOffsetY(m_hCam,nOffsetY)==MVST_SUCCESS) return CameraOk;
|
|
125 |
else return CameraError;
|
|
126 |
}
|
|
127 |
|
|
128 |
int SetROI(int nOffsetX, int nOffsetY, int nWidth, int nHeight)
|
|
129 |
{
|
|
130 |
int WidthMax,WidthMin,WidthInc,HeightMax,HeigtMin,OffsetXMin,OffsetXMax,OffsetYMin,OffsetYMax;
|
|
131 |
if (MVGetWidthRange(m_hCam,&WidthMin,&WidthMax)!=MVST_SUCCESS) return CameraError;
|
|
132 |
if (MVGetWidthInc(m_hCam,&WidthInc)!=MVST_SUCCESS) return CameraError;
|
|
133 |
if (WidthInc==0) return CameraError;
|
|
134 |
if (MVGetHeightRange(m_hCam,&HeigtMin,&HeightMax)!=MVST_SUCCESS) return CameraError;
|
|
135 |
if (MVGetOffsetXRange(m_hCam,&OffsetXMin,&OffsetXMax)!=MVST_SUCCESS) return CameraError;
|
|
136 |
if (MVGetOffsetYRange(m_hCam,&OffsetYMin,&OffsetYMax)!=MVST_SUCCESS) return CameraError;
|
|
137 |
if (nWidth<WidthMin||nWidth>WidthMax) return CameraError;
|
|
138 |
if ((nWidth%WidthInc)!=0) return CameraError;
|
|
139 |
if (nHeight<HeigtMin||nHeight>HeightMax) return CameraError;
|
|
140 |
if (nOffsetX<OffsetXMin||nOffsetX>OffsetXMax) return CameraError;
|
|
141 |
if (nOffsetY<OffsetYMin||nOffsetY>OffsetYMax) return CameraError;
|
|
142 |
|
|
143 |
if (nOffsetX+nWidth>WidthMax) return CameraError;
|
|
144 |
if (nOffsetY+nHeight>HeightMax) return CameraError;
|
|
145 |
if (MVSetOffsetX(m_hCam,0)!=MVST_SUCCESS) return CameraError;
|
|
146 |
if (MVSetOffsetY(m_hCam,0)!=MVST_SUCCESS) return CameraError;
|
|
147 |
if (MVSetWidth(m_hCam,nWidth)!=MVST_SUCCESS) return CameraError;
|
|
148 |
if (MVSetHeight(m_hCam,nHeight)!=MVST_SUCCESS) return CameraError;
|
|
149 |
if (MVSetOffsetX(m_hCam,nOffsetX)!=MVST_SUCCESS) return CameraError;
|
|
150 |
if (MVSetOffsetY(m_hCam,nOffsetY)!=MVST_SUCCESS) return CameraError;
|
|
151 |
return CameraOk;
|
|
152 |
};
|
|
153 |
|
|
154 |
int GetGain(double *Gain)
|
|
155 |
{
|
|
156 |
if (MVGetGain(m_hCam,Gain)==MVST_SUCCESS)
|
|
157 |
return CameraOk;
|
|
158 |
else return CameraError;
|
|
159 |
};
|
|
160 |
int GetGainRange(double *GainMin,double *GainMax)
|
|
161 |
{
|
|
162 |
if (MVGetGainRange(m_hCam,GainMin,GainMax)==MVST_SUCCESS)
|
|
163 |
return CameraOk;
|
|
164 |
else return CameraError;
|
|
165 |
};
|
|
166 |
int SetGain(double Gain)
|
|
167 |
{
|
|
168 |
if (MVSetGain(m_hCam,Gain)==MVST_SUCCESS)
|
|
169 |
return CameraOk;
|
|
170 |
else return CameraError;
|
|
171 |
};
|
|
172 |
int GetGamma(double *Gamma)
|
|
173 |
{
|
|
174 |
if (MVGetGamma(m_hCam,Gamma)==MVST_SUCCESS)
|
|
175 |
return CameraOk;
|
|
176 |
else return CameraError;
|
|
177 |
};
|
|
178 |
int GetGammaRange(double *GammaMin,double *GammaMax)
|
|
179 |
{
|
|
180 |
if (MVGetGammaRange(m_hCam,GammaMin,GammaMax)==MVST_SUCCESS)
|
|
181 |
return CameraOk;
|
|
182 |
else return CameraError;
|
|
183 |
};
|
|
184 |
int SetGamma(double Gamma)
|
|
185 |
{
|
|
186 |
if (MVSetGamma(m_hCam,Gamma)==MVST_SUCCESS)
|
|
187 |
return CameraOk;
|
|
188 |
else return CameraError;
|
|
189 |
};
|
|
190 |
int GetLUTEnable(int *bIsEnable)
|
|
191 |
{
|
|
192 |
if (MVGetEnableLUT(m_hCam,bIsEnable)==MVST_SUCCESS) return CameraOk;
|
|
193 |
else return CameraError;
|
|
194 |
};
|
|
195 |
int SetLUTEnable(int bIsEnable)
|
|
196 |
{
|
|
197 |
if (MVSetEnableLUT(m_hCam,bIsEnable)==MVST_SUCCESS) return CameraOk;
|
|
198 |
else return CameraError;
|
|
199 |
};
|
|
200 |
int SetLUT(int *pBuf,int nCount)
|
|
201 |
{
|
|
202 |
unsigned long buf1[1024];
|
|
203 |
for (int i=0;i<nCount&&i<1024;i++)
|
|
204 |
{
|
|
205 |
buf1[i]=pBuf[i];
|
|
206 |
}
|
|
207 |
if (MVSetLUT(m_hCam,buf1,nCount)==MVST_SUCCESS) return CameraOk;
|
|
208 |
else return CameraError;
|
|
209 |
};
|
|
210 |
|
|
211 |
int StartGrab();
|
|
212 |
int StopGrab(){return CameraOk;};
|
|
213 |
int WaitForGrabFinish(int mSecound);
|
|
214 |
int FetchImageData();
|
|
215 |
|
|
216 |
int UpdateFps();
|
|
217 |
int UpdateImage();
|
|
218 |
|
|
219 |
#ifdef _WIN64
|
|
220 |
int static StreamCB(MV_IMAGE_INFO *pInfo,long long nUserVal);
|
|
221 |
#else
|
|
222 |
int static StreamCB(MV_IMAGE_INFO *pInfo,long nUserVal);
|
|
223 |
#endif
|
|
224 |
int OnStreamCB( MV_IMAGE_INFO *pInfo);
|
|
225 |
};
|
|
226 |
|