WarpTransform
xFWarpTransform
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 BRAMs. 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:
Affine transformation is applied in the xFWarpTransform function following the equation:
Perspective Transformation
The transformation matrix is a 3x3 matrix as shown below:
Perspective transformation is applied in xFWarpTransform following the equation:
The destination pixel is then computed by dividing the first two dimensions of the dst1 by the third dimension
API Syntax
template void xFWarpTransform(xF::Mat & src, xF::Mat & dst, float *transformation_matrix)
Parameter Descriptions
The following table describes the template and the function parameters.
Parameter | Description |
---|---|
STORE_LINES | Number of lines of the image that need to be buffered locally on FPGA. |
START_ROW | Number of the input rows to store before starting the image transformation. This must be less than or equal to STORE_LINES. |
TRANFORMATION_TYPE | Affine and perspective transformations are supported. Set this flag to ‘0’ for affine and ‘1’ for perspective transformation. |
INTERPOLATION_TYPE | Set flag to ‘1’ for bilinear interpolation and ‘0’ for nearest neighbor interpolation. |
SRC_T | Input pixel type. Only 8-bit, unsigned, 1 channel is supported (XF_8UC1) |
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). |
src | Input image |
dst | Output image |
transformation_matrix | Transformation matrix that is applied to the input image. |
Resource Utilization
The following table summarizes the resource utilization of the Warp transform, generated usingVivado HLS 2017.1version tool for the Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA, to progress a grayscale HD (1080x1920) image.
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 |
Performance Estimate
The following table summarizes a performance estimate of the Warp transform, as generated usingVivado HLS 2017.1tool for Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA, to process a grayscale HD (1080x1920) image.
Transformation | INTERPOLATION _TYPE | STORE _LINES | START _ROW | Operating Frequency (MHz) |
Latency Estimate Max (ms) |
---|---|---|---|---|---|
Perspective | Bilinear | 100 | 50 | 300 | 7.46 |
Perspective | Nearest Neighbor | 100 | 50 | 300 | 7.31 |
Affine | Bilinear | 100 | 50 | 300 | 7.31 |
Affine | Nearest Neighbor | 100 | 50 | 300 | 7.24 |