The input images are typically pre-processed before being fed for inference of different deep neural networks (DNNs). The Preprocess function applies mean (α) and bias (β) values provided by the user to the input image.
output = (input - α) * β
API Syntax
template <int IN_TYPE, int OUT_TYPE, int HEIGHT, int WIDTH, int NPC, int WIDTH_A, int IBITS_A, int WIDTH_B,
int IBITS_B, int WIDTH_OUT, int IBITS_OUT, int XFCVDEPTH_IN = _XFCVDEPTH_DEFAULT, int XFCVDEPTH_OUT = _XFCVDEPTH_DEFAULT>
void preProcess(xf::cv::Mat<IN_TYPE, HEIGHT, WIDTH, NPC, XFCVDEPTH_IN>& in_mat,
xf::cv::Mat<OUT_TYPE, HEIGHT, WIDTH, NPC, XFCVDEPTH_OUT>& out_mat,
float params[2 * XF_CHANNELS(IN_TYPE, NPC)])
The following table describes the template and the function parameters.
Parameter | Description |
---|---|
IN_TYPE | Type of the input image. Supported values are XF_8UC3, XF_10UC3, XF_12UC3, XF_16UC3 |
OUT_TYPE | Type of the output image. Supported values are XF_8UC3, XF_10UC3, XF_12UC3, XF_16UC3 |
HEIGHT | Maximum rows of the input image |
WIDTH | Maximum columns of the input image |
NPC | Number of pixels processed per clock |
WIDTH_A | alpha bit width |
IBITS_A | Number of integer bits for alpha |
WIDTH_B | beta bit width |
IBITS_B | Number of integer bits for beta |
WIDTH_OUT | Output bit width |
IBITS_OUT | Number of integer bits for output |
XFCVDEPTH_IN | Depth of the hls::stream of input image |
XFCVDEPTH_OUT | Depth of the hls::stream of output image |
in_mat | Input image |
out_mat | Output image |
params | Array containing α, β values per channel |
Resource Utilization
The following table summarizes the resource utilization of preProcess for NPC =8, for a maximum input image size of 1280x720 pixels. The results are after synthesis in Vitis 2019.2 for the Xilinx xcu200-fsgd2104-2-e FPGA at 300 MHz. Latency for this configuration is 0.7 ms.
Operating Mode Operating Frequency
(MHz)
Utilization Estimate BRAM_18K DSP_48Es FF LUT SLICE 8 pixel 300 0 2 7554 11127 2155