VisionWorks Toolkit Reference

April 8, 2016 | 1.4 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Initialization and Deinitialization

This tutorial demonstrates VisionWorks and NVXIO libraries initialization and deinitialization.

VisionWorks library initialization is controlled via the vx_context object. It is the main object that holds all other data and framework objects, and controls immediate mode execution.

The NVXIO library is initialized via the nvxio::Application object. It is a singleton object that initializes the NVXIO library environment and parses command line arguments.

std::string sourceUri = app.findSampleFilePath("lena.jpg");
app.setDescription("This tutorial demonstrates basic concepts of VisionWorks and NVXIO libraries");
app.addOption('s', "source", "Source URI", nvxio::OptionHandler::string(&sourceUri));
app.init(argc, argv);

VisionWorks deinitialization is performed via the vxReleaseContext call. The context object destruction releases all references to data and framework objects that were not released by application. For debug purposes, the application might query the number of active references from the context object using the VX_CONTEXT_ATTRIBUTE_REFERENCES attribute.

vx_uint32 numActiveReferences;
vxQueryContext(context, VX_CONTEXT_ATTRIBUTE_REFERENCES, &numActiveReferences, sizeof(numActiveReferences));
printf("Number of active references : %u\n", numActiveReferences);
fflush(stdout);
vxReleaseContext(&context);

NVXIO library deinitialization is performed implicitly by the Application object.

NVXIO provides a utility class that encapsulates VisionWorks context creation and destruction in the constructor and destructor. The object of this class can be implicitly cast to type vx_context.

{
// VisionWorks context will be released in nvxio::ContextGuard destructor
}