![]() |
VisionWorks Toolkit ReferenceDecember 18, 2015 | 1.2 Release |
Adds various extensions to the vx_image
object.
This section describes different extensions and features to the standard Object: Image.
Image dimensions in VisionWorks implementations must not exceed INT32_MAX
.
In VisionWorks, images can be accessed from the CUDA device memory in addition to the host CPU memory defined in the OpenVX specification. For this, the application must use CUDA-specific accessors nvx_accessor_e for the usage parameter of function vxAccessImagePatch
.
Example Code
In VisionWorks, the vxCreateImageFromHandle
function can import images from:
VX_IMPORT_TYPE_HOST
In both cases, the imported memory must satisfy the following memory layout condition:
By creating an image from handle, the application temporarily transfers the property of the memory referenced by the handle to VisionWorks. VisionWorks uses it as pixel storage memory for the newly created vx_image object. The application gets back possession of the memory when the vx_image object is destroyed (when its total reference count is zero).
Since the property of the memory is transferred to VisionWorks, the application is not allowed to directly access image pixels through the memory handle it passed to the vxCreateImageFromHandle
function. The application must use vxAccessImagePatch
/vxCommitImagePatch
functions to access pixels similar to standard images. vxAccessImagePatch
/vxCommitImagePatch
methods notify the framework about image access so that the framework can perform appropriate synchronization internally between CPU and GPU memory.
When the application requests access to an image created from handle in 'map' mode (when *ptr is null, ptr being a parameter of the vxAccessImagePatch
function) and for the same memory type as the handle given at image creation time, then the requested patch is mapped at its original address and with the original layout.
After the destruction of a vx_image
object created from handle that occurs when its total reference count reaches zero, the memory referenced by the handle contains up-to-date pixel data. The property of the memory is also transferred back to the application that can reuse or deallocate it freely.
Modules | |
Extra Map Flags | |
Extra flags for map operation. | |
Enumerations | |
enum | nvx_df_image_e { NVX_DF_IMAGE_F32 = VX_DF_IMAGE('F','0','3','2'), NVX_DF_IMAGE_2F32 = VX_DF_IMAGE('2','F','3','2'), NVX_DF_IMAGE_2S16 = VX_DF_IMAGE('2','S','1','6'), NVX_DF_IMAGE_RGB16 = VX_DF_IMAGE('S','3','1','6') } |
Defines additional image formats. More... | |
Functions | |
vx_image | nvxCreateImageFromChannel (vx_image imgref, vx_enum channel) |
Creates an image from a single channel of another image. More... | |
vx_status | nvxMapImagePatch (vx_image image, const vx_rectangle_t *rect, vx_uint32 plane_index, vx_imagepatch_addressing_t *addr, void **ptr, vx_enum usage, vx_enum memory_type, vx_uint32 flags) |
Maps a rectangular patch (subset) of an image from a single plane. More... | |
vx_status | nvxUnmapImagePatch (vx_image image, const vx_rectangle_t *rect, vx_uint32 plane_index, void *ptr, vx_enum memory_type) |
Unmaps a mapped patch (subset) of an image. More... | |
enum nvx_df_image_e |
Defines additional image formats.
Creates an image from a single channel of another image.
This second image refers to the data in the original image. Updates to this image updates the parent image.
The method supports only multi-planar images (YUV4, IYUV, NV12, NV21) and only channels that occupy an entire plane.
[in] | imgref | Specifies the parent image. |
[in] | channel | Specifies the channel to use. |
vx_status nvxMapImagePatch | ( | vx_image | image, |
const vx_rectangle_t * | rect, | ||
vx_uint32 | plane_index, | ||
vx_imagepatch_addressing_t * | addr, | ||
void ** | ptr, | ||
vx_enum | usage, | ||
vx_enum | memory_type, | ||
vx_uint32 | flags | ||
) |
Maps a rectangular patch (subset) of an image from a single plane.
[in] | image | The reference to the image from which to map the patch. |
[in] | rect | The coordinates from which to get the patch. Must be 0 <= start < end. |
[in] | plane_index | The plane index from which to get the data. |
[out] | addr | A pointer to a structure describing the addressing information of the image patch to be accessed. |
[out] | ptr | A pointer to a pointer to a location to access the requested data. |
[in] | usage | This declares the intended usage of the pointer using the vx_accessor_e enumeration. |
[in] | memory_type | This declares the intended memory type of the mapped memory. Supported values : VX_IMPORT_TYPE_HOST and NVX_IMPORT_TYPE_CUDA. |
[in] | flags | Extra flags for map operation. It must be a bitwise combination of values from Extra Map Flags or 0 for default behavior. |
If an image is imported from user memory and memory_type
corresponds to its import type and flags
is equal to 0
, then the original imported pointer and memory layout is returned.
vx_status nvxUnmapImagePatch | ( | vx_image | image, |
const vx_rectangle_t * | rect, | ||
vx_uint32 | plane_index, | ||
void * | ptr, | ||
vx_enum | memory_type | ||
) |
Unmaps a mapped patch (subset) of an image.
[in] | image | The reference to the image. |
[in] | rect | The coordinates of the patch. |
[in] | plane_index | The plane index. |
[in] | ptr | The mapped pointer returned by nvxMapImagePatch. |
[in] | memory_type | The memory type of the mapped pointer. |