Crop - 2023.2 English

Vitis Libraries

Release Date
2023-12-20
Version
2023.2 English

The Crop function extracts the region of interest (ROI) from the input image.

P(X,Y) ≤ P(xi, yi) ≤ P(X’,Y’)

  • P(X,Y) - Top left corner of ROI
  • P(X’,Y’) - Bottom Right of ROI

API Syntax

template<int SRC_T, int ROWS, int COLS,int ARCH_TYPE=0,int NPC=1, int XF_CV_DEPTH_IN, int XF_CV_DEPTH_OUT>
void crop(xf::cv::Mat<SRC_T, ROWS, COLS, NPC, XF_CV_DEPTH_IN> & _src_mat,xf::cv::Mat<SRC_T, ROWS, COLS, NPC, XF_CV_DEPTH_OUT>  &_dst_mat,xf::cv::Rect_<unsigned int> &roi)

Parameter Descriptions

The following table describes the template and the function parameters.

Table 473 Table Crop Parameter Description
Parameter Description
SRC_T Input pixel type. Only 8-bit, unsigned, 1 and 4 channels are supported (XF_8UC1 and XF_8UC4).
ROWS Maximum height of input and output image.
COLS Maximum width of input and output image. Must be multiple of 8 for 8-pixel operation.
ARCH_TYPE Architecture type. 0 resolves to stream implementation and 1 resolves to memory mapped implementation.
NPC Number of pixels to be processed per cycle. NPC should be power of 2.
XFCVDEPTH_IN Depth of input image
XFCVDEPTH_OUT Depth of output image
_src_mat Input image
_dst_mat Output ROI image
roi ROI is a xf::cv::Rect object that consists of the top left corner of the rectangle along with the height and width of the rectangle.

Resource Utilization

The following table summarizes the resource utilization of crop function in normal mode (NPC=1) for 3 ROIs (480x640, 100x200, 300x300) as generated in the Vivado HLS 2019.1 tool for the Xilinx xczu9eg-ffvb1156-2-i-es2 FPGA.

Table 474 Table Crop Function Resource Utilization Summary
Name Resource Utilization
1 pixel per clock operation 8 pixel per clock operation
300 MHz 150 MHz
BRAM_18K 6 8
DSP48E 10 10
FF 17482 16995
LUT 16831 15305

Performance Estimate

The following table summarizes a performance estimate of the kernel in different configurations, generated using Vivado HLS 2019.1 tool for Xczu9eg-ffvb1156-1-i-es1 FPGA to process a grayscale HD (1080x1920) image for 3 ROIs (480x640, 100x200, 300x300).

Table 475 Table Crop Function Performance Estimate Summary
Operating Mode Latency Estimate
Max Latency (ms)
1 pixel operation (300 MHz) 1.7
8 pixel operation (150 MHz) 0.6