Face Engine SDK  5.17.0
A face detection, recognition and tracking engine.
include/fsdk/Types/Format.h
00001 #pragma once
00002 
00003 #include <cassert>
00004 
00005 namespace fsdk {
00006 
00010     struct Format {
00011 
00014         enum Type {
00016             Unknown,
00017 
00019             B8G8R8X8,
00020 
00022             R8G8B8X8,
00023 
00025             B8G8R8,
00026 
00028             R8G8B8,
00029 
00031             R8,
00032 
00034             R16,
00035 
00037             IR_X8X8X8,
00038 
00041             YUV_NV21,
00042 
00045             YUV_NV12
00046         };
00047 
00052         const char* toString() const noexcept {
00053             switch(m_type) {
00054             case Type::B8G8R8X8:
00055                 return "B8G8R8X8";
00056             case Type::R8G8B8X8:
00057                 return "R8G8B8X8";
00058             case Type::B8G8R8:
00059                 return "B8G8R8";
00060             case Type::R8G8B8:
00061                 return "R8G8B8";
00062             case Type::R8:
00063                 return "R8";
00064             case Type::R16:
00065                 return "R16";
00066             case Type::IR_X8X8X8:
00067                 return "IR_X8X8X8";
00068             case Type::YUV_NV21:
00069                 return "YUV_NV21";
00070             case Type::YUV_NV12:
00071                 return "YUV_NV12";
00072             default:
00073                 return "Unknown";
00074             }
00075         }
00076 
00083         int getChannelCount() const noexcept {
00084             switch(m_type) {
00085             case B8G8R8X8:
00086             case R8G8B8X8:
00087             case B8G8R8:
00088             case R8G8B8:
00089             case IR_X8X8X8:
00090             case YUV_NV21:
00091             case YUV_NV12:
00092                 return 3;
00093             case R8:
00094             case R16:
00095                 return 1;
00096             default:
00097                 return 0;
00098             }
00099         }
00100 
00105         int getChannelStep() const noexcept {
00106             switch(m_type) {
00107             case B8G8R8X8:
00108             case R8G8B8X8:
00109                 return 4;
00110             case B8G8R8:
00111             case R8G8B8:
00112             case IR_X8X8X8:
00113                 return 3;
00114             case R8:
00115             case R16:
00116             case YUV_NV21:
00117             case YUV_NV12:
00118                 return 1;
00119             default:
00120                 return 0;
00121             }
00122         }
00123 
00127         int getChannelSize() const noexcept {
00128             switch(m_type) {
00129             case B8G8R8X8:
00130             case R8G8B8X8:
00131             case B8G8R8:
00132             case R8G8B8:
00133             case IR_X8X8X8:
00134             case R8:
00135                 return 8;
00136             case R16:
00137                 return 16;
00138             case YUV_NV21:
00139             case YUV_NV12:
00140                 return 12;
00141             default:
00142                 return 0;
00143             }
00144         }
00145 
00149         int getBitDepth() const noexcept {
00150             return getChannelStep() * getChannelSize();
00151         }
00152 
00156         int getByteDepth() const noexcept {
00157             if(isBlock()) {
00158                 assert(!"Not implemented");
00159                 return 0;
00160             } else {
00161                 return getBitDepth() >> 3;
00162             }
00163         }
00164 
00169         int computePitch(int rowWidth) const noexcept {
00170             return rowWidth * getByteDepth();
00171         }
00172 
00175         bool isPadded() const noexcept {
00176             switch(m_type) {
00177             case B8G8R8X8:
00178             case R8G8B8X8:
00179                 return true;
00180             default:
00181                 return false;
00182             }
00183         }
00184 
00189         bool isBGR() const noexcept {
00190             switch(m_type) {
00191             case B8G8R8X8:
00192             case B8G8R8:
00193                 return true;
00194             default:
00195                 return false;
00196             }
00197         }
00198 
00201         bool isYUV() const noexcept {
00202             switch(m_type) {
00203             case YUV_NV21:
00204             case YUV_NV12:
00205                 return true;
00206             default:
00207                 return false;
00208             }
00209         }
00210 
00215         bool isBlock() const noexcept {
00216             return false;
00217         }
00218 
00222         bool isValid() const noexcept {
00223             return m_type != Unknown;
00224         }
00225 
00229         Format() noexcept
00230             : m_type(Unknown) {
00231         }
00232 
00236         Format(Type type) noexcept
00237             : m_type(type) {
00238         }
00239 
00241         operator Type() const noexcept {
00242             return m_type;
00243         }
00244 
00245     protected:
00246         Type m_type; 
00247     };
00248 
00249     constexpr int format_as(Format::Type in) {
00250         return static_cast<int>(in);
00251     }
00252 } // namespace fsdk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines