VisionWorks Toolkit Reference

April 8, 2016 | 1.4 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Utility

Detailed Description

Defines NVXIO Utility API.

Data Structures

struct  nvxio::ContextGuard
 ContextGuard is a wrapper for vx_context. More...
 

Macros

#define NVXIO_ASSERT(cond)
 Checks a condition. More...
 
#define NVXIO_CHECK_REFERENCE(ref)   NVXIO_ASSERT(ref != 0 && vxGetStatus((vx_reference)ref) == VX_SUCCESS)
 Checks a reference. More...
 
#define NVXIO_CUDA_SAFE_CALL(cudaOp)
 Performs a CUDA operation. More...
 
#define NVXIO_SAFE_CALL(vxOp)
 Performs an NVX operation. More...
 
#define NVXIO_THROW_EXCEPTION(msg)
 Throws std::runtime_error exception. More...
 

Functions

NVXIO_EXPORT void nvxio::checkIfContextIsValid (vx_context context)
 Checks whether the context is valid and throws an exception in case of failure. More...
 
template<typename T , vx_size N>
vx_size nvxio::dimOf (T(&)[N])
 Returns the size of an array (the N template argument). More...
 
NVXIO_EXPORT std::vector
< std::string > 
nvxio::getSupportedFeatures ()
 Returns a vector of NVXIO supported features. More...
 
template<typename T , typename... Args>
std::unique_ptr< T > nvxio::makeUP (Args &&...args)
 make_unique function. More...
 
NVXIO_EXPORT void nvxio::printPerf (vx_graph graph, const char *label)
 Prints performance information for the provided graph object. More...
 
NVXIO_EXPORT void nvxio::printPerf (vx_node node, const char *label)
 Prints performance information for the provided node object. More...
 
NVXIO_EXPORT void VX_CALLBACK nvxio::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. More...
 

Variables

const vx_float64 nvxio::PI = 3.1415926535897932
 Double-precision PI. More...
 
const vx_float32 nvxio::PI_F = 3.14159265f
 Float-precision PI. More...
 

Macro Definition Documentation

#define NVXIO_ASSERT (   cond)
Value:
do \
{ \
if (!(cond)) \
{ \
NVXIO_THROW_EXCEPTION(# cond << " failure in file " << __FILE__ << " line " << __LINE__); \
} \
} while (0)
#define NVXIO_THROW_EXCEPTION(msg)
Throws std::runtime_error exception.
Definition: Utility.hpp:115

Checks a condition.

If the condition is false then it throws std::runtime_error exception.

Parameters
[in]condExpression to be evaluated.
See also
NVXIO APIs

Definition at line 145 of file Utility.hpp.

#define NVXIO_CHECK_REFERENCE (   ref)    NVXIO_ASSERT(ref != 0 && vxGetStatus((vx_reference)ref) == VX_SUCCESS)

Checks a reference.

If the reference is not valid then it throws std::runtime_error exception.

Parameters
[in]refReference to be checked.
See also
NVXIO APIs

Definition at line 160 of file Utility.hpp.

#define NVXIO_CUDA_SAFE_CALL (   cudaOp)
Value:
do \
{ \
cudaError_t err = (cudaOp); \
if (err != cudaSuccess) \
{ \
std::ostringstream ostr; \
ostr << "CUDA Error in " << # cudaOp << __FILE__ << " file " << __LINE__ << " line : " << cudaGetErrorString(err); \
throw std::runtime_error(ostr.str()); \
} \
} while (0)

Performs a CUDA operation.

If the operation fails, then it throws std::runtime_error exception.

Parameters
[in]cudaOpSpecifies a function to be called. The function must have cudaError_t return value.
See also
NVXIO APIs

Definition at line 170 of file Utility.hpp.

#define NVXIO_SAFE_CALL (   vxOp)
Value:
do \
{ \
vx_status status = (vxOp); \
if (status != VX_SUCCESS) \
{ \
NVXIO_THROW_EXCEPTION(# vxOp << " failure [status = " << status << "]" << " in file " << __FILE__ << " line " << __LINE__); \
} \
} while (0)
No error.
Definition: vx_types.h:414
vx_enum vx_status
A formal status type with known fixed size.
Definition: vx_types.h:421
#define NVXIO_THROW_EXCEPTION(msg)
Throws std::runtime_error exception.
Definition: Utility.hpp:115

Performs an NVX operation.

If the operation fails, then it throws std::runtime_error exception.

Parameters
[in]vxOpA function to be called. The function must have vx_status return value.
See also
NVXIO APIs

Definition at line 129 of file Utility.hpp.

#define NVXIO_THROW_EXCEPTION (   msg)
Value:
do { \
std::ostringstream ostr_; \
ostr_ << msg; \
throw std::runtime_error(ostr_.str()); \
} while(0)

Throws std::runtime_error exception.

Parameters
[in]msgA message with content related to the exception.
See also
NVXIO APIs

Definition at line 115 of file Utility.hpp.

Function Documentation

NVXIO_EXPORT void nvxio::checkIfContextIsValid ( vx_context  context)

Checks whether the context is valid and throws an exception in case of failure.

Parameters
[in]contextSpecifies the context to check.
See also
NVXIO APIs

Referenced by nvxio::ContextGuard::ContextGuard().

template<typename T , vx_size N>
vx_size nvxio::dimOf ( T(&)  [N])

Returns the size of an array (the N template argument).

See also
NVXIO APIs

Definition at line 188 of file Utility.hpp.

NVXIO_EXPORT std::vector<std::string> nvxio::getSupportedFeatures ( )

Returns a vector of NVXIO supported features.

The following scheme is used to describe the features in the form of tree:

  <feature_type>:<IO_object_type>:<backend>:<details_0>:<details_1>:...

<feature_type> possible values:

  • render2d - describes a set of 2D renders.
  • render3d - describes a set of 3D renders.
  • source - describes a set of frame sources.

<IO_object_type> possible values:

  • image - a sequence of images. The source features read the sequence; the render features write the sequence.
  • video - a video file.
  • window - a UI window.
  • camera - different types of cameras - USB, CSI, etc.

<backend> possible values:

  • opencv - implementation using OpenCV drawing utilities.
  • opengl - implementation using OpenGL (ES) shaders.
  • gstreamer - GStreamer implementation.
  • v4l2 - Video 4 Linux 2 implementation
  • nvmedia - NvMedia implementation
  • openmax - OpenMAX implementation

<details_N> tags can store any additional information about the feature.

Examples:

  • render2d:video:gstreamer: a 2D render that can write to a video file using GStreamer backend
  • source:video:nvmedia:pure: a frame source that can fetch images from a video file using the "pure" NvMedia backend
  • source:camera:nvmedia:pure:dvp-ov10635-yuv422-ab: a frame source that can fetch images from an OV10635 camera attached to ab ports in a YUV422 format using "pure" NvMedia backend.
See also
NVXIO APIs
template<typename T , typename... Args>
std::unique_ptr<T> nvxio::makeUP ( Args &&...  args)

make_unique function.

See also
NVXIO APIs

Definition at line 287 of file Utility.hpp.

NVXIO_EXPORT void nvxio::printPerf ( vx_graph  graph,
const char *  label 
)

Prints performance information for the provided graph object.

Parameters
[in]graphSpecifies the graph object.
[in]labelSpecifies the label.
NVXIO_EXPORT void nvxio::printPerf ( vx_node  node,
const char *  label 
)

Prints performance information for the provided node object.

Parameters
[in]nodeSpecifies the node object.
[in]labelSpecifies the label.
NVXIO_EXPORT void VX_CALLBACK nvxio::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.

Must be used as a parameter for vxRegisterLogCallback.

Parameters
[in]contextSpecifies the OpenVX context.
[in]refSpecifies the reference to the object that generated the error message.
[in]statusSpecifies the error code.
[in]stringSpecifies the error message.

Variable Documentation

const vx_float64 nvxio::PI = 3.1415926535897932

Double-precision PI.

See also
NVXIO APIs

Definition at line 199 of file Utility.hpp.

const vx_float32 nvxio::PI_F = 3.14159265f

Float-precision PI.

See also
NVXIO APIs

Definition at line 205 of file Utility.hpp.