VPI - Vision Programming Interface

0.1.0 Release

Sample Applications

Overview

The provided samples show how the library is used in simple scenarios. Most of them accept one or more arguments specifying the backend to be used, and the images to be processed. The result is saved back to disk into the same directory.

For convenience, VPI includes sample images that can be used as input. They are located in /opt/nvidia/vpi/vpi-0.1/samples/assets and can be referred directly.

Environment Setup

Sample applications are installed in /opt/nvidia/vpi/vpi-0.1/samples.

To build the sample application these packages must be installed:

  • cmake >= 3.8
  • g++ or clang (tested with g++-7 and clang-7)
  • OpenCV >= 3.2

For Ubuntu-18.04, install the packages by executing:

apt-get install cmake g++ libopencv-dev

The installer sets up the system to allow using VPI immediately. CMake is able to find the vpi package without additional user intervention. All header and library paths are set up correctly.

Build Instructions

From within a sample directory, execute:

cmake .
make

The sample is built into an executable in the same directory.

Once built, execute each sample using input images, such as those included in the sample assets directory.

Sample Applications

The provided sample applications, along with instructions on how to run them, are as follows.

  1. Convolve 2D
  2. Stereo Disparity
  3. Harris Corners Detector
  4. Image Resample
  5. KLT Bounding Box Tracker
  6. Event timing
VPIImagePlane::height
uint32_t height
Height of this plane in pixels.
Definition: Image.h:126
VPIContext
struct VPIContextImpl * VPIContext
Definition: Types.h:135
vpiArrayDestroy
void vpiArrayDestroy(VPIArray array)
Destroy an array instance as well as all resources it owns.
vpiEventElapsedTime
VPIStatus vpiEventElapsedTime(VPIEvent start, VPIEvent end, float *msec)
Computes the elapsed time in (msec) between two completed events.
vpiEventCreate
VPIStatus vpiEventCreate(uint32_t flags, VPIEvent *event)
Create an event instance with the specified flags.
VPIDeviceType
VPIDeviceType
Device types.
Definition: Types.h:431
VPIImagePlane::width
uint32_t width
Width of this plane in pixels.
Definition: Image.h:125
vpiSubmitGaussianPyramidGenerator
VPIStatus vpiSubmitGaussianPyramidGenerator(VPIStream stream, VPIImage input, VPIPyramid output)
Computes the Gaussian pyramid from the input image.
vpiArrayCreate
VPIStatus vpiArrayCreate(uint32_t capacity, VPIArrayType fmt, uint32_t flags, VPIArray *array)
Create an empty array instance with the specified flags.
vpiPyramidCreate
VPIStatus vpiPyramidCreate(uint32_t width, uint32_t height, VPIImageType fmt, uint32_t numLevels, float scale, uint32_t flags, VPIPyramid *pyr)
Create an empty image pyramid instance with the specified flags.
vpiEventSync
VPIStatus vpiEventSync(VPIEvent event)
Blocks the calling thread until the event is completed.
ImageConvolver.h
vpiCreateStereoDisparityEstimator
VPIStatus vpiCreateStereoDisparityEstimator(VPIStream stream, uint32_t imageWidth, uint32_t imageHeight, const VPIImageType inputType, const uint32_t maxDisparity, VPIPayload *payload)
Creates payload for vpiSubmitStereoDisparityEstimator.
VPIImageType
VPIImageType
Image formats.
Definition: Types.h:172
VPIHarrisKeypointDetectorParams::sensitivity
float sensitivity
Specifies sensitivity threshold from the Harris-Stephens equation.
Definition: HarrisKeypointDetector.h:92
VPI_IMAGE_TYPE_Y16I
signed 16-bit grayscale/luma.
Definition: Types.h:177
VPIKLTTrackedBoundingBox
Stores a bounding box that is being tracked by KLT Tracker.
Definition: Types.h:354
VPIKLTTrackedBoundingBox::bbox
VPIBoundingBox bbox
Bounding box being tracked.
Definition: Types.h:357
vpiContextCreate
VPIStatus vpiContextCreate(uint32_t flags, VPIContext *ctx)
Create a context instance.
GaussianImageFilter.h
VPIKeypoint
Stores a keypoint coordinate.
Definition: Types.h:298
KLTBoundingBoxTracker.h
VPIKLTTrackedBoundingBox::trackingStatus
uint8_t trackingStatus
Tracking status of this bounding box.
Definition: Types.h:364
vpiEventRecord
VPIStatus vpiEventRecord(VPIEvent event, VPIStream stream)
Captures in the event the contents of the stream command queue at the time of this call.
vpiContextSetCurrent
VPIStatus vpiContextSetCurrent(VPIContext ctx)
Sets the context for the calling thread.
VPIHomographyTransform2D
Stores a generic 2D homography transform.
Definition: Types.h:326
VPIImagePlane::rowStride
uint32_t rowStride
Difference in bytes of beginning of one row and the beginning of the previous.
Definition: Image.h:127
vpiCreateHarrisKeypointDetector
VPIStatus vpiCreateHarrisKeypointDetector(VPIStream stream, uint32_t inputWidth, uint32_t inputHeight, VPIPayload *payload)
Creates a Harris Keypoint Detector payload.
VPIArrayData::type
VPIArrayType type
Type of each array element.
Definition: Array.h:118
vpiArraySetSize
VPIStatus vpiArraySetSize(VPIArray array, uint32_t size)
Set the array size in elements.
vpiArrayUnlock
VPIStatus vpiArrayUnlock(VPIArray array)
Releases the lock on array object.
vpiImageUnlock
VPIStatus vpiImageUnlock(VPIImage img)
Releases the lock on an image object.
VPIHarrisKeypointDetectorParams
Structure that defines the parameters for vpiSubmitHarrisKeypointDetector.
Definition: HarrisKeypointDetector.h:80
vpiStreamCreate
VPIStatus vpiStreamCreate(VPIDeviceType devType, VPIStream *stream)
Create a stream instance.
Array.h
vpiStreamSync
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
VPIImageData
Stores information about image characteristics and content.
Definition: Image.h:143
VPIKLTBoundingBoxTrackerParams::maxScaleChange
float maxScaleChange
Maximum relative scale change.
Definition: KLTBoundingBoxTracker.h:113
vpiSubmitImageResampler
VPIStatus vpiSubmitImageResampler(VPIStream stream, VPIImage input, VPIImage output, VPIInterpolationType interpolationType, VPIBoundaryCond boundary)
Runs a generic resampling algorithm on a 2D image.
HarrisKeypointDetector.h
VPIHarrisKeypointDetectorParams::strengthThresh
float strengthThresh
Specifies the minimum threshold with which to eliminate Harris Corner scores.
Definition: HarrisKeypointDetector.h:89
vpiSubmitStereoDisparityEstimator
VPIStatus vpiSubmitStereoDisparityEstimator(VPIPayload payload, VPIImage left, VPIImage right, VPIImage disparity, const VPIStereoDisparityEstimatorParams *params)
Runs stereo processing on a pair of images, outputs a disparity map.
StereoDisparityEstimator.h
VPIHarrisKeypointDetectorParams::gradientSize
uint32_t gradientSize
Gradient window size.
Definition: HarrisKeypointDetector.h:83
VPIArrayData::size
uint32_t size
Number of elements in the array.
Definition: Array.h:119
vpiArrayWrapHostMem
VPIStatus vpiArrayWrapHostMem(const VPIArrayData *arrayData, uint32_t flags, VPIArray *array)
Create an array object by wrapping around an existing host-memory block.
VPIKLTBoundingBoxTrackerParams::trackingType
VPIKLTBoundingBoxTrackerType trackingType
Type of KLT tracking that will be performed.
Definition: KLTBoundingBoxTracker.h:120
VPI_ARRAY_TYPE_HOMOGRAPHY_TRANSFORM_2D
VPIHomographyTransform2D element.
Definition: Types.h:217
vpiSubmitHarrisKeypointDetector
VPIStatus vpiSubmitHarrisKeypointDetector(VPIPayload payload, VPIImage input, VPIArray outFeatures, VPIArray outScores, const VPIHarrisKeypointDetectorParams *params)
Submits Harris Keypoint Detector operation to the stream associated with the payload.
vpiSubmitKLTBoundingBoxTracker
VPIStatus vpiSubmitKLTBoundingBoxTracker(VPIPayload payload, VPIImage templateImage, VPIArray inputBoxList, VPIArray inputPredictionList, VPIImage referenceImage, VPIArray outputBoxList, VPIArray outputEstimationList, const VPIKLTBoundingBoxTrackerParams *params)
Runs KLT Tracker on two frames.
vpiContextDestroy
void vpiContextDestroy(VPIContext ctx)
Destroy a context instance as well as all resources it owns.
VPIArrayData::capacity
uint32_t capacity
Maximum number of elements that the array can hold.
Definition: Array.h:120
vpiStreamDestroy
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
VPI_LOCK_READ
Lock memory only for reading.
Definition: Types.h:386
VPIArrayData::data
void * data
Points to the first element of the array.
Definition: Array.h:122
GaussianPyramidGenerator.h
vpiSubmitImageConvolver
VPIStatus vpiSubmitImageConvolver(VPIStream stream, VPIImage input, VPIImage output, const float *kernelData, uint32_t kernelWidth, uint32_t kernelHeight, VPIBoundaryCond boundary)
Runs a generic 2D convolution over an image.
VPIImageData::planes
VPIImagePlane planes[VPI_MAX_PLANE_COUNT]
Data of all image planes.
Definition: Image.h:151
VPIHarrisKeypointDetectorParams::minNMSDistance
float minNMSDistance
Non-maximum suppression radius, set to 0 to disable it.
Definition: HarrisKeypointDetector.h:95
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
VPIKLTBoundingBoxTrackerParams::maxTranslationChange
float maxTranslationChange
Maximum relative translation change.
Definition: KLTBoundingBoxTracker.h:117
VPI_INTERP_CATMULL_ROM
Catmull-Rom cubic interpolation.
Definition: Types.h:274
ImageResampler.h
VPIKLTBoundingBoxTrackerParams::nccThresholdStop
float nccThresholdStop
Threshold to stop estimating.
Definition: KLTBoundingBoxTracker.h:109
vpiImageDestroy
void vpiImageDestroy(VPIImage img)
Destroy an image instance as well as all resources it owns.
VPIKLTTrackedBoundingBox::templateStatus
uint8_t templateStatus
Status of the template related to this bounding box.
Definition: Types.h:371
VPI_ARRAY_TYPE_KEYPOINT
VPIKeypoint element.
Definition: Types.h:216
VPIBoundingBox::height
float height
Bounding box height.
Definition: Types.h:347
VPI_IMAGE_TYPE_Y8
unsigned 8-bit grayscale/luma.
Definition: Types.h:174
Image.h
VPIBoundingBox::xform
VPIHomographyTransform2D xform
Defines the bounding box top left corner and its homography.
Definition: Types.h:346
Event.h
VPIKLTBoundingBoxTrackerParams::nccThresholdKill
float nccThresholdKill
Threshold to consider template tracking was lost.
Definition: KLTBoundingBoxTracker.h:108
vpiCreateKLTBoundingBoxTracker
VPIStatus vpiCreateKLTBoundingBoxTracker(VPIStream stream, uint32_t imageWidth, uint32_t imageHeight, VPIImageType imageType, VPIPayload *payload)
Creates payload for vpiSubmitKLTBoundingBoxTracker.
VPIEvent
struct VPIEventImpl * VPIEvent
Definition: Types.h:141
VPI_ARRAY_TYPE_KLT_TRACKED_BOUNDING_BOX
VPIKLTTrackedBoundingBox element.
Definition: Types.h:218
VPIKLTBoundingBoxTrackerParams
Structure that defines the parameters for vpiCreateKLTBoundingBoxTracker.
Definition: KLTBoundingBoxTracker.h:104
VPI_IMAGE_TYPE_Y16
unsigned 16-bit grayscale/luma.
Definition: Types.h:176
VPIStereoDisparityEstimatorParams::windowSize
uint32_t windowSize
width of Census Transform window for disparity features.
Definition: StereoDisparityEstimator.h:82
VPIImage
struct VPIImageImpl * VPIImage
Definition: Types.h:153
VPIKLTBoundingBoxTrackerParams::nccThresholdUpdate
float nccThresholdUpdate
Threshold for requiring template update.
Definition: KLTBoundingBoxTracker.h:107
VPIImageData::numPlanes
int32_t numPlanes
Number of planes.
Definition: Image.h:146
vpiImageGetType
VPIStatus vpiImageGetType(VPIImage img, VPIImageType *type)
Get the image type.
VPIArrayData
Stores information about array characteristics and content.
Definition: Array.h:116
VPIHarrisKeypointDetectorParams::blockSize
uint32_t blockSize
Block window size used to compute the Harris Corner score.
Definition: HarrisKeypointDetector.h:86
Pyramid.h
vpiImageLock
VPIStatus vpiImageLock(VPIImage img, VPILockMode mode, VPIImageData *hostData)
Acquires the lock on an image object and returns a pointer to the image planes Depending on the inter...
VPIImageData::type
VPIImageType type
Image type.
Definition: Image.h:145
vpiImageCreate
VPIStatus vpiImageCreate(uint32_t width, uint32_t height, VPIImageType type, uint32_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
VPI_BOUNDARY_COND_ZERO
All pixels outside the image are considered to be zero.
Definition: Types.h:204
VPI_IMAGE_TYPE_Y8I
signed 8-bit grayscale/luma.
Definition: Types.h:175
vpiArrayLock
VPIStatus vpiArrayLock(VPIArray array, VPILockMode mode, VPIArrayData *arrayData)
Acquires the lock on array object and returns a pointer to array data.
vpiImageWrapHostMem
VPIStatus vpiImageWrapHostMem(const VPIImageData *hostData, uint32_t flags, VPIImage *img)
Create an image object by wrapping around an existing host-memory block.
VPI_DEVICE_TYPE_PVA
PVA backend.
Definition: Types.h:435
VPIStereoDisparityEstimatorParams::maxDisparity
uint32_t maxDisparity
Maximum disparity for matching search.
Definition: StereoDisparityEstimator.h:83
VPIStereoDisparityEstimatorParams
Structure that defines the parameters for vpiCreateStereoDisparityEstimator.
Definition: StereoDisparityEstimator.h:80
VPIPayload
struct VPIPayloadImpl * VPIPayload
A handle to an algorithm payload.
Definition: Types.h:164
VPIArray
struct VPIArrayImpl * VPIArray
Definition: Types.h:129
vpiPayloadDestroy
void vpiPayloadDestroy(VPIPayload payload)
Deallocates the payload object and all associated resources.
VPI_LOCK_READ_WRITE
Lock memory for reading and writing.
Definition: Types.h:400
Stream.h
vpiArrayInvalidate
VPIStatus vpiArrayInvalidate(VPIArray array)
This method is useful for unmanaged arrays only (created with 'vpiArrayWrap*`).
VPI_KLT_INVERSE_COMPOSITIONAL
Inverse compositional algorithm for KLT tracker.
Definition: KLTBoundingBoxTracker.h:91
VPIKLTBoundingBoxTrackerParams::numberOfIterationsScaling
uint32_t numberOfIterationsScaling
Number of Inverse compositional iterations of scale estimations.
Definition: KLTBoundingBoxTracker.h:106
VPIImagePlane::data
void * data
Pointer to the first row of this plane.
Definition: Image.h:135
vpiPyramidDestroy
void vpiPyramidDestroy(VPIPyramid pyr)
Destroy an image pyramid instance as well as all resources it owns.
VPI_ARRAY_TYPE_U32
unsigned 32-bit.
Definition: Types.h:215
VPIStream
struct VPIStreamImpl * VPIStream
Definition: Types.h:147
vpiEventDestroy
void vpiEventDestroy(VPIEvent event)
Destroy an event instance as well as all resources it owns.
VPIPyramid
struct VPIPyramidImpl * VPIPyramid
Definition: Types.h:159
VPI_DEVICE_TYPE_CUDA
CUDA backend.
Definition: Types.h:434
Context.h
vpiSubmitGaussianImageFilter
VPIStatus vpiSubmitGaussianImageFilter(VPIStream stream, VPIImage input, VPIImage output, uint32_t kernelSizeX, uint32_t kernelSizeY, float sigmaX, float sigmaY, VPIBoundaryCond boundary)
Runs a 2D Gaussian filter over an image.
VPI_DEVICE_TYPE_CPU
CPU backend.
Definition: Types.h:433