|
|
NVIDIA DeepStream SDK API Reference
|
9.1 Release
|
Go to the documentation of this file.
18 #ifndef _DS3D_COMMON_FUNC_UTILS__H
19 #define _DS3D_COMMON_FUNC_UTILS__H
21 #include <ds3d/common/abi_frame.h>
22 #include <ds3d/common/common.h>
23 #include <ds3d/common/idatatype.h>
58 static const std::unordered_map<ErrCode, const char*> kCodeTable = {
59 #define __DS3D_ERR_STR_DEF(code) {ErrCode::code, #code}
71 #undef __DS3D_ERR_STR_DEF
73 auto iter = kCodeTable.find(code);
74 if (iter == kCodeTable.cend()) {
89 template <
class F,
typename... Args>
94 DS3D_TRY { code = f(std::forward<Args>(args)...); }
115 return (len ? std::string(str, len) : std::string(str));
117 return std::string(
"");
120 template <
typename T>
129 return sizeof(T) * 4;
132 return sizeof(T) * 3;
134 return sizeof(T) * 3;
136 return sizeof(T) * 4;
138 return sizeof(T) * 3;
140 LOG_ERROR(
"bytesPerPixel with unsupported frametype: %d",
static_cast<int>(f));
149 #define __DS3D_DATATYPE_BYTES(t) \
151 return sizeof(NativeData<DataType::t>::type)
162 #undef __DS3D_DATATYPE_BYTES
175 if (std::any_of(shape.
d, shape.
d + shape.
numDims, [](
int d) { return d < 0; })) {
179 return (
size_t)std::accumulate(
180 shape.
d, shape.
d + shape.
numDims, 1, [](
int s,
int i) { return s * i; });
189 for (uint32_t i = 0; i < a.
numDims; ++i) {
190 if (a.
d[i] != b.
d[i]) {
204 readFile(
const std::string& path, std::string& context)
206 std::ifstream fileIn(path, std::ios::in | std::ios::binary);
209 fileIn.seekg(0, std::ios::end);
210 size_t fileSize = fileIn.tellg();
211 context.resize(fileSize, 0);
212 fileIn.seekg(0, std::ios::beg);
213 fileIn.read(&context[0], fileSize);
220 static bool debug = std::getenv(
"DS3D_ENABLE_DEBUG") ? true :
false;
224 template <
typename Data>
228 for (
int i = 0; i < 3; ++i) {
229 to.
data[i] = from[i];
236 if (fabs(a - b) <= std::numeric_limits<float>::epsilon())
241 inline TransformMatrix
245 {{param.
fx, 0.0f, 0.0f, 0.0f}},
246 {{0.0f, param.
fy, 0.0f, 0.0f}},
248 {{0.0f, 0.0f, 0.0f, 1.0f}},
259 #endif // _DS3D_COMMON_FUNC_UTILS__H
#define DS3D_EXTERN_C_BEGIN
size_t ShapeSize(const Shape &shape)
ErrCode CatchError(F f, Args... args)
#define DS3D_FAILED_RETURN(condition, ret, fmt,...)
bool readFile(const std::string &path, std::string &context)
#define __DS3D_DATATYPE_BYTES(t)
uint32_t bytesPerPixel(FrameType f)
#define LOG_ERROR(fmt,...)
bool operator!=(const Shape &a, const Shape &b)
#define DS3D_EXTERN_C_END
bool isNear(float a, float b)
#define __DS3D_ERR_STR_DEF(code)
DS3D_EXTERN_C_BEGIN DS3D_EXPORT_API ds3d::abiRefDataMap * NvDs3d_CreateDataHashMap()
bool operator==(const Shape &a, const Shape &b)
#define DS3D_CATCH_ERROR(type, errcode, fmt,...)
void array2Vec3(Data *from, vec3< Data > &to)
uint32_t dataTypeBytes(DataType t)
const char * ErrCodeStr(ErrCode code)
std::unique_lock< std::mutex > LockMutex
#define DS3D_CATCH_ANY(errcode, fmt,...)
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)