Jetson Linux API Reference

32.7.5 Release
Types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2023, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA CORPORATION nor the names of its
13  * contributors may be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
36 #ifndef _ARGUS_TYPES_H
37 #define _ARGUS_TYPES_H
38 
39 #include <stdint.h>
40 #include <vector>
41 #include <string>
42 #include <assert.h>
43 
44 #include <EGL/egl.h>
45 #include <EGL/eglext.h>
46 
47 // Some versions of the Xlib.h header file define 'Status' to 'int'.
48 // This collides with the libargus 'Status' type.
49 // If 'Status' is defined then undefine it and use a typedef instead.
50 #ifdef Status
51 #undef Status
52 typedef int Status;
53 #endif // Status
54 
55 namespace Argus
56 {
57 
58 /*
59  * Forward declaration of standard objects
60  */
61 class CameraDevice;
62 class CameraProvider;
63 class CaptureSession;
64 class CaptureMetadata;
65 class CaptureMetadataContainer;
66 class Event;
67 class EventQueue;
68 class InputStream;
69 class OutputStream;
70 class OutputStreamSettings;
71 class Request;
72 class SensorMode;
73 
74 /*
75  * Forward declaration of standard interfaces
76  */
77 class ICameraProperties;
78 class ICameraProvider;
79 class ICaptureSession;
80 class IAutoControlSettings;
81 class IRequest;
82 class IStream;
83 class IStreamSettings;
84 
88 const uint64_t TIMEOUT_INFINITE = 0xFFFFFFFFFFFFFFFF;
89 
93 enum Status
94 {
96  STATUS_OK = 0,
97 
100 
103 
106 
109 
112 
115 
118 
121 
124 
125  // Number of elements in this enum.
127 };
128 
133 {
138 
140 };
141 
146 {
150 
153 };
154 
159 {
163 
165 };
166 
170 DEFINE_NAMED_UUID_CLASS(AeAntibandingMode);
171 DEFINE_UUID(AeAntibandingMode, AE_ANTIBANDING_MODE_OFF, AD1E5560,9C16,11E8,B568,18,00,20,0C,9A,66);
172 DEFINE_UUID(AeAntibandingMode, AE_ANTIBANDING_MODE_AUTO, AD1E5561,9C16,11E8,B568,18,00,20,0C,9A,66);
173 DEFINE_UUID(AeAntibandingMode, AE_ANTIBANDING_MODE_50HZ, AD1E5562,9C16,11E8,B568,18,00,20,0C,9A,66);
174 DEFINE_UUID(AeAntibandingMode, AE_ANTIBANDING_MODE_60HZ, AD1E5563,9C16,11E8,B568,18,00,20,0C,9A,66);
175 
180 DEFINE_UUID(AeMode, AE_MODE_OFF, FCACB1E0,C6E5,11ED,A901,08,00,20,0C,9A,66);
181 DEFINE_UUID(AeMode, AE_MODE_ON, FCACB1E1,C6E5,11ED,A901,08,00,20,0C,9A,66);
182 DEFINE_UUID(AeMode, AE_MODE_OTHERS, FCACB1E2,C6E5,11ED,A901,08,00,20,0C,9A,66);
183 
187 DEFINE_NAMED_UUID_CLASS(AeFlickerState);
188 DEFINE_UUID(AeFlickerState, AE_FLICKER_NONE, AD1E5564,9C16,11E8,B568,18,00,20,0C,9A,66);
189 DEFINE_UUID(AeFlickerState, AE_FLICKER_50HZ, AD1E5565,9C16,11E8,B568,18,00,20,0C,9A,66);
190 DEFINE_UUID(AeFlickerState, AE_FLICKER_60HZ, AD1E5566,9C16,11E8,B568,18,00,20,0C,9A,66);
191 
195 DEFINE_NAMED_UUID_CLASS(AeState);
196 DEFINE_UUID(AeState, AE_STATE_INACTIVE, D2EBEA50,9C16,11E8,B568,18,00,20,0C,9A,66);
197 DEFINE_UUID(AeState, AE_STATE_SEARCHING, D2EBEA51,9C16,11E8,B568,18,00,20,0C,9A,66);
198 DEFINE_UUID(AeState, AE_STATE_CONVERGED, D2EBEA52,9C16,11E8,B568,18,00,20,0C,9A,66);
199 DEFINE_UUID(AeState, AE_STATE_FLASH_REQUIRED, D2EBEA53,9C16,11E8,B568,18,00,20,0C,9A,66);
200 DEFINE_UUID(AeState, AE_STATE_TIMEOUT, D2EBEA54,9C16,11E8,B568,18,00,20,0C,9A,66);
201 
205 DEFINE_NAMED_UUID_CLASS(AwbMode);
206 DEFINE_UUID(AwbMode, AWB_MODE_OFF, FB3F365A,CC62,11E5,9956,62,56,62,87,07,61);
207 DEFINE_UUID(AwbMode, AWB_MODE_AUTO, FB3F365B,CC62,11E5,9956,62,56,62,87,07,61);
208 DEFINE_UUID(AwbMode, AWB_MODE_INCANDESCENT, FB3F365C,CC62,11E5,9956,62,56,62,87,07,61);
209 DEFINE_UUID(AwbMode, AWB_MODE_FLUORESCENT, FB3F365D,CC62,11E5,9956,62,56,62,87,07,61);
210 DEFINE_UUID(AwbMode, AWB_MODE_WARM_FLUORESCENT, FB3F365E,CC62,11E5,9956,62,56,62,87,07,61);
211 DEFINE_UUID(AwbMode, AWB_MODE_DAYLIGHT, FB3F365F,CC62,11E5,9956,62,56,62,87,07,61);
212 DEFINE_UUID(AwbMode, AWB_MODE_CLOUDY_DAYLIGHT, FB3F3660,CC62,11E5,9956,62,56,62,87,07,61);
213 DEFINE_UUID(AwbMode, AWB_MODE_TWILIGHT, FB3F3661,CC62,11E5,9956,62,56,62,87,07,61);
214 DEFINE_UUID(AwbMode, AWB_MODE_SHADE, FB3F3662,CC62,11E5,9956,62,56,62,87,07,61);
215 DEFINE_UUID(AwbMode, AWB_MODE_MANUAL, 20FB45DA,C49F,4293,AB02,13,3F,8C,CA,DD,69);
216 
220 DEFINE_NAMED_UUID_CLASS(AwbState);
221 DEFINE_UUID(AwbState, AWB_STATE_INACTIVE, E33CDB30,9C16,11E8,B568,18,00,20,0C,9A,66);
222 DEFINE_UUID(AwbState, AWB_STATE_SEARCHING, E33CDB31,9C16,11E8,B568,18,00,20,0C,9A,66);
223 DEFINE_UUID(AwbState, AWB_STATE_CONVERGED, E33CDB32,9C16,11E8,B568,18,00,20,0C,9A,66);
224 DEFINE_UUID(AwbState, AWB_STATE_LOCKED, E33CDB33,9C16,11E8,B568,18,00,20,0C,9A,66);
225 
230 DEFINE_UUID(AfMode, AF_MODE_OFF, FCACB1E3,C6E5,11ED,A901,08,00,20,0C,9A,66);
231 DEFINE_UUID(AfMode, AF_MODE_AUTO, FCACB1E4,C6E5,11ED,A901,08,00,20,0C,9A,66);
232 DEFINE_UUID(AfMode, AF_MODE_MANUAL, FCACB1E5,C6E5,11ED,A901,08,00,20,0C,9A,66);
233 DEFINE_UUID(AfMode, AF_MODE_OTHERS, FCACB1E6,C6E5,11ED,A901,08,00,20,0C,9A,66);
234 
249 DEFINE_NAMED_UUID_CLASS(CaptureIntent);
250 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_MANUAL, FB3F3663,CC62,11E5,9956,62,56,62,87,07,61);
251 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_PREVIEW, FB3F3664,CC62,11E5,9956,62,56,62,87,07,61);
252 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_STILL_CAPTURE, FB3F3665,CC62,11E5,9956,62,56,62,87,07,61);
253 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_VIDEO_RECORD, FB3F3666,CC62,11E5,9956,62,56,62,87,07,61);
254 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_VIDEO_SNAPSHOT, FB3F3667,CC62,11E5,9956,62,56,62,87,07,61);
255 
259 DEFINE_NAMED_UUID_CLASS(DenoiseMode);
260 DEFINE_UUID(DenoiseMode, DENOISE_MODE_OFF, FB3F3668,CC62,11E5,9956,62,56,62,87,07,61);
261 DEFINE_UUID(DenoiseMode, DENOISE_MODE_FAST, FB3F3669,CC62,11E5,9956,62,56,62,87,07,61);
262 DEFINE_UUID(DenoiseMode, DENOISE_MODE_HIGH_QUALITY, FB3F366A,CC62,11E5,9956,62,56,62,87,07,61);
263 
267 DEFINE_NAMED_UUID_CLASS(EdgeEnhanceMode);
268 DEFINE_UUID(EdgeEnhanceMode, EDGE_ENHANCE_MODE_OFF, F7100B40,6A5F,11E6,BDF4,08,00,20,0C,9A,66);
269 DEFINE_UUID(EdgeEnhanceMode, EDGE_ENHANCE_MODE_FAST, F7100B41,6A5F,11E6,BDF4,08,00,20,0C,9A,66);
270 DEFINE_UUID(EdgeEnhanceMode, EDGE_ENHANCE_MODE_HIGH_QUALITY, F7100B42,6A5F,11E6,BDF4,08,00,20,0C,9A,66);
271 
275 DEFINE_NAMED_UUID_CLASS(ExtensionName);
276 
280 DEFINE_NAMED_UUID_CLASS(PixelFormat);
281 DEFINE_UUID(PixelFormat, PIXEL_FMT_UNKNOWN, 00000000,93d5,11e5,0000,1c,b7,2c,ef,d4,1e);
282 DEFINE_UUID(PixelFormat, PIXEL_FMT_Y8, 569be14a,93d5,11e5,91bc,1c,b7,2c,ef,d4,1e);
283 DEFINE_UUID(PixelFormat, PIXEL_FMT_Y16, 56ddb19c,93d5,11e5,8e2c,1c,b7,2c,ef,d4,1e);
284 DEFINE_UUID(PixelFormat, PIXEL_FMT_YCbCr_420_888, 570c10e6,93d5,11e5,8ff3,1c,b7,2c,ef,d4,1e);
285 DEFINE_UUID(PixelFormat, PIXEL_FMT_YCbCr_422_888, 573a7940,93d5,11e5,99c2,1c,b7,2c,ef,d4,1e);
286 DEFINE_UUID(PixelFormat, PIXEL_FMT_YCbCr_444_888, 576043dc,93d5,11e5,8983,1c,b7,2c,ef,d4,1e);
287 DEFINE_UUID(PixelFormat, PIXEL_FMT_JPEG_BLOB, 578b08c4,93d5,11e5,9686,1c,b7,2c,ef,d4,1e);
288 DEFINE_UUID(PixelFormat, PIXEL_FMT_RAW16, 57b484d8,93d5,11e5,aeb6,1c,b7,2c,ef,d4,1e);
289 DEFINE_UUID(PixelFormat, PIXEL_FMT_P016, 57b484d9,93d5,11e5,aeb6,1c,b7,2c,ef,d4,1e);
290 
295 DEFINE_NAMED_UUID_CLASS(SensorModeType);
296 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_DEPTH, 64483464,4b91,11e6,bbbd,40,16,7e,ab,86,92);
297 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_YUV, 6453e00c,4b91,11e6,871d,40,16,7e,ab,86,92);
298 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_RGB, 6463d4c6,4b91,11e6,88a3,40,16,7e,ab,86,92);
299 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_BAYER, 646f04ea,4b91,11e6,9c06,40,16,7e,ab,86,92);
300 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_BAYER_PWL, f6a08220,6a0f,11eb,8572,08,00,20,0c,9a,66);
301 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_BAYER_DOL, f6a08221,6a0f,11eb,8572,08,00,20,0c,9a,66);
302 
306 DEFINE_NAMED_UUID_CLASS(SensorPlacement);
307 DEFINE_UUID(SensorPlacement, SENSOR_PLACEMENT_REAR_OR_BOTTOM_OR_BOTTOM_LEFT, 01dba8b0,1946,11eb,8b6f,08,00,20,0c,9a,66);
308 DEFINE_UUID(SensorPlacement, SENSOR_PLACEMENT_FRONT_OR_TOP_OR_CENTER_LEFT, 01dba8b1,1946,11eb,8b6f,08,00,20,0c,9a,66);
309 DEFINE_UUID(SensorPlacement, SENSOR_PLACEMENT_CENTER_OR_CENTER_RIGHT, 01dba8b2,1946,11eb,8b6f,08,00,20,0c,9a,66);
310 DEFINE_UUID(SensorPlacement, SENSOR_PLACEMENT_TOP_LEFT, 01dba8b3,1946,11eb,8b6f,08,00,20,0c,9a,66);
311 DEFINE_UUID(SensorPlacement, SENSOR_PLACEMENT_BOTTOM_RIGHT, 01dba8b4,1946,11eb,8b6f,08,00,20,0c,9a,66);
312 DEFINE_UUID(SensorPlacement, SENSOR_PLACEMENT_TOP_RIGHT, 01dba8b5,1946,11eb,8b6f,08,00,20,0c,9a,66);
313 
317 DEFINE_NAMED_UUID_CLASS(BayerPhase);
318 DEFINE_UUID(BayerPhase, BAYER_PHASE_UNKNOWN, b9d43270,6a0e,12eb,8572,08,00,20,0c,9a,66);
319 DEFINE_UUID(BayerPhase, BAYER_PHASE_RGGB, b9d43271,6a0e,12eb,8572,08,00,20,0c,9a,66);
320 DEFINE_UUID(BayerPhase, BAYER_PHASE_BGGR, b9d43272,6a0e,12eb,8572,08,00,20,0c,9a,66);
321 DEFINE_UUID(BayerPhase, BAYER_PHASE_GRBG, b9d43273,6a0e,12eb,8572,08,00,20,0c,9a,66);
322 DEFINE_UUID(BayerPhase, BAYER_PHASE_GBRG, b9d43274,6a0e,12eb,8572,08,00,20,0c,9a,66);
323 
328 {
329 protected:
331 
332 private:
333  NonCopyable(NonCopyable& other);
334  NonCopyable& operator=(NonCopyable& other);
335 };
336 
345 {
346 protected:
349 };
350 
354 class InterfaceID : public NamedUUID
355 {
356 public:
357  InterfaceID(uint32_t time_low_
358  , uint16_t time_mid_
359  , uint16_t time_hi_and_version_
360  , uint16_t clock_seq_
361  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
362  , const char* name)
363  : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_,
364  c0, c1, c2, c3, c4, c5, name)
365  {}
366 
368  : NamedUUID(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "IID_UNSPECIFIED")
369  {}
370 };
371 
376 {
377 public:
378 
384  virtual Interface* getInterface(const InterfaceID& interfaceId) = 0;
385 
386 protected:
388 };
389 
394 template <typename TheInterface>
395 inline TheInterface* interface_cast(InterfaceProvider* obj)
396 {
397  return static_cast<TheInterface*>(obj ? obj->getInterface(TheInterface::id()): 0);
398 }
399 
400 template <typename TheInterface>
401 inline TheInterface* interface_cast(const InterfaceProvider* obj)
402 {
403  return static_cast<TheInterface*>(
404  obj ? const_cast<const Interface*>(
405  const_cast<InterfaceProvider*>(obj)->getInterface(TheInterface::id())): 0);
406 }
407 
413 {
414 public:
415 
420  virtual void destroy() = 0;
421 
422 protected:
424 };
425 
430 template<typename T>
431 class rv : public T
432 {
433  rv();
434  ~rv();
435  rv(const rv&);
436  void operator=(const rv&);
437 };
438 
439 template<typename T>
440  rv<T>& move(T& self)
441 {
442  return *static_cast<rv<T>*>(&self);
443 }
450 template <typename T> struct remove_const;
451 template <typename T> struct remove_const<const T&>{ typedef T& type; };
452 template <typename T> struct remove_const<const T*>{ typedef T* type; };
453 template <typename T> struct remove_const<const T >{ typedef T type; };
454 template <typename T> struct remove_const { typedef T type; };
457 template <typename T>
459 {
460 public:
461  explicit UniqueObj(T* obj=NULL): m_obj(obj) {}
462 
463  void reset(T* obj=NULL)
464  { if (m_obj && (m_obj != obj)) const_cast<typename remove_const<T*>::type>(m_obj)->destroy(); m_obj = obj; }
465  T* release()
466  { T* obj = m_obj; m_obj = NULL; return obj; }
467 
468  UniqueObj( rv<UniqueObj>& moved ): m_obj(moved.release()) {}
469  UniqueObj& operator=( rv<UniqueObj>& moved ){ reset( moved.release()); return *this; }
470 
471  ~UniqueObj() { reset(); }
472 
473  T& operator*() const { return *m_obj; }
474  T* get() const { return m_obj; }
475 
476  operator bool() const { return !!m_obj; }
477 
478  operator rv<UniqueObj>&() { return *static_cast< rv<UniqueObj>*>(this); }
479  operator const rv<UniqueObj>&() const { return *static_cast<const rv<UniqueObj>*>(this); }
480 
481 private:
482  T* m_obj;
483 
484  T* operator->() const; // Prevent calling destroy() directly.
485  // Note: For getInterface functionality use interface_cast.
486 };
487 
488 template <typename TheInterface, typename TObject>
489 inline TheInterface* interface_cast(const UniqueObj<TObject>& obj)
490 {
491  return interface_cast<TheInterface>( obj.get());
492 }
493 
497 template <unsigned int N, typename T>
498 class Tuple
499 {
500 public:
501  Tuple() {}
502 
504  Tuple(T init)
505  {
506  for (unsigned int i = 0; i < N; i++)
507  m_data[i] = init;
508  }
509 
511  bool operator==(const Tuple<N,T>& rhs) const
512  {
513  return !memcmp(m_data, rhs.m_data, sizeof(m_data));
514  }
515 
517  bool operator!=(const Tuple<N,T>& rhs) const
518  {
519  return !(*this == rhs);
520  }
521 
524  {
525  for (unsigned int i = 0; i < N; i++)
526  m_data[i] += rhs.m_data[i];
527  return *this;
528  }
529 
532  {
533  for (unsigned int i = 0; i < N; i++)
534  m_data[i] -= rhs.m_data[i];
535  return *this;
536  }
537 
539  Tuple<N, T>& operator*=(const T& rhs)
540  {
541  for (unsigned int i = 0; i < N; i++)
542  m_data[i] *= rhs;
543  return *this;
544  }
545 
547  Tuple<N, T>& operator/=(const T& rhs)
548  {
549  for (unsigned int i = 0; i < N; i++)
550  m_data[i] /= rhs;
551  return *this;
552  }
553 
555  const Tuple<N, T> operator+(const Tuple<N, T>& rhs) const
556  {
557  return Tuple<N, T>(*this) += rhs;
558  }
559 
561  const Tuple<N, T> operator-(const Tuple<N, T>& rhs) const
562  {
563  return Tuple<N, T>(*this) -= rhs;
564  }
565 
567  const Tuple<N, T> operator*(const T& rhs) const
568  {
569  return Tuple<N, T>(*this) *= rhs;
570  }
571 
573  const Tuple<N, T> operator/(const T& rhs) const
574  {
575  return Tuple<N, T>(*this) /= rhs;
576  }
577 
578  T& operator[](unsigned int i) { assert(i < N); return m_data[i]; }
579  const T& operator[](unsigned int i) const { assert(i < N); return m_data[i]; }
580 
582  static unsigned int tupleSize() { return N; }
583 
584 protected:
585  T m_data[N];
586 };
587 
593 template <typename T>
594 class BayerTuple : public Tuple<BAYER_CHANNEL_COUNT, T>
595 {
596 public:
599 
600  BayerTuple(T init)
601  {
602  r() = gEven() = gOdd() = b() = init;
603  }
604 
605  BayerTuple(T _r, T _gEven, T _gOdd, T _b)
606  {
607  r() = _r;
608  gEven() = _gEven;
609  gOdd() = _gOdd;
610  b() = _b;
611  }
612 
621 };
622 
628 template <typename T>
629 class RGBTuple : public Tuple<RGB_CHANNEL_COUNT, T>
630 {
631 public:
632  RGBTuple() {}
634 
635  RGBTuple(T init)
636  {
637  r() = g() = b() = init;
638  }
639 
640  RGBTuple(T _r, T _g, T _b)
641  {
642  r() = _r;
643  g() = _g;
644  b() = _b;
645  }
646 
653 };
654 
660 template <typename T>
661 class Point2D : public Tuple<COORDINATE_2D_COUNT, T>
662 {
663 public:
664  Point2D() {}
666 
667  Point2D(T init)
668  {
669  x() = y() = init;
670  }
671 
672  Point2D(T _x, T _y)
673  {
674  x() = _x;
675  y() = _y;
676  }
677 
682 };
683 
684 
690 template <typename T>
691 class Point3D : public Tuple<COORDINATE_3D_COUNT, T>
692 {
693 public:
694  Point3D() {}
696 
697  Point3D(T init)
698  {
699  x() = y() = z() = init;
700  }
701 
702  Point3D(T _x, T _y, T _z)
703  {
704  x() = _x;
705  y() = _y;
706  z() = _z;
707  }
708 
715 };
716 
721 template <typename T>
722 class Size2D : public Tuple<2, T>
723 {
724 public:
725  Size2D() {}
726  Size2D(const Tuple<2, T>& other) : Tuple<2, T>(other) {}
727 
728  Size2D(T init)
729  {
730  width() = height() = init;
731  }
732 
733  Size2D(T _width, T _height)
734  {
735  width() = _width;
736  height() = _height;
737  }
738 
739  T& width() { return Tuple<2, T>::m_data[0]; }
740  const T& width() const { return Tuple<2, T>::m_data[0]; }
741  T& height() { return Tuple<2, T>::m_data[1]; }
742  const T& height() const { return Tuple<2, T>::m_data[1]; }
743 
745  T area() const { return width() * height(); }
746 };
747 
753 template <typename T>
754 class Rectangle : public Tuple<4, T>
755 {
756 public:
758  Rectangle(const Tuple<4, T>& other) : Tuple<4, T>(other) {}
759 
760  Rectangle(T init)
761  {
762  left() = top() = right() = bottom() = init;
763  }
764 
765  Rectangle(T _left, T _top, T _right, T _bottom)
766  {
767  left() = _left;
768  top() = _top;
769  right() = _right;
770  bottom() = _bottom;
771  }
772 
773  T& left() { return Tuple<4, T>::m_data[0]; }
774  const T& left() const { return Tuple<4, T>::m_data[0]; }
775  T& top() { return Tuple<4, T>::m_data[1]; }
776  const T& top() const { return Tuple<4, T>::m_data[1]; }
777  T& right() { return Tuple<4, T>::m_data[2]; }
778  const T& right() const { return Tuple<4, T>::m_data[2]; }
779  T& bottom() { return Tuple<4, T>::m_data[3]; }
780  const T& bottom() const { return Tuple<4, T>::m_data[3]; }
781 
783  T width() const { return right() - left(); }
784 
786  T height() const { return bottom() - top(); }
787 
789  T area() const { return width() * height(); }
790 };
791 
796 template <typename T>
797 class Range : public Tuple<2, T>
798 {
799 public:
800  Range() {}
801  Range(const Tuple<2, T>& other) : Tuple<2, T>(other) {}
802 
803  Range(T init)
804  {
805  min() = max() = init;
806  }
807 
808  Range(T _min, T _max)
809  {
810  min() = _min;
811  max() = _max;
812  }
813 
814  T& min() { return Tuple<2, T>::m_data[0]; }
815  const T& min() const { return Tuple<2, T>::m_data[0]; }
816  T& max() { return Tuple<2, T>::m_data[1]; }
817  const T& max() const { return Tuple<2, T>::m_data[1]; }
818 
819  bool empty() const { return max() < min(); }
820 };
821 
826 class AcRegion : public Rectangle<uint32_t>
827 {
828 public:
830  : Rectangle<uint32_t>(0, 0, 0, 0)
831  , m_weight(1.0f)
832  {}
833 
834  AcRegion(uint32_t _left, uint32_t _top, uint32_t _right, uint32_t _bottom, float _weight)
835  : Rectangle<uint32_t>(_left, _top, _right, _bottom)
836  , m_weight(_weight)
837  {}
838 
839  float& weight() { return m_weight; }
840  const float& weight() const { return m_weight; }
841 
842 protected:
843  float m_weight;
844 };
845 
853 template <typename T>
854 class Array2D
855 {
856 public:
857  // Iterator types.
858  typedef T* iterator;
859  typedef const T* const_iterator;
860 
862  Array2D() : m_size(0, 0) {}
863 
865  Array2D(const Size2D<uint32_t>& size) : m_size(size)
866  {
867  m_data.resize(size.width() * size.height());
868  }
869 
871  Array2D(const Size2D<uint32_t>& size, const T& value) : m_size(size)
872  {
873  m_data.resize(size.width() * size.height(), value);
874  }
875 
877  Array2D(const Array2D<T>& other)
878  {
879  m_data = other.m_data;
880  m_size = other.m_size;
881  }
882 
885  {
886  m_data = other.m_data;
887  m_size = other.m_size;
888  return *this;
889  }
890 
892  bool operator== (const Array2D<T>& other) const
893  {
894  return (m_size == other.m_size && m_data == other.m_data);
895  }
896 
898  Size2D<uint32_t> size() const { return m_size; }
899 
903  {
904  uint32_t s = size.width() * size.height();
905  m_data.resize(s);
906  if (m_data.size() != s)
907  return false;
908  m_size = size;
909  return true;
910  }
911 
913  inline const_iterator begin() const { return m_data.data(); }
914  inline const_iterator end() const { return m_data.data() + m_data.size(); }
915  inline iterator begin() { return m_data.data(); }
916  inline iterator end() { return m_data.data() + m_data.size(); }
917 
919  T& operator[](unsigned int i) { return m_data[checkIndex(i)]; }
920  const T& operator[](unsigned int i) const { return m_data[checkIndex(i)]; }
921 
923  inline const T& operator() (uint32_t i) const { return m_data[checkIndex(i)]; }
924  inline const T& operator() (uint32_t x, uint32_t y) const { return m_data[checkIndex(x, y)]; }
925  inline const T& operator() (const Point2D<uint32_t>& p) const
926  { return m_data[checkIndex(p.x(), p.y())]; }
927  inline T& operator() (uint32_t i) { return m_data[checkIndex(i)]; }
928  inline T& operator() (uint32_t x, uint32_t y) { return m_data[checkIndex(x, y)]; }
929  inline T& operator() (const Point2D<uint32_t>& p)
930  { return m_data[checkIndex(p.x(), p.y())]; }
931 
932  // Get pointers to data.
933  inline const T* data() const { return m_data.data(); }
934  inline T* data() { return m_data.data(); }
935 
936 private:
937  inline uint32_t checkIndex(uint32_t i) const
938  {
939  assert(i < m_data.size());
940  return i;
941  }
942 
943  inline uint32_t checkIndex(uint32_t x, uint32_t y) const
944  {
945  assert(x < m_size.width());
946  assert(y < m_size.height());
947  return x + (y * m_size.width());
948  }
949 
950  std::vector<T> m_data;
951  Size2D<uint32_t> m_size;
952 };
953 
954 typedef uint32_t AutoControlId;
955 
956 } // namespace Argus
957 
958 #endif // _ARGUS_TYPES_H
Argus::RGB_CHANNEL_COUNT
@ RGB_CHANNEL_COUNT
Definition: Types.h:164
Argus::Tuple::operator[]
T & operator[](unsigned int i)
Definition: Types.h:578
Argus::BayerTuple::gEven
T & gEven()
Definition: Types.h:615
Argus::Rectangle::Rectangle
Rectangle(T init)
Definition: Types.h:760
Argus::BAYER_CHANNEL_B
@ BAYER_CHANNEL_B
Definition: Types.h:137
Argus::RGBTuple::b
T & b()
Definition: Types.h:651
Argus::Range::empty
bool empty() const
Definition: Types.h:819
Argus::DEFINE_NAMED_UUID_CLASS
DEFINE_NAMED_UUID_CLASS(BufferType)
Argus::TIMEOUT_INFINITE
const uint64_t TIMEOUT_INFINITE
Constant used for infinite timeouts.
Definition: Types.h:88
Argus::interface_cast
TheInterface * interface_cast(InterfaceProvider *obj)
Interface-casting helper similar to dynamic_cast.
Definition: Types.h:395
Argus::RGB_CHANNEL_G
@ RGB_CHANNEL_G
Definition: Types.h:161
Argus::Coordinate
Coordinate
Coordinates used for 2D and 3D points.
Definition: Types.h:145
Argus::Array2D::operator[]
const T & operator[](unsigned int i) const
Definition: Types.h:920
Argus::NonCopyable::NonCopyable
NonCopyable()
Definition: Types.h:330
Argus::RGBTuple::g
const T & g() const
Definition: Types.h:650
Argus::Array2D
A template class to hold a 2-dimensional array of data.
Definition: Types.h:854
Argus::UniqueObj::operator=
UniqueObj & operator=(rv< UniqueObj > &moved)
Definition: Types.h:469
Argus::Point3D::Point3D
Point3D(T _x, T _y, T _z)
Definition: Types.h:702
Argus::Tuple::operator+=
Tuple< N, T > & operator+=(const Tuple< N, T > &rhs)
Adds every element of another tuple to the elements of this tuple.
Definition: Types.h:523
Argus::RGBTuple::RGBTuple
RGBTuple(T init)
Definition: Types.h:635
Argus::BayerTuple::BayerTuple
BayerTuple()
Definition: Types.h:597
Argus::Rectangle::height
T height() const
Returns the height of the rectangle.
Definition: Types.h:786
Argus::AutoControlId
uint32_t AutoControlId
Definition: Types.h:954
Argus::DEFINE_UUID
DEFINE_UUID(ExtensionName, EXT_BAYER_AVERAGE_MAP, 12c3de20, 64c5, 11e6, bdf4, 08, 00, 20, 0c, 9a, 66)
Argus::Range::max
const T & max() const
Definition: Types.h:817
Argus::COORDINATE_Y
@ COORDINATE_Y
Definition: Types.h:148
Argus::BayerTuple::b
const T & b() const
Definition: Types.h:620
Argus::AcRegion::weight
float & weight()
Definition: Types.h:839
Argus::UniqueObj::get
T * get() const
Definition: Types.h:474
Argus::Array2D::data
T * data()
Definition: Types.h:934
Argus::Rectangle::left
const T & left() const
Definition: Types.h:774
Argus::Point2D::y
T & y()
Definition: Types.h:680
Argus::Tuple::operator[]
const T & operator[](unsigned int i) const
Definition: Types.h:579
Argus::Destructable::~Destructable
~Destructable()
Definition: Types.h:423
Argus::Point3D::z
const T & z() const
Definition: Types.h:714
Argus::STATUS_CANCELLED
@ STATUS_CANCELLED
The capture was aborted.
Definition: Types.h:117
Argus::NamedUUID
A universally unique identifier with a name (used for debugging purposes).
Definition: UUID.h:72
Argus
Definition: BayerAverageMap.h:39
Argus::STATUS_OK
@ STATUS_OK
Function succeeded.
Definition: Types.h:96
Argus::Point2D::Point2D
Point2D(const Tuple< COORDINATE_2D_COUNT, T > &other)
Definition: Types.h:665
Argus::Tuple::operator-
const Tuple< N, T > operator-(const Tuple< N, T > &rhs) const
Returns the result of subtracting another tuple from this tuple.
Definition: Types.h:561
Argus::Tuple::operator!=
bool operator!=(const Tuple< N, T > &rhs) const
Returns true if there are any differences between the two tuples.
Definition: Types.h:517
Argus::STATUS_UNAVAILABLE
@ STATUS_UNAVAILABLE
The requested device is unavailable.
Definition: Types.h:105
Argus::STATUS_END_OF_STREAM
@ STATUS_END_OF_STREAM
End of stream, used by Stream objects.
Definition: Types.h:123
Argus::Point3D::x
const T & x() const
Definition: Types.h:710
Argus::Tuple::operator*=
Tuple< N, T > & operator*=(const T &rhs)
Multiplies every element in the tuple by a single value.
Definition: Types.h:539
Argus::Size2D
Size2D template class.
Definition: Types.h:722
Argus::BayerTuple::gOdd
T & gOdd()
Definition: Types.h:617
Argus::Tuple::operator-=
Tuple< N, T > & operator-=(const Tuple< N, T > &rhs)
Subtracts every element of another tuple from the elements of this tuple.
Definition: Types.h:531
Argus::Tuple::Tuple
Tuple(T init)
Initialize every element of the tuple to a single value.
Definition: Types.h:504
Argus::Tuple::operator*
const Tuple< N, T > operator*(const T &rhs) const
Returns the result of multiplying this tuple by a single value.
Definition: Types.h:567
Argus::Size2D::width
const T & width() const
Definition: Types.h:740
Argus::Tuple::tupleSize
static unsigned int tupleSize()
Returns the number of elements in the tuple.
Definition: Types.h:582
Argus::Range::Range
Range(const Tuple< 2, T > &other)
Definition: Types.h:801
Argus::RGB_CHANNEL_R
@ RGB_CHANNEL_R
Definition: Types.h:160
Argus::Range::Range
Range(T _min, T _max)
Definition: Types.h:808
Argus::Array2D::operator[]
T & operator[](unsigned int i)
Array indexing using [] operator.
Definition: Types.h:919
Argus::Interface
The top-level interface class.
Definition: Types.h:344
Argus::Point3D::Point3D
Point3D(const Tuple< COORDINATE_3D_COUNT, T > &other)
Definition: Types.h:695
Argus::Rectangle::bottom
const T & bottom() const
Definition: Types.h:780
Argus::Tuple::operator+
const Tuple< N, T > operator+(const Tuple< N, T > &rhs) const
Returns the result of adding another tuple to this tuple.
Definition: Types.h:555
Argus::STATUS_DISCONNECTED
@ STATUS_DISCONNECTED
The stream or other resource has been disconnected.
Definition: Types.h:120
Argus::AcRegion::AcRegion
AcRegion(uint32_t _left, uint32_t _top, uint32_t _right, uint32_t _bottom, float _weight)
Definition: Types.h:834
Argus::InterfaceProvider::getInterface
virtual Interface * getInterface(const InterfaceID &interfaceId)=0
Acquire the interface specified by interfaceId.
Argus::Interface::Interface
Interface()
Definition: Types.h:347
Argus::Range
Range template class.
Definition: Types.h:797
Argus::Rectangle::top
T & top()
Definition: Types.h:775
Argus::InterfaceID::InterfaceID
InterfaceID()
Definition: Types.h:367
Argus::Rectangle
Rectangle template class.
Definition: Types.h:754
Argus::Tuple::m_data
T m_data[N]
Definition: Types.h:585
Argus::Rectangle::right
T & right()
Definition: Types.h:777
Argus::Point3D
Point3D template class.
Definition: Types.h:691
Argus::BayerTuple::BayerTuple
BayerTuple(T _r, T _gEven, T _gOdd, T _b)
Definition: Types.h:605
Argus::Array2D::Array2D
Array2D(const Size2D< uint32_t > &size)
Constructor given initial array size.
Definition: Types.h:865
Argus::InterfaceID
A unique identifier for a libargus Interface.
Definition: Types.h:354
Argus::Tuple
Tuple template class.
Definition: Types.h:498
Argus::Tuple::operator/=
Tuple< N, T > & operator/=(const T &rhs)
Divides every element in the tuple by a single value.
Definition: Types.h:547
Argus::RGBTuple::b
const T & b() const
Definition: Types.h:652
Argus::Array2D::Array2D
Array2D()
Default Constructor.
Definition: Types.h:862
Argus::UniqueObj::UniqueObj
UniqueObj(rv< UniqueObj > &moved)
Definition: Types.h:468
Argus::Point2D::Point2D
Point2D(T init)
Definition: Types.h:667
Argus::Rectangle::width
T width() const
Returns the width of the rectangle.
Definition: Types.h:783
Argus::Array2D::begin
const_iterator begin() const
STL style iterators.
Definition: Types.h:913
Argus::STATUS_UNIMPLEMENTED
@ STATUS_UNIMPLEMENTED
This method has not been implemented.
Definition: Types.h:111
Argus::Point3D::y
T & y()
Definition: Types.h:711
Argus::BayerTuple::gEven
const T & gEven() const
Definition: Types.h:616
Argus::AcRegion::weight
const float & weight() const
Definition: Types.h:840
Argus::UniqueObj::UniqueObj
UniqueObj(T *obj=NULL)
Definition: Types.h:461
Argus::InterfaceProvider
The base interface for a class that provides libargus Interfaces.
Definition: Types.h:375
Argus::Rectangle::top
const T & top() const
Definition: Types.h:776
Argus::Rectangle::Rectangle
Rectangle()
Definition: Types.h:757
Argus::RGBTuple::r
const T & r() const
Definition: Types.h:648
Argus::COORDINATE_Z
@ COORDINATE_Z
Definition: Types.h:149
Argus::Array2D::end
iterator end()
Definition: Types.h:916
Argus::AcRegion
Defines an autocontrol region of interest (in pixel space).
Definition: Types.h:826
Argus::BAYER_CHANNEL_G_EVEN
@ BAYER_CHANNEL_G_EVEN
Definition: Types.h:135
Argus::Size2D::Size2D
Size2D()
Definition: Types.h:725
Argus::InterfaceProvider::~InterfaceProvider
~InterfaceProvider()
Definition: Types.h:387
Argus::AcRegion::m_weight
float m_weight
Definition: Types.h:843
Argus::Rectangle::bottom
T & bottom()
Definition: Types.h:779
Argus::UniqueObj::release
T * release()
Definition: Types.h:465
Argus::RGBTuple::g
T & g()
Definition: Types.h:649
Argus::Point3D::x
T & x()
Definition: Types.h:709
Argus::COORDINATE_3D_COUNT
@ COORDINATE_3D_COUNT
Definition: Types.h:152
Argus::Point2D::y
const T & y() const
Definition: Types.h:681
Argus::Rectangle::Rectangle
Rectangle(T _left, T _top, T _right, T _bottom)
Definition: Types.h:765
Argus::BayerTuple::BayerTuple
BayerTuple(T init)
Definition: Types.h:600
Argus::NonCopyable
Utility class for libargus interfaces.
Definition: Types.h:327
Argus::Array2D::size
Size2D< uint32_t > size() const
Returns the size (dimensions) of the array.
Definition: Types.h:898
Argus::BayerTuple
BayerTuple template class.
Definition: Types.h:594
Argus::Interface::~Interface
~Interface()
Definition: Types.h:348
Argus::Point2D::x
const T & x() const
Definition: Types.h:679
Argus::Destructable::destroy
virtual void destroy()=0
Destroy this object.
Argus::InterfaceID::InterfaceID
InterfaceID(uint32_t time_low_, uint16_t time_mid_, uint16_t time_hi_and_version_, uint16_t clock_seq_, uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, const char *name)
Definition: Types.h:357
Argus::Tuple::Tuple
Tuple()
Definition: Types.h:501
Argus::AcRegion::AcRegion
AcRegion()
Definition: Types.h:829
Argus::RGBChannel
RGBChannel
Color channel constants for RGB data.
Definition: Types.h:158
Argus::Array2D::Array2D
Array2D(const Size2D< uint32_t > &size, const T &value)
Constructor given initial array size and initial fill value.
Definition: Types.h:871
Argus::STATUS_INVALID_PARAMS
@ STATUS_INVALID_PARAMS
The set of parameters passed was invalid.
Definition: Types.h:99
Argus::Range::min
T & min()
Definition: Types.h:814
Argus::Size2D::Size2D
Size2D(const Tuple< 2, T > &other)
Definition: Types.h:726
Argus::Size2D::area
T area() const
Returns the area of the size (width * height).
Definition: Types.h:745
Argus::Rectangle::Rectangle
Rectangle(const Tuple< 4, T > &other)
Definition: Types.h:758
Argus::BAYER_CHANNEL_COUNT
@ BAYER_CHANNEL_COUNT
Definition: Types.h:139
Argus::Array2D::operator==
bool operator==(const Array2D< T > &other) const
Equality operator.
Definition: Types.h:892
Argus::Rectangle::left
T & left()
Definition: Types.h:773
Argus::BayerTuple::gOdd
const T & gOdd() const
Definition: Types.h:618
Argus::STATUS_OUT_OF_MEMORY
@ STATUS_OUT_OF_MEMORY
An operation failed because of insufficient mavailable memory.
Definition: Types.h:108
Argus::BayerChannel
BayerChannel
Color channel constants for Bayer data.
Definition: Types.h:132
Argus::Array2D::resize
bool resize(const Size2D< uint32_t > &size)
Resize the array.
Definition: Types.h:902
Argus::BayerTuple::b
T & b()
Definition: Types.h:619
Argus::Tuple::operator/
const Tuple< N, T > operator/(const T &rhs) const
Returns the result of dividing this tuple by a single value.
Definition: Types.h:573
Argus::RGB_CHANNEL_B
@ RGB_CHANNEL_B
Definition: Types.h:162
Argus::Size2D::Size2D
Size2D(T init)
Definition: Types.h:728
Argus::Range::max
T & max()
Definition: Types.h:816
Argus::STATUS_COUNT
@ STATUS_COUNT
Definition: Types.h:126
Argus::Tuple::operator==
bool operator==(const Tuple< N, T > &rhs) const
Returns true when every element in the two tuples are identical.
Definition: Types.h:511
Argus::Array2D::operator()
const T & operator()(uint32_t i) const
Array indexing using () operator.
Definition: Types.h:923
Argus::Array2D::iterator
T * iterator
Definition: Types.h:858
Argus::STATUS_INVALID_SETTINGS
@ STATUS_INVALID_SETTINGS
The requested settings are invalid.
Definition: Types.h:102
Argus::RGBTuple::r
T & r()
Definition: Types.h:647
Argus::BayerTuple::BayerTuple
BayerTuple(const Tuple< BAYER_CHANNEL_COUNT, T > &other)
Definition: Types.h:598
Argus::Point3D::Point3D
Point3D()
Definition: Types.h:694
Argus::RGBTuple::RGBTuple
RGBTuple(T _r, T _g, T _b)
Definition: Types.h:640
Argus::Array2D::operator=
Array2D & operator=(const Array2D< T > &other)
Assignment operator.
Definition: Types.h:884
Argus::RGBTuple::RGBTuple
RGBTuple(const Tuple< RGB_CHANNEL_COUNT, T > &other)
Definition: Types.h:633
Argus::Array2D::end
const_iterator end() const
Definition: Types.h:914
Argus::Point2D::Point2D
Point2D()
Definition: Types.h:664
Argus::Point2D::x
T & x()
Definition: Types.h:678
Argus::Point2D
Point2D template class.
Definition: Types.h:661
Argus::Array2D::Array2D
Array2D(const Array2D< T > &other)
Copy constructor.
Definition: Types.h:877
Argus::RGBTuple
RGBTuple template class.
Definition: Types.h:629
Argus::RGBTuple::RGBTuple
RGBTuple()
Definition: Types.h:632
Argus::Array2D::const_iterator
const typedef T * const_iterator
Definition: Types.h:859
Argus::COORDINATE_X
@ COORDINATE_X
Definition: Types.h:147
Argus::Point3D::y
const T & y() const
Definition: Types.h:712
Argus::BAYER_CHANNEL_R
@ BAYER_CHANNEL_R
Definition: Types.h:134
Argus::COORDINATE_2D_COUNT
@ COORDINATE_2D_COUNT
Definition: Types.h:151
Argus::UniqueObj::operator*
T & operator*() const
Definition: Types.h:473
Argus::Destructable
A top level object class for libargus objects that are created and owned by the client.
Definition: Types.h:412
Argus::UniqueObj::reset
void reset(T *obj=NULL)
Definition: Types.h:463
Argus::Size2D::height
T & height()
Definition: Types.h:741
Argus::BayerTuple::r
const T & r() const
Definition: Types.h:614
Argus::BayerTuple::r
T & r()
Definition: Types.h:613
Argus::Size2D::height
const T & height() const
Definition: Types.h:742
Argus::Point3D::Point3D
Point3D(T init)
Definition: Types.h:697
Argus::Size2D::width
T & width()
Definition: Types.h:739
Argus::Status
Status
Status values returned by API function calls.
Definition: Types.h:93
Argus::Rectangle::area
T area() const
Returns the area of the rectangle (width * height).
Definition: Types.h:789
Argus::UniqueObj
Template helper emulating C++11 rvalue semantics.
Definition: Types.h:458
Argus::Range::min
const T & min() const
Definition: Types.h:815
Argus::Range::Range
Range(T init)
Definition: Types.h:803
Argus::Rectangle::right
const T & right() const
Definition: Types.h:778
Argus::Range::Range
Range()
Definition: Types.h:800
Argus::Array2D::begin
iterator begin()
Definition: Types.h:915
Argus::BAYER_CHANNEL_G_ODD
@ BAYER_CHANNEL_G_ODD
Definition: Types.h:136
Argus::UniqueObj::~UniqueObj
~UniqueObj()
Definition: Types.h:471
Argus::Point2D::Point2D
Point2D(T _x, T _y)
Definition: Types.h:672
Argus::Array2D::data
const T * data() const
Definition: Types.h:933
Argus::Size2D::Size2D
Size2D(T _width, T _height)
Definition: Types.h:733
Argus::Point3D::z
T & z()
Definition: Types.h:713
Argus::STATUS_TIMEOUT
@ STATUS_TIMEOUT
An operation timed out.
Definition: Types.h:114