Warp Transform - 2024.1 English

Vitis Libraries

Release Date
2024-05-30
Version
2024.1 English

The warpTransform function is designed to perform the perspective and affine geometric transformations on an image. The type of transform is a compile time parameter to the function.

The function uses a streaming interface to perform the transformation. Due to this and due to the fact that geometric transformations need access to many different rows of input data to compute one output row, the function stores some rows of the input data in block RAMs/UltraRAMs. The number of rows the function stores can be configured by the user by modifying a template parameter. Based on the transformation matrix, you can decide on the number of rows to be stored. You can also choose when to start transforming the input image in terms of the number of rows of stored image.

Affine Transformation

The transformation matrix consists of size parameters, and is as shown:

image156

Affine transformation is applied in the warpTransform function following the equation:

image157

Perspective Transformation

The transformation matrix is a 3x3 matrix as shown below:

image158

Perspective transformation is applied in warpTransform following the equation:

image159

The destination pixel is then computed by dividing the first two dimensions of the dst1 by the third dimension

image160

API Syntax

template<int STORE_LINES, int START_ROW, int TRANSFORMATION_TYPE, int INTERPOLATION_TYPE, int SRC_T, int ROWS, int COLS, int NPC=1, bool USE_URAM=false, int XFCVDEPTH_IN = _XFCVDEPTH_DEFAULT, int XFCVDEPTH_OUT = _XFCVDEPTH_DEFAULT>
void warpTransform(xf::cv::Mat<SRC_T, ROWS, COLS, NPC, XFCVDEPTH_IN> & src, xf::cv::Mat<SRC_T, ROWS, COLS, NPC, XFCVDEPTH_OUT> & dst, float *transformation_matrix)

Parameter Descriptions

The following table describes the template and the function parameters.

Table 768 Table . warpTransform Parameter Description
Parameter Description
STORE_LINES Number of lines to store an input to process a given transformation.
START_ROW Number of the input rows to store before starting the image transformation. This must be less than or equal to STORE_LINES.
TRANSFORMATI ON_TYPE Affine and perspective transformations are supported. Set this flag to ‘0’ for affine and ‘1’ for perspective transformation.
INTERPOLATIO N_TYPE Set flag to ‘1’ for bilinear interpolation and ‘0’ for nearest neighbor interpolation.
SRC_T Input and Output pixel type. Only 8-bit, unsigned, 1 and 3 channels are supported (XF_8UC1 and XF_8UC3)
ROWS Maximum height of input and output image.
COLS Maximum width of input and output image.
NPC Number of pixels to be processed per cycle; only one-pixel operation supported (XF_NPPC1).
USE_URAM Enable to map some storage structures to UltraRAM
XFCVDEPTH_IN Depth of the input image.
XFCVDEPTH_OUT Depth of the output image.
src Input image
dst Output image
transformati on_matrix Transformation matrix that is applied to the input image.

Resource Utilization

The following table summarizes the resource utilization of the Warp transform, generated using Vivado HLS 2019.1 version tool for the Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA, to process a grayscale HD (1080x1920) image.

Table 769 Table . warpTransform Function Resource Utilization Summary
Transformation INTERPOLATION _TYPE STORE _LINES START _ROW

Operating Frequency

(MHz)

Utilization Estimate
LUTs FFs DSPs BRAMs
Perspective Bilinear 100 50 300 7468 9804 61 112
Perspective Nearest Neighbor 100 50 300 4514 6761 35 104
Affine Bilinear 100 50 300 6139 5606 40 124
Affine Nearest Neighbor 100 50 300 4611 4589 18 112

The following table summarizes the resource utilization of the Warp transform, generated using Vivado HLS 2019.1 version tool for the Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA, to process a BGR 4K image.

Table 770 Table . warpTransform Function Resource Utilization Summary
Transformation INTERPOLATION _TYPE STORE _LINES START _ROW

Operating Frequency

(MHz)

Utilization Estimate
LUTs FFs DSPs BRAMs
Perspective Bilinear 100 50 300 9192 7910 48 616
Perspective Nearest Neighbor 100 50 300 10533 12055 69 604
Affine Bilinear 100 50 300 6397 8415 35 604

The following table summarizes the resource utilization of the Warp transform, generated using Vivado HLS 2019.1 version tool for the Xilinx xczu7ev-ffvc1156-2-e FPGA, to progress a grayscale 4K image with UltraRAM enabled.

Table 771 Table . warpTransform Function Resource Utilization Summary with UltraRAM Enable
Transformation INTERPOLATION _TYPE STORE _LINES START _ROW

Operating Frequency

(MHz)

Utilization Estimate
LUTs FFs DSPs BRAMs URAM
Perspective Bilinear 100 50 300 7820 12458 61 7 12
Perspective Nearest Neighbor 100 50 300 4880 8323 35 2 6
Affine Bilinear 100 50 300 6850 9516 40 13 12
Affine Nearest Neighbor 100 50 300 4651 6548 18 6 6

Performance Estimate

The following table summarizes a performance estimate of the Warp transform, as generated using Vivado HLS 2019.1 tool for Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA, to process a grayscale HD (1080x1920) image.

Table 772 Table . warpTransform Function Performance Estimate Summary
Transforma tion INTERPOLATI ON _TYPE STORE _LIN ES START _ROW

Operatin g Frequenc y

(MHz)

Latency Estimate

Max (ms)

Perspectiv e Bilinear 100 50 300 7.46
Perspectiv e Nearest Neighbor 100 50 300 7.31
Affine Bilinear 100 50 300 7.31
Affine Nearest Neighbor 100 50 300 7.24