libcvd
dvbuffer3.h
1 // -*- c++ -*-
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  {
20  {
21  All(std::string sWhat)
22  : CVD::Exceptions::VideoBuffer::All("DVBuffer3: " + sWhat)
23  {
24  }
25  };
26  }
27 }
28 
30 namespace DV3
31 {
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 
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 
74  {
75  UNDEFINED = -1,
76  RGGB = 0,
77  GBRG = 1,
78  GRBG = 2,
79  BGGR = 3
80  };
81 
82 #ifndef DOXYGEN_IGNORE_INTERNAL
83  // Translation helper classes to go from CVD-types to the above
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 <>
101  {
102  static const DV3ColourSpace space = YUV411;
103  };
104  template <>
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 <>
116  {
117  static const DV3ColourSpace space = RAW8;
118  };
119  template <>
121  {
122  static const DV3ColourSpace space = RAW8;
123  };
124  template <>
126  {
127  static const DV3ColourSpace space = RAW8;
128  };
129  template <>
131  {
132  static const DV3ColourSpace space = RAW8;
133  };
134  template <>
136  {
137  static const DV3ColourSpace space = RAW16;
138  };
139  template <>
141  {
142  static const DV3ColourSpace space = RAW16;
143  };
144  template <>
146  {
147  static const DV3ColourSpace space = RAW16;
148  };
149  template <>
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 <>
162  {
163  static const DV3ColourFilter filter = BGGR;
164  };
165  template <>
167  {
168  static const DV3ColourFilter filter = GBRG;
169  };
170  template <>
172  {
173  static const DV3ColourFilter filter = GRBG;
174  };
175  template <>
177  {
178  static const DV3ColourFilter filter = RGGB;
179  };
180  template <>
182  {
183  static const DV3ColourFilter filter = BGGR;
184  };
185  template <>
187  {
188  static const DV3ColourFilter filter = GBRG;
189  };
190  template <>
192  {
193  static const DV3ColourFilter filter = GRBG;
194  };
195  template <>
197  {
198  static const DV3ColourFilter filter = RGGB;
199  };
200 
201  struct LibDCParams;
202 #endif
203 
208  class RawDVBuffer3 : public virtual RawVideoBuffer
209  {
210  public:
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;
253  LibDCParams* mpLDCP;
254  };
255 
256 }
257 
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)
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(); }
284  {
285  return reinterpret_cast<VideoFrame<pixel_T>*>(RawDVBuffer3::get_frame());
286  }
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
DV3ColourSpace
This enumerates all the colourspace types supported by DC1394 N.b.
Definition: dvbuffer3.h:55
Definition: dvbuffer3.h:85
Non-templated libDC1394 interface.
Definition: dvbuffer3.h:208
Base class which provides untyped access to video grabber objects.
Definition: videobuffer.h:39
Definition: dvbuffer3.h:156
A colour consisting of red, green and blue components.
Definition: rgb.h:25
All classes and functions are within the CVD namespace.
Definition: argb.h:6
virtual bool frame_pending()
Is there a frame waiting in the buffer? This function does not block.
Definition: dvbuffer3.h:291
16bit big endian Bayer datatype representing the colour filter pattern RGGB
Definition: colourspaces.h:157
A datatype to represent yuv411 (uyyvyy) data, typically from firewire cameras.
Definition: colourspaces.h:176
Base class for objects which provide a typed video stream.
Definition: videobuffer.h:88
ImageRef size()
The size of the VideoFrames returned by this buffer.
Definition: dvbuffer3.h:282
virtual VideoFrame< pixel_T > * get_frame()
Returns the next frame from the buffer. This function blocks until a frame is ready.
Definition: dvbuffer3.h:283
Class for all DVBuffer3 exceptions.
Definition: dvbuffer3.h:19
The buffer has live semantics: frames are throttled by something externa, but VideoBuffer::frame_pend...
Definition: videobuffer.h:23
virtual void seek_to(double)
Go to a particular point in the video buffer (only implemented in buffers of recorded video) ...
Definition: dvbuffer3.h:292
DV3Feature
This enumerates the list of controllable features (This isn&#39;t the full set of DC1394 ones...
Definition: dvbuffer3.h:34
DV3ColourFilter
This enumerates the different colour filter tile patterns for Bayer images.
Definition: dvbuffer3.h:73
A video buffer from a Firewire (IEEE 1394) camera.
Definition: dvbuffer3.h:263
Definition: dvbuffer3_dc1394v1.cc:19
Definition: image_ref.h:29
double frame_rate()
What is the (expected) frame rate of this video buffer, in frames per second?
Definition: dvbuffer3.h:234
Bayer datatype representing the colour filter pattern GRBG.
Definition: colourspaces.h:40
Bayer datatype representing the colour filter pattern GBRG.
Definition: colourspaces.h:27
ImageRef size()
The size of the VideoFrames returned by this buffer.
Definition: dvbuffer3.h:232
unsigned char byte
An 8-bit datatype.
Definition: byte.h:8
Base class for all VideoBuffer exceptions.
Definition: videobuffer.h:153
16 bit big endian Bayer datatype representing the colour filter pattern BGGR
Definition: colourspaces.h:118
16bit big endian Bayer datatype representing the colour filter pattern GRBG
Definition: colourspaces.h:144
Bayer datatype representing the colour filter pattern BGGR.
Definition: colourspaces.h:14
A datatype to represent yuv422 (yuyv) data.
Definition: colourspaces.h:192
virtual void put_frame(VideoFrame< pixel_T > *f)
Tell the buffer that you are finished with this frame.
Definition: dvbuffer3.h:287
double frame_rate()
What is the (expected) frame rate of this video buffer, in frames per second?
Definition: dvbuffer3.h:281
Bayer datatype representing the colour filter pattern RGGB.
Definition: colourspaces.h:53
16bit big endian Bayer datatype representing the colour filter pattern GBRG
Definition: colourspaces.h:131