-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsiCamera.h
231 lines (187 loc) · 6.54 KB
/
AsiCamera.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
///////////////////////////////////////////////////////////////////////////////
// FILE: ASICamera.h
// PROJECT: Micro-Manager
// SUBSYSTEM: DeviceAdapters
//-----------------------------------------------------------------------------
// DESCRIPTION: A camera implementation that is backed by the file system
// Can access stage positions to choose image to display
//
// AUTHOR: Mikhail Latyshov
//
// COPYRIGHT: 2024 Mikhail Latyshov
// LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <string>
#include "DeviceBase.h"
#include "DeviceThreads.h"
#include "ASICamera2.h"
#include "EFW_filter.h"
class SequenceThread;
#include "error_code.h"
extern const char* cameraName;
class parse_error : public std::exception {};
class ASICamera : public CCameraBase<ASICamera>
{
public:
ASICamera();
~ASICamera();
// ------------
int Initialize();
int Shutdown();
void GetName(char* name) const;
// MMCamera API
// ------------
int SnapImage();
const unsigned char* GetImageBuffer();
// const unsigned int* GetImageBufferAsRGB32();
unsigned GetImageWidth() const;
unsigned GetImageHeight() const;
unsigned GetImageBytesPerPixel() const;
unsigned GetBitDepth() const;
long GetImageBufferSize() const;
double GetExposure() const;
void SetExposure(double exp);
int SetROI(unsigned x, unsigned y, unsigned xSize, unsigned ySize);
int GetROI(unsigned& x, unsigned& y, unsigned& xSize, unsigned& ySize);
int ClearROI();
bool IsCapturing();
int GetBinning() const;
int SetBinning(int binSize);
int IsExposureSequenceable(bool& seq) const;
int PrepareSequenceAcqusition();
int StartSequenceAcquisition(double interval);
int StartSequenceAcquisition(long numImages, double interval_ms, bool stopOnOverflow);
int StopSequenceAcquisition();
unsigned GetNumberOfComponents() const { return iComponents; };
int GetComponentName(unsigned component, char* name);
// action interface
// ----------------
int OnBinning(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnPixelType(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnGain(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnBrightness(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnUSBTraffic(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSelectCamIndex(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnTemperature(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnCoolerOn(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnHeater(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnTargetTemp(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnCoolerPowerPerc(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnWB_R(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnWB_B(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnAutoWB(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnUSB_Auto(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnGamma(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnAutoExp(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnAutoGain(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnFlip(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnHighSpeedMod(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnHardwareBin(MM::PropertyBase* pProp, MM::ActionType eAct);
private:
static const int MAX_BIT_DEPTH = 16;
long lExpMs;
enum CamStatus {
closed = 0,
opened,
capturing,
snaping
};
CamStatus Status;
char FlipArr[4][8];
char ConnectedCamName[32][32];
bool initialized_;
int iConnectedCamNum;
//variable of a camera
unsigned char* uc_pImg;
unsigned char* pRGB32, * pRGB64;
unsigned long iBufSize;
int iPixBytes;//ÿ�������ֽ���
int iComponents;
int iROIWidth, iROIHeight, iBin;//sensor������ߴ���Ϣ
int iSetWid, iSetHei, iSetBin, iSetX, iSetY; //Ҫ���õ�����ߴ���Ϣ
ASI_IMG_TYPE ImgType;
friend class SequenceThread;
SequenceThread* thd_;
ASI_CONTROL_CAPS* pControlCaps;
ASI_CAMERA_INFO ASICameraInfo;
int iCtrlNum;
ASI_FLIP_STATUS ImgFlip;
int ImgStartX, ImgStartY, ImgBin, ImgWid, ImgHei;//����ʾͼ�������ߴ���Ϣ
// int iCamIndex;
char sz_ModelIndex[64];
bool b12RAW, bRGB48;
void DeleteImgBuf();
int RunSequenceOnThread(MM::MMTime startTime);
int InsertImage();
long imageCounter_;
void MallocControlCaps(int iCamindex);
void DeletepControlCaps(int iCamindex);
bool isImgTypeSupported(ASI_IMG_TYPE ImgType);
ASI_CONTROL_CAPS* GetOneCtrlCap(int CtrlID);
void ConvRGB2RGBA32();
void ConvRGB2RGBA64();
void Conv16RAWTo12RAW();
void RefreshImgType();
};
class SequenceThread : public MMDeviceThreadBase
{
public:
SequenceThread(ASICamera* pCam);
~SequenceThread();
void Stop();
void Start(long numImages, double intervalMs);
bool IsStopped();
double GetIntervalMs() { return intervalMs_; }
void SetLength(long images) { numImages_ = images; }
long GetLength() const { return numImages_; }
long GetImageCounter() { return imageCounter_; }
private:
int svc(void) throw();
ASICamera* camera_;
bool stop_;
long numImages_;
long imageCounter_;
double intervalMs_;
};
class CMyEFW : public CStateDeviceBase<CMyEFW>
{
public:
CMyEFW();
~CMyEFW();
// MMDevice API
// ------------
int Initialize();
int Shutdown();
void GetName(char* pszName) const;
bool Busy();
unsigned long GetNumberOfPositions() const;
// action interface
// ----------------
int OnState(MM::PropertyBase* pProp, MM::ActionType eAct);
// int OnNumberOfStates(MM::PropertyBase* pProp, MM::ActionType eAct);
int OnSelectEFWIndex(MM::PropertyBase* pProp, MM::ActionType eAct);
// int GetPosition(long& pos) const;
// int SetPosition(long pos);
// int GetPosition(long& pos);
private:
// long numPos_;
EFW_INFO EFWInfo;
int iConnectedEFWNum;
long lLastPos;
bool initialized_;
MM::MMTime changedTime_;
char ConnectedEFWName[32][32];
char sz_ModelIndex[64];
bool bPosWait;
// long position_;
};