Overview
The image flip algorithm writes to the output image a mirrored version of the input. It supports mirroring along horizontal, vertical and both axis simultaneously. The latter is a useful and fast way to rotate the image 180 degrees.
Input VPI_FLIP_HORIZ
VPI_FLIP_VERT VPI_FLIP_BOTH
Implementation
The image flip works by swapping the pixels across the x-axis, y-axis or across both axes depending on how the user wants it.
C API functions
For list of limitations, constraints and backends that implements the algorithm, consult reference documentation of the following functions:
Function Description
vpiSubmitImageFlip Flips a 2D image either horizontally, vertically or both.
Usage
Language:
C/C++
Python
Import VPI module
Run image flip on input image using the CUDA backend. It's using flip mode BOTH. Input and output are VPI images. with vpi.Backend.CUDA:
output = input.image_flip(vpi.Flip.BOTH)
Initialization phase
Include the header that defines the Image flip function.
Declares functions that implement Image flip algorithms.
Define the input image.
struct VPIImageImpl * VPIImage
A handle to an image.
Create the output image. It gets its dimensions and format from the input image. int32_t w, h;
VPIStatus vpiImageGetFormat(VPIImage img, VPIImageFormat *format)
Get the image format.
VPIStatus vpiImageCreate(int32_t width, int32_t height, VPIImageFormat fmt, uint64_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
VPIStatus vpiImageGetSize(VPIImage img, int32_t *width, int32_t *height)
Get the image dimensions in pixels.
Create the stream where the algorithm will be submitted for execution.
struct VPIStreamImpl * VPIStream
A handle to a stream.
VPIStatus vpiStreamCreate(uint64_t flags, VPIStream *stream)
Create a stream instance.
Processing phase
Submit the algorithm to the stream using the CPU backend, along with all parameters.
VPIStatus vpiSubmitImageFlip(VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, VPIFlipMode flipMode)
Flips a 2D image either horizontally, vertically or both.
@ VPI_BACKEND_CPU
CPU backend.
Optionally, wait until the processing is done.
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
Cleanup phase
Free resources held by the stream and the input and output images.
void vpiImageDestroy(VPIImage img)
Destroy an image instance.
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
For more information, see Image Flip in the "C API Reference" section of VPI - Vision Programming Interface .
Performance
For information on how to use the performance table below, see Algorithm Performance Tables .
Before comparing measurements, consult Comparing Algorithm Elapsed Times .
For further information on how performance was benchmarked, see Performance Benchmark .
clear filters
Device:
Jetson AGX Xavier
Jetson AGX Orin
-
Streams:
1
2
4
8