-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathBaslerVideoCtrlObj.cpp
More file actions
234 lines (214 loc) · 6.43 KB
/
Copy pathBaslerVideoCtrlObj.cpp
File metadata and controls
234 lines (214 loc) · 6.43 KB
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
232
233
234
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2022
// European Synchrotron Radiation Facility
// CS40220 38043 Grenoble Cedex 9
// FRANCE
//
// Contact: lima@esrf.fr
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#include "BaslerVideoCtrlObj.h"
#include "BaslerCamera.h"
#include "BaslerInterface.h"
using namespace lima;
using namespace lima::Basler;
VideoCtrlObj::VideoCtrlObj(Camera& cam) :
m_cam(cam)
{
m_cam.m_video = this;
}
VideoCtrlObj::~VideoCtrlObj()
{
}
void VideoCtrlObj::getSupportedVideoMode(std::list<VideoMode>& aList) const
{
DEB_MEMBER_FUNCT();
struct _VideoMode
{
const char* stringMode;
VideoMode mode;
};
static const _VideoMode BaslerVideoMode[] =
{
{"BayerRG16",BAYER_RG16},
{"BayerBG16",BAYER_BG16},
{"BayerRG12",BAYER_RG16},
{"BayerBG12",BAYER_BG16},
{"BayerRG8",BAYER_RG8},
{"BayerBG8",BAYER_BG8},
{"RGB8Packed",RGB24},
{"BGR8Packed",BGR24},
{"YUV411Packed",YUV411PACKED},
{"YUV422Packed",YUV422PACKED},
{"YUV444Packed",YUV444PACKED},
{"Mono16",Y16},
{"Mono12",Y16},
{"Mono10",Y16},
{"Mono8",Y8},
{NULL,Y8}
};
for(const _VideoMode* pt = BaslerVideoMode;pt->stringMode;++pt)
{
GenApi::IEnumEntry *anEntry =
m_cam.Camera_->PixelFormat.GetEntryByName(pt->stringMode);
if(anEntry && GenApi::IsAvailable(anEntry))
aList.push_back(pt->mode);
}
}
void VideoCtrlObj::getVideoMode(VideoMode &mode) const
{
DEB_MEMBER_FUNCT();
PixelFormatEnums aCurrentPixelFormat = m_cam.Camera_->PixelFormat.GetValue();
switch(aCurrentPixelFormat)
{
case PixelFormat_Mono8: mode = Y8; break;
case PixelFormat_Mono10: mode = Y16; break;
case PixelFormat_Mono12: mode = Y16; break;
case PixelFormat_Mono16: mode = Y16; break;
case PixelFormat_BayerRG8: mode = BAYER_RG8; break;
case PixelFormat_BayerBG8: mode = BAYER_BG8; break;
case PixelFormat_BayerRG10: mode = BAYER_RG16; break;
case PixelFormat_BayerBG10: mode = BAYER_BG16; break;
case PixelFormat_BayerRG12: mode = BAYER_RG16; break;
case PixelFormat_BayerBG12: mode = BAYER_BG16; break;
case PixelFormat_RGB8Packed: mode = RGB24; break;
case PixelFormat_BGR8Packed: mode = BGR24; break;
case PixelFormat_RGBA8Packed: mode = RGB32; break;
case PixelFormat_BGRA8Packed: mode = BGR32; break;
case PixelFormat_YUV411Packed: mode = YUV411PACKED; break;
case PixelFormat_YUV422Packed: mode = YUV422PACKED; break;
case PixelFormat_YUV444Packed: mode = YUV444PACKED; break;
case PixelFormat_BayerRG16: mode = BAYER_RG16; break;
case PixelFormat_BayerBG16: mode = BAYER_BG16; break;
default:
THROW_HW_ERROR(NotSupported) << "Pixel type not supported yet";
}
}
void VideoCtrlObj::setVideoMode(VideoMode mode)
{
DEB_MEMBER_FUNCT();
std::list<PixelFormatEnums> pixelformat;
switch(mode)
{
case Y8:
pixelformat.push_back(PixelFormat_Mono8);
break;
case Y16:
pixelformat.push_back(PixelFormat_Mono16);
pixelformat.push_back(PixelFormat_Mono12);
pixelformat.push_back(PixelFormat_Mono10);
break;
case BAYER_RG8:
pixelformat.push_back(PixelFormat_BayerRG8);
break;
case BAYER_BG8:
pixelformat.push_back(PixelFormat_BayerBG8);
break;
case BAYER_RG16:
pixelformat.push_back(PixelFormat_BayerRG16);
pixelformat.push_back(PixelFormat_BayerRG12);
pixelformat.push_back(PixelFormat_BayerRG10);
break;
case BAYER_BG16:
pixelformat.push_back(PixelFormat_BayerBG16);
pixelformat.push_back(PixelFormat_BayerBG12);
pixelformat.push_back(PixelFormat_BayerBG10);
break;
case RGB24:
pixelformat.push_back(PixelFormat_RGB8Packed);
break;
case BGR24:
pixelformat.push_back(PixelFormat_BGR8Packed);
break;
case RGB32:
pixelformat.push_back(PixelFormat_RGBA8Packed);
break;
case BGR32:
pixelformat.push_back(PixelFormat_BGRA8Packed);
break;
case YUV411PACKED:
pixelformat.push_back(PixelFormat_YUV411Packed);
break;
case YUV422PACKED:
pixelformat.push_back(PixelFormat_YUV422Packed);
break;
case YUV444PACKED:
pixelformat.push_back(PixelFormat_YUV444Packed);
break;
default:
THROW_HW_ERROR(NotSupported) << "Mode type not supported yet";
}
bool succeed = false;
std::string errorMsg;
for(std::list<PixelFormatEnums>::iterator i = pixelformat.begin();
!succeed && i != pixelformat.end();++i)
{
try
{
m_cam.Camera_->PixelFormat.SetValue(*i);
succeed = true;
}
catch (Pylon::GenericException &e)
{
errorMsg += e.GetDescription() + '\n';
}
}
if(!succeed)
THROW_HW_ERROR(Error) << errorMsg;
}
void VideoCtrlObj::setLive(bool flag)
{
if(flag)
{
m_cam.setNbFrames(0);
m_cam.prepareAcq();
m_cam.startAcq();
}
else
m_cam.stopAcq();
}
void VideoCtrlObj::getLive(bool &flag) const
{
}
void VideoCtrlObj::getGain(double &aGain) const
{
m_cam.getGain(aGain);
}
void VideoCtrlObj::setGain(double aGain)
{
m_cam.setGain(aGain);
}
void VideoCtrlObj::checkBin(Bin &bin)
{
bin = Bin(1,1); // Do not manage Hw Bin
}
void VideoCtrlObj::checkRoi(const Roi&,Roi& hw_roi)
{
hw_roi = Roi(0,0,
m_cam.Camera_->Width.GetMax(),
m_cam.Camera_->Height.GetMax());
}
bool VideoCtrlObj::checkAutoGainMode(AutoGainMode mode) const
{
return mode == OFF ? true :
GenApi::IsAvailable(m_cam.Camera_->GainAuto) &&
GenApi::IsAvailable(m_cam.Camera_->GainSelector);
}
void VideoCtrlObj::setHwAutoGainMode(AutoGainMode mode)
{
m_cam.setAutoGain(mode == ON);
}