|
NVIDIA DeepStream SDK API Reference
|
7.1 Release
|
Go to the documentation of this file.
14 #ifndef _DS3D_COMMON_FUNC_UTILS__H
15 #define _DS3D_COMMON_FUNC_UTILS__H
54 static const std::unordered_map<ErrCode, const char*> kCodeTable = {
55 #define __DS3D_ERR_STR_DEF(code) {ErrCode::code, #code}
67 #undef __DS3D_ERR_STR_DEF
69 auto iter = kCodeTable.find(code);
70 if (iter == kCodeTable.cend()) {
85 template <
class F,
typename... Args>
90 DS3D_TRY { code = f(std::forward<Args>(args)...); }
111 return (len ? std::string(str, len) : std::string(str));
113 return std::string(
"");
116 template <
typename T>
125 return sizeof(T) * 4;
128 return sizeof(T) * 3;
130 return sizeof(T) * 3;
132 return sizeof(T) * 4;
134 return sizeof(T) * 3;
136 LOG_ERROR(
"bytesPerPixel with unsupported frametype: %d",
static_cast<int>(f));
145 #define __DS3D_DATATYPE_BYTES(t) \
147 return sizeof(NativeData<DataType::t>::type)
158 #undef __DS3D_DATATYPE_BYTES
171 if (std::any_of(shape.
d, shape.
d + shape.
numDims, [](
int d) { return d < 0; })) {
175 return (
size_t)std::accumulate(
176 shape.
d, shape.
d + shape.
numDims, 1, [](
int s,
int i) { return s * i; });
185 for (uint32_t i = 0; i < a.
numDims; ++i) {
186 if (a.
d[i] != b.
d[i]) {
200 readFile(
const std::string& path, std::string& context)
202 std::ifstream fileIn(path, std::ios::in | std::ios::binary);
205 fileIn.seekg(0, std::ios::end);
206 size_t fileSize = fileIn.tellg();
207 context.resize(fileSize, 0);
208 fileIn.seekg(0, std::ios::beg);
209 fileIn.read(&context[0], fileSize);
216 static bool debug = std::getenv(
"DS3D_ENABLE_DEBUG") ? true :
false;
220 template <
typename Data>
224 for (
int i = 0; i < 3; ++i) {
225 to.
data[i] = from[i];
232 if (fabs(a - b) <= std::numeric_limits<float>::epsilon())
237 inline TransformMatrix
241 {{param.
fx, 0.0f, 0.0f, 0.0f}},
242 {{0.0f, param.
fy, 0.0f, 0.0f}},
244 {{0.0f, 0.0f, 0.0f, 1.0f}},
255 #endif // _DS3D_COMMON_FUNC_UTILS__H
#define __DS3D_ERR_STR_DEF(code)
DS3D_EXTERN_C_BEGIN DS3D_EXPORT_API ds3d::abiRefDataMap * NvDs3d_CreateDataHashMap()
size_t ShapeSize(const Shape &shape)
std::unique_lock< std::mutex > LockMutex
#define DS3D_CATCH_ANY(errcode, fmt,...)
ErrCode CatchError(F f, Args... args)
#define DS3D_EXTERN_C_BEGIN
bool readFile(const std::string &path, std::string &context)
uint32_t bytesPerPixel(FrameType f)
const char * ErrCodeStr(ErrCode code)
#define DS3D_EXTERN_C_END
bool operator!=(const Shape &a, const Shape &b)
bool isNear(float a, float b)
#define DS3D_CATCH_ERROR(type, errcode, fmt,...)
bool operator==(const Shape &a, const Shape &b)
void array2Vec3(Data *from, vec3< Data > &to)
uint32_t dataTypeBytes(DataType t)
#define DS3D_FAILED_RETURN(condition, ret, fmt,...)
#define __DS3D_DATATYPE_BYTES(t)
std::string cppString(const char *str, size_t len=0)
TransformMatrix getIntrinsicMat(IntrinsicsParam ¶m)
void throwError(ErrCode code, const std::string &msg)
ErrCode CatchVoidCall(std::function< void()> f)