UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 57379

2013.2 Vivado HLS - hls::GaussianBlur() Compile Error

Description

The hls::GaussianBlur() function (one of the new OpenCV functions) compiles only with template parameters KH=5 & KW=5 in Vivado_HLS 2013.2.
hls::GaussianBlur<5,5>(img_1, img_2, (double)1.0, (double)1.0);
If these are changed to KH=3 & KW=3:
hls::GaussianBlur<3,3>(img_1, img_2, (double)1.0, (double)1.0);
The error below is received:
@E [HLS-70] Compilation errors found:
C:/Xilinx/Vivado_HLS/2013.2/include/hls/hls_video_harris.h: In function 'void hls::getGaussianKernel(hls::Window<KH, KW, K_T>&) [with int KH = 3, int KW = 3, K_T = ap_fixed<16, 2, AP_RND, AP_WRAP, 0>]':
C:/Xilinx/Vivado_HLS/2013.2/include/hls/hls_video_harris.h:139:   instantiated from 'void hls::GaussianBlur(hls::Mat<ROWS, COLS, SRC_T>&, hls::Mat<ROW, COL, SRC_T>&, double, double) [with int KH = 3, int KW = 3, int SRC_T = 16, int DST_T = 16, int ROWS = 1080, int COLS = 1920]'

Solution

Vivado_HLS 2013.2 only supports a Gaussian kernel size of 5x5 (KH=5 & KW=5).

This has been fixed in the 2013.3 release.

As a workaround in 2013.2, you can define a custom gaussianblur() function with filter2D() as below:

template<int KH,int KW,typename K_T>
void my_getGaussianKernel(
        hls::Window<KH,KW,K_T> &kernel
        )
{

#pragma HLS INLINE
const int k_val[3*3] = {1, 2, 1,
                                        2, 4, 2,
                                       1, 2, 1};
       for (int i = 0; i < 3; i++)
      {
#pragma HLS unroll
             for (int j = 0; j < 3; j++)
             {
#pragma HLS unroll
                kernel.val[i][j] = k_val[i*3+j]*0.0625;
             }
     }
}
template<int KH,int KW,int SRC_T,int DST_T,int ROWS,int COLS>
void my_GaussianBlur(
                hls::Mat<ROWS, COLS, SRC_T>         &_src,
                hls::Mat<ROWS, COLS, DST_T>         &_dst,
                double sigmaX=0,
                double sigmaY=0)
{
    hls::Point_<int> anchor;
    anchor.x = -1;
    anchor.y = -1;
    hls::Window<KW, KH, ap_fixed<16,2,AP_RND>  > kernel;
    my_getGaussianKernel(kernel);
    hls::Filter2D(_src, _dst, kernel, anchor);
AR# 57379
Date Created 09/05/2013
Last Updated 05/01/2014
Status Active
Type General Article
Tools
  • Vivado Design Suite