Face Engine SDK  5.8.0
A face detection, recognition and tracking engine.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Format.h
1 #pragma once
2 
3 #include <cassert>
4 
5 namespace fsdk
6 {
7 
11 struct Format {
12 
15  enum Type {
21  R8,
22  R16,
26  };
27 
34  int getChannelCount() const noexcept {
35  switch(m_type) {
36  case B8G8R8X8:
37  case R8G8B8X8:
38  case B8G8R8:
39  case R8G8B8:
40  case IR_X8X8X8:
41  case YUV_NV21:
42  case YUV_NV12:
43  return 3;
44  case R8:
45  case R16:
46  return 1;
47  default:
48  return 0;
49  }
50  }
51 
56  int getChannelStep() const noexcept {
57  switch(m_type) {
58  case B8G8R8X8:
59  case R8G8B8X8:
60  return 4;
61  case B8G8R8:
62  case R8G8B8:
63  case IR_X8X8X8:
64  return 3;
65  case R8:
66  case R16:
67  case YUV_NV21:
68  case YUV_NV12:
69  return 1;
70  default:
71  return 0;
72  }
73  }
74 
78  int getChannelSize() const noexcept {
79  switch(m_type) {
80  case B8G8R8X8:
81  case R8G8B8X8:
82  case B8G8R8:
83  case R8G8B8:
84  case IR_X8X8X8:
85  case R8:
86  return 8;
87  case R16:
88  return 16;
89  case YUV_NV21:
90  case YUV_NV12:
91  return 12;
92  default:
93  return 0;
94  }
95  }
96 
100  int getBitDepth() const noexcept {
101  return getChannelStep() * getChannelSize();
102  }
103 
107  int getByteDepth() const noexcept {
108  if(isBlock()) {
109  assert(!"Not implemented");
110  return 0;
111  }
112  else {
113  return getBitDepth() >> 3;
114  }
115  }
116 
121  int computePitch(int rowWidth) const noexcept {
122  return rowWidth * getByteDepth();
123  }
124 
127  bool isPadded() const noexcept {
128  switch(m_type) {
129  case B8G8R8X8:
130  case R8G8B8X8:
131  return true;
132  default:
133  return false;
134  }
135  }
136 
141  bool isBGR() const noexcept {
142  switch(m_type) {
143  case B8G8R8X8:
144  case B8G8R8:
145  return true;
146  default:
147  return false;
148  }
149  }
150 
153  bool isYUV() const noexcept {
154  switch(m_type) {
155  case YUV_NV21:
156  case YUV_NV12:
157  return true;
158  default:
159  return false;
160  }
161  }
162 
167  bool isBlock() const noexcept {
168  return false;
169  }
170 
174  bool isValid() const noexcept {
175  return m_type != Unknown;
176  }
177 
181  Format() noexcept : m_type(Unknown) {}
182 
186  Format(Type type) noexcept : m_type(type) {}
187 
189  operator Type () const noexcept {
190  return m_type;
191  }
192 
193 protected:
195 };
196 }
197 
198 
int getBitDepth() const noexcept
Get number of bits per pixel.
Definition: Format.h:100
int getChannelSize() const noexcept
Get color channel size in bits.
Definition: Format.h:78
3 channel, 8 bit per channel, R-G-B color order format;
Definition: Format.h:20
unknown format.
Definition: Format.h:16
int getChannelStep() const noexcept
Get channel step.
Definition: Format.h:56
bool isBlock() const noexcept
Definition: Format.h:167
Format() noexcept
Initializes format structure.
Definition: Format.h:181
int computePitch(int rowWidth) const noexcept
Compute row size in bytes.
Definition: Format.h:121
bool isValid() const noexcept
Definition: Format.h:174
Image format.
Definition: Format.h:11
bool isBGR() const noexcept
Definition: Format.h:141
int getChannelCount() const noexcept
Get color channel count.
Definition: Format.h:34
4:2:0 planar format with a plane of 8-bit Y samples followed by interleaved 2x2 subsampled U/V 8-bit ...
Definition: Format.h:25
int getByteDepth() const noexcept
Get number of bytes per pixel.
Definition: Format.h:107
3 channel, 8 bit per channel, B-G-R color order format;
Definition: Format.h:19
Type
Format type enumeration.
Definition: Format.h:15
Type m_type
Format type.
Definition: Format.h:194
bool isPadded() const noexcept
Definition: Format.h:127
1 channel, 8 bit per channel format;
Definition: Format.h:21
3 channel, 8 bit per channel, B-G-R color order format with 8 bit padding before next pixel; ...
Definition: Format.h:17
1 channel, 16 bit per channel format;
Definition: Format.h:22
3 channel, 8 bit per channel, R-G-B color order format with 8 bit padding before next pixel; ...
Definition: Format.h:18
4:2:0 planar format with a plane of 8-bit Y samples followed by interleaved 2x2 subsampled V/U 8-bit ...
Definition: Format.h:24
bool isYUV() const noexcept
Definition: Format.h:153
Format(Type type) noexcept
Initializes format structure.
Definition: Format.h:186
3 channel, 8 bit per channel format with InfraRed semantics;
Definition: Format.h:23