VPI - Vision Programming Interface

0.1.0 Release

Types.h File Reference
#include <stdint.h>
+ Include dependency graph for Types.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  VPIParallelForConfig
 
struct  VPIKeypoint
 Stores a keypoint coordinate. More...
 
struct  VPIHomographyTransform2D
 Stores a generic 2D homography transform. More...
 
struct  VPIBoundingBox
 Stores a generic 2D bounding box. More...
 
struct  VPIKLTTrackedBoundingBox
 Stores a bounding box that is being tracked by KLT Tracker. More...
 

Typedefs

typedef void(* VPIParallelTask) (int taskId, int threadId, void *vpiData)
 
typedef void(* VPIParallelForCallback) (VPIParallelTask task, int taskCount, void *vpiData, void *userData)
 
typedef void * VPINativeThreadHandle
 
typedef struct VPIArrayImpl * VPIArray
 
typedef struct VPIContextImpl * VPIContext
 
typedef struct VPIEventImpl * VPIEvent
 
typedef struct VPIStreamImpl * VPIStream
 
typedef struct VPIImageImpl * VPIImage
 
typedef struct VPIPyramidImpl * VPIPyramid
 
typedef struct VPIPayloadImpl * VPIPayload
 A handle to an algorithm payload.
 
typedef VPIStatus(* VPIUserFunction) (void *)
 Pointer to user function. More...
 

Enumerations

enum  VPIImageType {
  VPI_IMAGE_TYPE_INVALID =0, VPI_IMAGE_TYPE_Y8, VPI_IMAGE_TYPE_Y8I, VPI_IMAGE_TYPE_Y16,
  VPI_IMAGE_TYPE_Y16I, VPI_IMAGE_TYPE_NV12, VPI_IMAGE_TYPE_RGB8, VPI_IMAGE_TYPE_RGBA8
}
 Image formats. More...
 
enum  VPIPixelType {
  VPI_PIXEL_TYPE_DEFAULT = 0, VPI_PIXEL_TYPE_INVALID, VPI_PIXEL_TYPE_1C_U8, VPI_PIXEL_TYPE_1C_S8,
  VPI_PIXEL_TYPE_1C_U16, VPI_PIXEL_TYPE_1C_S16, VPI_PIXEL_TYPE_2C_U8, VPI_PIXEL_TYPE_3C_U8,
  VPI_PIXEL_TYPE_4C_U8
}
 Pixel formats. More...
 
enum  VPIBoundaryCond { VPI_BOUNDARY_COND_ZERO, VPI_BOUNDARY_COND_CLAMP }
 Image boundary condition specify how pixel values outside of the image domain should be constructed. More...
 
enum  VPIArrayType {
  VPI_ARRAY_TYPE_INVALID =0, VPI_ARRAY_TYPE_S8, VPI_ARRAY_TYPE_U8, VPI_ARRAY_TYPE_S16,
  VPI_ARRAY_TYPE_U16, VPI_ARRAY_TYPE_U32, VPI_ARRAY_TYPE_KEYPOINT, VPI_ARRAY_TYPE_HOMOGRAPHY_TRANSFORM_2D,
  VPI_ARRAY_TYPE_KLT_TRACKED_BOUNDING_BOX
}
 Array element formats. More...
 
enum  VPIInterpolationType {
  VPI_INTERP_NEAREST, VPI_INTERP_LINEAR, VPI_INTERP_LINEAR_FAST, VPI_INTERP_CATMULL_ROM,
  VPI_INTERP_CATMULL_ROM_FAST
}
 Interpolation types supported by several algorithms. More...
 
enum  VPILockMode { VPI_LOCK_READ = 1, VPI_LOCK_WRITE = 2, VPI_LOCK_READ_WRITE = 3 }
 Defines the lock modes used by memory lock functions. More...
 
enum  VPIStatus {
  VPI_SUCCESS = 0, VPI_ERROR_NOT_IMPLEMENTED, VPI_ERROR_INVALID_ARGUMENT, VPI_ERROR_INVALID_IMAGE_TYPE,
  VPI_ERROR_INVALID_ARRAY_TYPE, VPI_ERROR_INVALID_PYRAMID_TYPE, VPI_ERROR_INVALID_PAYLOAD_TYPE, VPI_ERROR_INVALID_OPERATION,
  VPI_ERROR_INVALID_CONTEXT, VPI_ERROR_DEVICE, VPI_ERROR_NOT_READY, VPI_ERROR_BUFFER_LOCKED,
  VPI_ERROR_OUT_OF_MEMORY, VPI_ERROR_INTERNAL
}
 Error codes. More...
 
enum  VPIDeviceType { VPI_DEVICE_TYPE_INVALID, VPI_DEVICE_TYPE_CPU, VPI_DEVICE_TYPE_CUDA, VPI_DEVICE_TYPE_PVA }
 Device types. More...
 

Detailed Description

Defines all types needed for programming with VPI.

Definition in file Types.h.


Data Structure Documentation

◆ VPIKeypoint

struct VPIKeypoint

Stores a keypoint coordinate.

The coordinate is relative to the top-left corner of an image.

Definition at line 298 of file Types.h.

+ Collaboration diagram for VPIKeypoint:
Data Fields
float x Keypoint's x coordinate.
float y Keypoint's y coordinate.

◆ VPIHomographyTransform2D

struct VPIHomographyTransform2D

Stores a generic 2D homography transform.

When only scale and translation transformation is needed, these parameters must be arranged in the matrix as follows:

\[ \begin{bmatrix} s_x & 0 & p_x \\ 0 & s_y & p_y \\ 0 & 0 & 1 \end{bmatrix} \]

Scaling \((s_x,s_y)\) is relative to the center of the patch, position \((p_x,p_y)\) is relative to the top-left of the image.

In the general case, given an homogeneous 2D point \(P(x,y,1)\) and the matrix \(M^{3x3}\), the Euclidean 2D point \(O(x,y)\) is defined as

\begin{align} T &= M \cdot P \\ O &= (T_x/T_z, T_y/T_z) \end{align}

Definition at line 326 of file Types.h.

+ Collaboration diagram for VPIHomographyTransform2D:
Data Fields
float mat3[3][3] 3x3 homogeneous matrix that defines the homography.

◆ VPIBoundingBox

struct VPIBoundingBox

Stores a generic 2D bounding box.

Although this structure can store a 2D bounding box transformed by any homography, most of the time it stores an axis-aligned bounding box. To retrieve it, do the following:

float x = xform.mat3[0][2];
float y = xform.mat3[1][2];
float w = width * xform.mat3[0][0];
float h = height * xform.mat3[1][1];

Definition at line 344 of file Types.h.

+ Collaboration diagram for VPIBoundingBox:
Data Fields
float height Bounding box height.
float width Bounding box width.
VPIHomographyTransform2D xform Defines the bounding box top left corner and its homography.

◆ VPIKLTTrackedBoundingBox

struct VPIKLTTrackedBoundingBox

Stores a bounding box that is being tracked by KLT Tracker.

Definition at line 354 of file Types.h.

+ Collaboration diagram for VPIKLTTrackedBoundingBox:
Data Fields
VPIBoundingBox bbox Bounding box being tracked.
uint8_t reserved1 Reserved for future use.
uint8_t reserved2 Reserved for future use.
uint8_t templateStatus Status of the template related to this bounding box.

Accepted values:

  • 1 template needs updating.
  • 0 existing template still can be used for tracking, it doesn't need to be updated.
uint8_t trackingStatus Tracking status of this bounding box.

Accepted values:

  • 1 tracking information is invalid and shouldn't be relied upon.
  • 0 tracking information is valid.

Typedef Documentation

◆ VPIStream

typedef struct VPIStreamImpl* VPIStream

A handle to a device.

Definition at line 147 of file Types.h.

◆ VPIUserFunction

typedef VPIStatus(* VPIUserFunction) (void *)

Pointer to user function.

Parameters
void* [in] callback data

Definition at line 428 of file Types.h.

Enumeration Type Documentation

◆ VPIArrayType

Array element formats.

Enumerator
VPI_ARRAY_TYPE_INVALID 

Signal type conversion errors.

VPI_ARRAY_TYPE_S8 

signed 8-bit.

VPI_ARRAY_TYPE_U8 

unsigned 8-bit.

VPI_ARRAY_TYPE_S16 

signed 16-bit.

VPI_ARRAY_TYPE_U16 

unsigned 16-bit.

VPI_ARRAY_TYPE_U32 

unsigned 32-bit.

VPI_ARRAY_TYPE_KEYPOINT 

VPIKeypoint element.

VPI_ARRAY_TYPE_HOMOGRAPHY_TRANSFORM_2D 

VPIHomographyTransform2D element.

VPI_ARRAY_TYPE_KLT_TRACKED_BOUNDING_BOX 

VPIKLTTrackedBoundingBox element.

Definition at line 209 of file Types.h.

◆ VPIBoundaryCond

Image boundary condition specify how pixel values outside of the image domain should be constructed.

Enumerator
VPI_BOUNDARY_COND_ZERO 

All pixels outside the image are considered to be zero.

VPI_BOUNDARY_COND_CLAMP 

Border pixels are repeated indefinitely.

Definition at line 203 of file Types.h.

◆ VPIDeviceType

Device types.

Enumerator
VPI_DEVICE_TYPE_INVALID 

Invalid backend.

VPI_DEVICE_TYPE_CPU 

CPU backend.

VPI_DEVICE_TYPE_CUDA 

CUDA backend.

VPI_DEVICE_TYPE_PVA 

PVA backend.

Definition at line 431 of file Types.h.

◆ VPIImageType

Image formats.

An image type represents one or more planar channels, each one having a particular VPIPixelType. In these image types, each channel is assigned a color component for algorithms that need it. The luma (Y) image types can also be used for generic, single-channel elements.

Enumerator
VPI_IMAGE_TYPE_INVALID 

Signal type conversion errors.

VPI_IMAGE_TYPE_Y8 

unsigned 8-bit grayscale/luma.

VPI_IMAGE_TYPE_Y8I 

signed 8-bit grayscale/luma.

VPI_IMAGE_TYPE_Y16 

unsigned 16-bit grayscale/luma.

VPI_IMAGE_TYPE_Y16I 

signed 16-bit grayscale/luma.

VPI_IMAGE_TYPE_NV12 

8-bit NV12.

VPI_IMAGE_TYPE_RGB8 

8-bit RGB, R being the most significant byte.

VPI_IMAGE_TYPE_RGBA8 

8-bit RGBA, R being the MSB.

Definition at line 172 of file Types.h.

◆ VPIInterpolationType

Interpolation types supported by several algorithms.

Enumerator
VPI_INTERP_NEAREST 

Nearest neighbor interpolation.

\[ P(x,y) = \mathit{in}[\lfloor x+0.5 \rfloor, \lfloor y+0.5 \rfloor] \]

VPI_INTERP_LINEAR 

Linear interpolation.

Interpolation weights are defined as:

\begin{align*} w_0(t)& \triangleq t-\lfloor t \rfloor \\ w_1(t)& \triangleq 1 - w_0(t) \\ \end{align*}

Bilinear-interpolated value is given by the formula below:

\[ P(x,y) = \sum_{p=0}^1 \sum_{q=0}^1 \mathit{in}[\lfloor x \rfloor+p, \lfloor y \rfloor+q]w_p(x)w_q(y) \]

VPI_INTERP_LINEAR_FAST 

Fast linear interpolation.

Takes advantage of CUDA's backend hardware interpolator and take only 1 linear sample per pixel instead of 4, yielding better performance. There's a slight decrease in precision due to \(\alpha_x\) and \(\alpha_y\) being stored in 9-bit fixed point format (8 bits of fractional value), which amounts to ~1% maximum relative error.

It uses a technique presented here.

For other backends, it works exactly like VPI_INTERP_LINEAR.

VPI_INTERP_CATMULL_ROM 

Catmull-Rom cubic interpolation.

Catmull-Rom interpolation weights with \(A=-0.5\) are defined as follows:

\begin{eqnarray*} w_0(t) &\triangleq& A(t+1)^3 &-& 5A(t+1)^2 &+& 8A(t+1) &-& 4A \\ w_1(t) &\triangleq& (A+2)t^3 &-& (A+3)t^2 &\nonumber& &+& 1 \\ w_2(t) &\triangleq& (A+2)(1-t)^3 &-& (A+3)(1-t)^2 &\nonumber& &+& 1 \\ w_3(t) &\triangleq& \rlap{1 - w_0(t) - w_1(t) - w_2(t) } \end{eqnarray*}

Bicubic-interpolated value is given by the formula below:

\[ P(x,y) = \sum_{p=-1}^2 \sum_{q=-1}^2 \mathit{in}[\lfloor x \rfloor+p, \lfloor y \rfloor+q]w_p(x)w_q(y) \]

VPI_INTERP_CATMULL_ROM_FAST 

Fast Catmull-Rom cubic interpolation.

Takes advantage of CUDA's backend hardware interpolator and take 9 linear samples per pixel instead of 16, yielding better performance. There's a slight decrease in precision due to linear weights being stored in hardware in 9-bit fixed point format (8 bits of fractional value).

It uses a variation of the technique presented here. The paper assumes that \(w_1/(w_0+w_1), w_3/(w_2+w_3) \in [0,1]\), which doesn't hold for Catmull-Rom interpolator, but for \(w_2/(w_1+w_2)\) it does. So, in the 1D case, 3 texture fetches are performed: one linear fetch corresponding to \(w_1T_0 + w_2T_1\), and two more regular fetches for \(w_0T_{-1}\) and \(w_3T_2\). These 3 fetches in 1D correspond to 9 fetches in 2D.

For other backends, it works exactly like VPI_INTERP_LINEAR.

Definition at line 224 of file Types.h.

◆ VPILockMode

Defines the lock modes used by memory lock functions.

Enumerator
VPI_LOCK_READ 

Lock memory only for reading.

Writing to the memory when locking for reading leads to undefined behavior.

VPI_LOCK_WRITE 

Lock memory only for writing.

Reading to the memory when locking for reading leads to undefined behavior. It is expected that the whole memory is written to. If there are regions not written, it might not be updated correctly during unlock. In this case, it's better to use VPI_LOCK_READ_WRITE.

It might be slightly efficient to lock only for writing, specially when performing non-shared memory mapping.

VPI_LOCK_READ_WRITE 

Lock memory for reading and writing.

Definition at line 382 of file Types.h.

◆ VPIPixelType

Pixel formats.

Represents the geometry of pixels in a image channel.

Enumerator
VPI_PIXEL_TYPE_DEFAULT 

Used to signal that the pixel type must be inferred from image type.

VPI_PIXEL_TYPE_INVALID 

Signal type conversion errors.

VPI_PIXEL_TYPE_1C_U8 

1 channel of unsigned 8-bit values.

VPI_PIXEL_TYPE_1C_S8 

1 channel of signed 8-bit values.

VPI_PIXEL_TYPE_1C_U16 

1 channel of unsigned 16-bit values.

VPI_PIXEL_TYPE_1C_S16 

1 channel of signed 16-bit values.

VPI_PIXEL_TYPE_2C_U8 

2 interleaved channels of unsigned 8-bit values.

VPI_PIXEL_TYPE_3C_U8 

3 interleaved channels of unsigned 8-bit values.

VPI_PIXEL_TYPE_4C_U8 

4 interleaved channels of unsigned 8-bit values.

Definition at line 187 of file Types.h.

◆ VPIStatus

enum VPIStatus

Error codes.

When an error is generated, a descriptive error message is printed in stderr.

Enumerator
VPI_SUCCESS 

Operation completed successfully.

VPI_ERROR_NOT_IMPLEMENTED 

Operation isn't implemented.

VPI_ERROR_INVALID_ARGUMENT 

Invalid argument, either wrong range or value not accepted.

VPI_ERROR_INVALID_IMAGE_TYPE 

Image type not accepted.

VPI_ERROR_INVALID_ARRAY_TYPE 

Array type not accepted.

VPI_ERROR_INVALID_PYRAMID_TYPE 

Pyramid type not accepted.

VPI_ERROR_INVALID_PAYLOAD_TYPE 

Payload not created for this algorithm.

VPI_ERROR_INVALID_OPERATION 

Operation isn't valid in this context.

VPI_ERROR_INVALID_CONTEXT 

Context is invalid or is already destroyed.

VPI_ERROR_DEVICE 

Device backend error.

VPI_ERROR_NOT_READY 

Operation not completed yet, try again later.

VPI_ERROR_BUFFER_LOCKED 

Invalid operation on a locked buffer.

VPI_ERROR_OUT_OF_MEMORY 

Not enough free memory to allocate object.

VPI_ERROR_INTERNAL 

Internal, non specific error.

Definition at line 407 of file Types.h.

VPIBoundingBox::width
float width
Bounding box width.
Definition: Types.h:347
VPIHomographyTransform2D::mat3
float mat3[3][3]
3x3 homogeneous matrix that defines the homography.
Definition: Types.h:328
VPIBoundingBox::height
float height
Bounding box height.
Definition: Types.h:347
VPIBoundingBox::xform
VPIHomographyTransform2D xform
Defines the bounding box top left corner and its homography.
Definition: Types.h:346