Face Engine SDK  4.6.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,
25  };
26 
33  int getChannelCount() const noexcept {
34  switch(m_type) {
35  case B8G8R8X8:
36  case R8G8B8X8:
37  case B8G8R8:
38  case R8G8B8:
39  case IR_X8X8X8:
40  case YUV_NV21:
41  return 3;
42  case R8:
43  case R16:
44  return 1;
45  default:
46  return 0;
47  }
48  }
49 
54  int getChannelStep() const noexcept {
55  switch(m_type) {
56  case B8G8R8X8:
57  case R8G8B8X8:
58  return 4;
59  case B8G8R8:
60  case R8G8B8:
61  case IR_X8X8X8:
62  return 3;
63  case R8:
64  case R16:
65  case YUV_NV21:
66  return 1;
67  default:
68  return 0;
69  }
70  }
71 
75  int getChannelSize() const noexcept {
76  switch(m_type) {
77  case B8G8R8X8:
78  case R8G8B8X8:
79  case B8G8R8:
80  case R8G8B8:
81  case IR_X8X8X8:
82  case R8:
83  return 8;
84  case R16:
85  return 16;
86  case YUV_NV21:
87  return 12;
88  default:
89  return 0;
90  }
91  }
92 
96  int getBitDepth() const noexcept {
97  return getChannelStep() * getChannelSize();
98  }
99 
103  int getByteDepth() const noexcept {
104  if(isBlock()) {
105  assert(!"Not implemented");
106  return 0;
107  }
108  else {
109  return getBitDepth() >> 3;
110  }
111  }
112 
117  int computePitch(int rowWidth) const noexcept {
118  return rowWidth * getByteDepth();
119  }
120 
123  bool isPadded() const noexcept {
124  switch(m_type) {
125  case B8G8R8X8:
126  case R8G8B8X8:
127  return true;
128  default:
129  return false;
130  }
131  }
132 
137  bool isBGR() const noexcept {
138  switch(m_type) {
139  case B8G8R8X8:
140  case B8G8R8:
141  return true;
142  default:
143  return false;
144  }
145  }
146 
149  bool isYUV() const noexcept {
150  switch(m_type) {
151  case YUV_NV21:
152  return true;
153  default:
154  return false;
155  }
156  }
157 
162  bool isBlock() const noexcept {
163  return false;
164  }
165 
169  bool isValid() const noexcept {
170  return m_type != Unknown;
171  }
172 
176  Format() noexcept : m_type(Unknown) {}
177 
181  Format(Type type) noexcept : m_type(type) {}
182 
184  operator Type () const noexcept {
185  return m_type;
186  }
187 
188 protected:
190 };
191 }
192 
193 
int getBitDepth() const noexcept
Get number of bits per pixel.
Definition: Format.h:96
int getChannelSize() const noexcept
Get color channel size in bits.
Definition: Format.h:75
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:54
bool isBlock() const noexcept
Definition: Format.h:162
Format() noexcept
Initializes format structure.
Definition: Format.h:176
int computePitch(int rowWidth) const noexcept
Compute row size in bytes.
Definition: Format.h:117
bool isValid() const noexcept
Definition: Format.h:169
Image format.
Definition: Format.h:11
bool isBGR() const noexcept
Definition: Format.h:137
int getChannelCount() const noexcept
Get color channel count.
Definition: Format.h:33
int getByteDepth() const noexcept
Get number of bytes per pixel.
Definition: Format.h:103
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:189
bool isPadded() const noexcept
Definition: Format.h:123
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 format with a plane of 8-bit Y samples followed by interleaved 2x2 subsampled V/U 8-bit chroma ...
Definition: Format.h:24
bool isYUV() const noexcept
Definition: Format.h:149
Format(Type type) noexcept
Initializes format structure.
Definition: Format.h:181
3 channel, 8 bit per channel format with InfraRed semantics.
Definition: Format.h:23