29 #ifndef NVXIO_UTILITY_HPP
30 #define NVXIO_UTILITY_HPP
41 #include <android/log.h>
45 #include <NVXIO/Export.hpp>
73 #define NVXIO_LOGV(tag, ...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, tag, __VA_ARGS__))
80 #define NVXIO_LOGD(tag, ...) ((void)__android_log_print(ANDROID_LOG_DEBUG, tag, __VA_ARGS__))
87 #define NVXIO_LOGI(tag, ...) ((void)__android_log_print(ANDROID_LOG_INFO, tag, __VA_ARGS__))
94 #define NVXIO_LOGW(tag, ...) ((void)__android_log_print(ANDROID_LOG_WARN, tag, __VA_ARGS__))
101 #define NVXIO_LOGE(tag, ...) ((void)__android_log_print(ANDROID_LOG_ERROR, tag, __VA_ARGS__))
115 #define NVXIO_THROW_EXCEPTION(msg) \
117 std::ostringstream ostr_; \
119 throw std::runtime_error(ostr_.str()); \
129 #define NVXIO_SAFE_CALL(vxOp) \
132 vx_status status = (vxOp); \
133 if (status != VX_SUCCESS) \
135 NVXIO_THROW_EXCEPTION(# vxOp << " failure [status = " << status << "]" << " in file " << __FILE__ << " line " << __LINE__); \
145 #define NVXIO_ASSERT(cond) \
150 NVXIO_THROW_EXCEPTION(# cond << " failure in file " << __FILE__ << " line " << __LINE__); \
160 #define NVXIO_CHECK_REFERENCE(ref) \
161 NVXIO_ASSERT(ref != 0 && vxGetStatus((vx_reference)ref) == VX_SUCCESS)
170 #define NVXIO_CUDA_SAFE_CALL(cudaOp) \
173 cudaError_t err = (cudaOp); \
174 if (err != cudaSuccess) \
176 std::ostringstream ostr; \
177 ostr << "CUDA Error in " << # cudaOp << __FILE__ << " file " << __LINE__ << " line : " << cudaGetErrorString(err); \
178 throw std::runtime_error(ostr.str()); \
187 template <
typename T, vx_size N>
286 template <
typename T,
typename... Args>
287 std::unique_ptr<T>
makeUP(Args &&... args)
289 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
345 #endif // NVXIO_UTILITY_HPP
size_t vx_size
A wrapper of size_t to keep the naming convention uniform.
NVXIO_EXPORT void checkIfContextIsValid(vx_context context)
Checks whether the context is valid and throws an exception in case of failure.
NVIDIA VisionWorks Framework and Primitives API.
ContextGuard is a wrapper for vx_context.
char vx_char
An 8 bit ASCII character.
float vx_float32
A 32-bit float value.
NVXIO_EXPORT void VX_CALLBACK stdoutLogCallback(vx_context context, vx_reference ref, vx_status status, const vx_char string[])
The callback for OpenVX error logs, which prints messages to standard output.
const vx_float64 PI
Double-precision PI.
vx_status VX_API_CALL vxReleaseContext(vx_context *context)
Releases the OpenVX object context.
vx_enum vx_status
A formal status type with known fixed size.
struct _vx_context * vx_context
An opaque reference to the implementation context.
NVXIO_EXPORT void printPerf(vx_graph graph, const char *label)
Prints performance information for the provided graph object.
struct _vx_reference * vx_reference
A generic opaque reference to any object within OpenVX.
std::unique_ptr< T > makeUP(Args &&...args)
make_unique function.
double vx_float64
A 64-bit float value (aka double).
const vx_float32 PI_F
Float-precision PI.
vx_context VX_API_CALL vxCreateContext()
Creates a vx_context.
struct _vx_graph * vx_graph
An opaque reference to a graph.
vx_size dimOf(T(&)[N])
Returns the size of an array (the N template argument).
struct _vx_node * vx_node
An opaque reference to a kernel node.
NVXIO_EXPORT std::vector< std::string > getSupportedFeatures()
Returns a vector of NVXIO supported features.