The code of the IP is the same that shown in the tutorial, is a 2D concolution filter:
#include <hls_video.h>
#include <stdint.h>
// Get 1080x1920 HD grey image as input (from “image_in” array)
// and do 2D convolution on it with a hard coded 3x3 kernel.
// Processed image is stored in “image_out” array.
void conv(uint8_t image_in[360640],uint8_t image_out[360640]){
#pragma HLS INTERFACE s_axilite port=return bundle=CRTL_BUS
#pragma HLS INTERFACE m_axi depth=691200 port=image_in offset=slave bundle=CRTL_BUS
#pragma HLS INTERFACE m_axi depth=691200 port=image_out offset=slave bundle=CRTL_BUS
#pragma HLS DATAFLOW
const char coefficients[3][3] = { {-1,-2,-1},
{ 0, 0, 0},
{ 1, 2, 1} };
hls::Mat<360,640,HLS_8UC1> src; // Mat format variables to store images
hls::Mat<360,640,HLS_8UC1> dst;
// Convert from axi format to Mat the input image
hls::AXIM2Mat<640,uint8_t,360,640,HLS_8UC1>(image_in,src);
// Declare a variable kind window for the coefficients
hls::Window<3,3,char> kernel;
// Convert the coefficients to hls format
for (int i=0;i<3;i++){
for (int j=0;j<3;j++){
kernel.val[i][j]=coefficients[i][j];
}
}
// indicates the relative position of a filtered point within the kernel
hls::Point_ anchor = hls::Point_(-1,-1); // means the center of the kernel
hls::Filter2D(src,dst,kernel,anchor);
// Convert to Axi format
hls::Mat2AXIM<640,uint8_t,360,640,HLS_8UC1>(dst,image_out);
}
Thank you!