| 1 |
|
| 2 |
|
| 3 |
#ifndef __DVBUFFER_3_H |
| 4 |
#define __DVBUFFER_3_H |
| 5 |
#include <cvd/byte.h> |
| 6 |
#include <cvd/colourspaces.h> |
| 7 |
#include <cvd/rgb.h> |
| 8 |
#include <cvd/videobuffer.h> |
| 9 |
#include <inttypes.h> |
| 10 |
|
| 11 |
namespace CVD |
| 12 |
{ |
| 13 |
namespace Exceptions |
| 14 |
{ |
| 15 |
namespace DVBuffer3 |
| 16 |
{ |
| 17 |
|
| 18 |
|
| 19 |
struct All : public CVD::Exceptions::VideoBuffer::All |
| 20 |
{ |
| 21 |
All(std::string sWhat) |
| 22 |
: CVD::Exceptions::VideoBuffer::All("DVBuffer3: " + sWhat) |
| 23 |
{ |
| 24 |
} |
| 25 |
}; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
namespace DV3 |
| 31 |
{ |
| 32 |
|
| 33 |
|
| 34 |
enum DV3Feature |
| 35 |
{ |
| 36 |
BRIGHTNESS, |
| 37 |
EXPOSURE, |
| 38 |
SHARPNESS, |
| 39 |
WHITE_BALANCE, |
| 40 |
HUE, |
| 41 |
SATURATION, |
| 42 |
GAMMA, |
| 43 |
SHUTTER, |
| 44 |
GAIN, |
| 45 |
IRIS, |
| 46 |
FOCUS, |
| 47 |
ZOOM, |
| 48 |
PAN, |
| 49 |
TILT, |
| 50 |
FRAME_RATE |
| 51 |
}; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
enum DV3ColourSpace |
| 56 |
{ |
| 57 |
MONO8, |
| 58 |
MONO16, |
| 59 |
MONO16S, |
| 60 |
RGB8, |
| 61 |
RGB16, |
| 62 |
RGB16S, |
| 63 |
YUV411, |
| 64 |
YUV422, |
| 65 |
YUV444, |
| 66 |
RAW8, |
| 67 |
RAW16 |
| 68 |
}; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
enum DV3ColourFilter |
| 74 |
{ |
| 75 |
UNDEFINED = -1, |
| 76 |
RGGB = 0, |
| 77 |
GBRG = 1, |
| 78 |
GRBG = 2, |
| 79 |
BGGR = 3 |
| 80 |
}; |
| 81 |
|
| 82 |
#ifndef DOXYGEN_IGNORE_INTERNAL |
| 83 |
|
| 84 |
template <class C> |
| 85 |
struct CSConvert |
| 86 |
{ |
| 87 |
static const DV3ColourSpace space = C::Error__type_not_valid_for_camera; |
| 88 |
}; |
| 89 |
template <> |
| 90 |
struct CSConvert<byte> |
| 91 |
{ |
| 92 |
static const DV3ColourSpace space = MONO8; |
| 93 |
}; |
| 94 |
template <> |
| 95 |
struct CSConvert<short unsigned int> |
| 96 |
{ |
| 97 |
static const DV3ColourSpace space = MONO16; |
| 98 |
}; |
| 99 |
template <> |
| 100 |
struct CSConvert<yuv411> |
| 101 |
{ |
| 102 |
static const DV3ColourSpace space = YUV411; |
| 103 |
}; |
| 104 |
template <> |
| 105 |
struct CSConvert<yuv422> |
| 106 |
{ |
| 107 |
static const DV3ColourSpace space = YUV422; |
| 108 |
}; |
| 109 |
template <> |
| 110 |
struct CSConvert<Rgb<byte>> |
| 111 |
{ |
| 112 |
static const DV3ColourSpace space = RGB8; |
| 113 |
}; |
| 114 |
template <> |
| 115 |
struct CSConvert<bayer_bggr> |
| 116 |
{ |
| 117 |
static const DV3ColourSpace space = RAW8; |
| 118 |
}; |
| 119 |
template <> |
| 120 |
struct CSConvert<bayer_gbrg> |
| 121 |
{ |
| 122 |
static const DV3ColourSpace space = RAW8; |
| 123 |
}; |
| 124 |
template <> |
| 125 |
struct CSConvert<bayer_grbg> |
| 126 |
{ |
| 127 |
static const DV3ColourSpace space = RAW8; |
| 128 |
}; |
| 129 |
template <> |
| 130 |
struct CSConvert<bayer_rggb> |
| 131 |
{ |
| 132 |
static const DV3ColourSpace space = RAW8; |
| 133 |
}; |
| 134 |
template <> |
| 135 |
struct CSConvert<bayer_bggr16be> |
| 136 |
{ |
| 137 |
static const DV3ColourSpace space = RAW16; |
| 138 |
}; |
| 139 |
template <> |
| 140 |
struct CSConvert<bayer_gbrg16be> |
| 141 |
{ |
| 142 |
static const DV3ColourSpace space = RAW16; |
| 143 |
}; |
| 144 |
template <> |
| 145 |
struct CSConvert<bayer_grbg16be> |
| 146 |
{ |
| 147 |
static const DV3ColourSpace space = RAW16; |
| 148 |
}; |
| 149 |
template <> |
| 150 |
struct CSConvert<bayer_rggb16be> |
| 151 |
{ |
| 152 |
static const DV3ColourSpace space = RAW16; |
| 153 |
}; |
| 154 |
|
| 155 |
template <class C> |
| 156 |
struct CSFilter |
| 157 |
{ |
| 158 |
static const DV3ColourFilter filter = UNDEFINED; |
| 159 |
}; |
| 160 |
template <> |
| 161 |
struct CSFilter<bayer_bggr> |
| 162 |
{ |
| 163 |
static const DV3ColourFilter filter = BGGR; |
| 164 |
}; |
| 165 |
template <> |
| 166 |
struct CSFilter<bayer_gbrg> |
| 167 |
{ |
| 168 |
static const DV3ColourFilter filter = GBRG; |
| 169 |
}; |
| 170 |
template <> |
| 171 |
struct CSFilter<bayer_grbg> |
| 172 |
{ |
| 173 |
static const DV3ColourFilter filter = GRBG; |
| 174 |
}; |
| 175 |
template <> |
| 176 |
struct CSFilter<bayer_rggb> |
| 177 |
{ |
| 178 |
static const DV3ColourFilter filter = RGGB; |
| 179 |
}; |
| 180 |
template <> |
| 181 |
struct CSFilter<bayer_bggr16be> |
| 182 |
{ |
| 183 |
static const DV3ColourFilter filter = BGGR; |
| 184 |
}; |
| 185 |
template <> |
| 186 |
struct CSFilter<bayer_gbrg16be> |
| 187 |
{ |
| 188 |
static const DV3ColourFilter filter = GBRG; |
| 189 |
}; |
| 190 |
template <> |
| 191 |
struct CSFilter<bayer_grbg16be> |
| 192 |
{ |
| 193 |
static const DV3ColourFilter filter = GRBG; |
| 194 |
}; |
| 195 |
template <> |
| 196 |
struct CSFilter<bayer_rggb16be> |
| 197 |
{ |
| 198 |
static const DV3ColourFilter filter = RGGB; |
| 199 |
}; |
| 200 |
|
| 201 |
struct LibDCParams; |
| 202 |
#endif |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
class RawDVBuffer3 : public virtual RawVideoBuffer |
| 209 |
{ |
| 210 |
public: |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
RawDVBuffer3(DV3ColourSpace colourspace, |
| 220 |
int nCamNumber = 0, |
| 221 |
uint64_t cam_guid = -1, |
| 222 |
int cam_unit = -1, |
| 223 |
bool verbose = 0, |
| 224 |
bool bus_reset = 0, |
| 225 |
ImageRef irSize = ImageRef(-1, -1), |
| 226 |
float fFrameRate = -1.0, |
| 227 |
ImageRef irOffset = ImageRef(-1, -1), |
| 228 |
int format7_mode = -1); |
| 229 |
|
| 230 |
~RawDVBuffer3(); |
| 231 |
static void stopAllTransmissions(void); |
| 232 |
inline ImageRef size() { return mirSize; } |
| 233 |
inline ImageRef offset() { return mirOffset; } |
| 234 |
inline double frame_rate() { return mdFramerate; } |
| 235 |
inline DV3ColourFilter colour_filter() { return mColourfilter; } |
| 236 |
|
| 237 |
VideoFrame<byte>* get_frame(); |
| 238 |
void put_frame(VideoFrame<byte>* f); |
| 239 |
bool frame_pending(); |
| 240 |
|
| 241 |
void set_feature_value(DV3Feature nFeature, unsigned int nValue); |
| 242 |
unsigned int get_feature_value(DV3Feature nFeature); |
| 243 |
std::pair<unsigned int, unsigned int> get_feature_min_max(DV3Feature nFeature); |
| 244 |
void auto_on_off(DV3Feature nFeature, bool bValue); |
| 245 |
void power_on_off(DV3Feature nFeature, bool bValue); |
| 246 |
|
| 247 |
private: |
| 248 |
ImageRef mirSize; |
| 249 |
ImageRef mirOffset; |
| 250 |
double mdFramerate; |
| 251 |
DV3ColourFilter mColourfilter; |
| 252 |
|
| 253 |
LibDCParams* mpLDCP; |
| 254 |
}; |
| 255 |
|
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
template <class pixel_T> |
| 263 |
class DVBuffer3 : public VideoBuffer<pixel_T>, public DV3::RawDVBuffer3 |
| 264 |
{ |
| 265 |
public: |
| 266 |
DVBuffer3(unsigned int nCamNumber = 0, |
| 267 |
ImageRef irSize = ImageRef(-1, -1), |
| 268 |
float fFPS = -1.0, |
| 269 |
ImageRef irOffset = ImageRef(-1, -1), |
| 270 |
bool verbose = 0, |
| 271 |
bool bus_reset = 0, |
| 272 |
int format7_mode = -1) |
| 273 |
: VideoBuffer<pixel_T>(VideoBufferType::Live) |
| 274 |
, RawDVBuffer3(DV3::CSConvert<pixel_T>::space, nCamNumber, 0, -1, verbose, bus_reset, irSize, fFPS, irOffset, format7_mode) |
| 275 |
{ |
| 276 |
if(DV3::CSFilter<pixel_T>::filter != DV3::UNDEFINED && colour_filter() != DV3::CSFilter<pixel_T>::filter) |
| 277 |
throw(Exceptions::DVBuffer3::All("wrong colour filter expected")); |
| 278 |
} |
| 279 |
|
| 280 |
virtual ~DVBuffer3() { } |
| 281 |
double frame_rate() { return RawDVBuffer3::frame_rate(); } |
| 282 |
ImageRef size() { return RawDVBuffer3::size(); } |
| 283 |
virtual VideoFrame<pixel_T>* get_frame() |
| 284 |
{ |
| 285 |
return reinterpret_cast<VideoFrame<pixel_T>*>(RawDVBuffer3::get_frame()); |
| 286 |
} |
| 287 |
virtual void put_frame(VideoFrame<pixel_T>* f) |
| 288 |
{ |
| 289 |
RawDVBuffer3::put_frame(reinterpret_cast<VideoFrame<byte>*>(f)); |
| 290 |
} |
| 291 |
virtual bool frame_pending() { return RawDVBuffer3::frame_pending(); } |
| 292 |
virtual void seek_to(double) { } |
| 293 |
}; |
| 294 |
|
| 295 |
} |
| 296 |
|
| 297 |
#endif |