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!

cancel
Showing results for 
Search instead for 
Did you mean: 
Participant eewse
Participant
139 Views
Registered: ‎02-24-2019

xf::equalizeHist does not work with pragma dataflow

The following prgram can run on vivado for

TEST001 - TEST004

but for

TEST005

there will produce no output. But why?

#include "axi_sgbm_config.h"
#include "xf_config_params.h"
#include "imgproc/xf_hist_equalize.hpp"
#include "imgproc/xf_duplicateimage.hpp"
#include "imgproc/xf_add_weighted.hpp"
#include "imgproc/xf_convert_bitdepth.hpp"
#include "core/xf_arithm.hpp"

#define TEST005

template <typename T, int rows, int cols>
void drain_xf_mat(T& img) {
    xf::Scalar<1, ap_uint<24>> p;
    for(int i=0; i < rows*cols; i++)
        #pragma HLS pipeline rewind
        //#pragma HLS loop_flatten
        p = img.data[i];
}

void equalizer(XGRAY_DST_IMAGE& src_disp, XGRAY_DST_IMAGE& src_disp4) {

#pragma HLS dataflow
#pragma HLS inline
    XGRAY_DST_IMAGE src_disp2(dst_rows, dst_cols);
    XGRAY_DST_IMAGE src_disp3(dst_rows, dst_cols);
    #pragma HLS stream variable=src_disp2 dim=1 depth=128
    #pragma HLS stream variable=src_disp3 dim=1 depth=128

    xf::duplicateMat<XF_8UC1, src_rows, src_cols, XF_NPPC1>(src_disp, src_disp2, src_disp3);
    xf::equalizeHist<XF_8UC1, src_rows, src_cols, XF_NPPC1>(src_disp2, src_disp3, src_disp4);

}


void sgbm_filter_simple(AXI_STREAM& src_data_l, AXI_STREAM& src_data_r, AXI_STREAM& src_data_d)
{
#pragma HLS INTERFACE axis port=src_data_l
#pragma HLS INTERFACE axis port=src_data_r
#pragma HLS INTERFACE axis port=src_data_d

#pragma HLS stream variable=src_data_l dim=1 depth=64
#pragma HLS stream variable=src_data_r dim=1 depth=64
#pragma HLS stream variable=src_data_d dim=1 depth=64

XGRAY_SRC_IMAGE src_l(src_rows, src_cols);
XGRAY_SRC_IMAGE src_r(src_rows, src_cols);
#pragma HLS stream variable=src_l dim=1 depth=128

#ifdef TEST001
    #pragma HLS dataflow
    xf::AXIvideo2xfMat(src_data_l, src_l);
    xf::AXIvideo2xfMat(src_data_r, src_r);
    drain_xf_mat<XGRAY_SRC_IMAGE, src_rows, src_cols>(src_r);
    xf::xfMat2AXIvideo(src_l, src_data_d);
#elif defined(TEST002)
    #pragma HLS stream variable=src_r dim=1 depth=128
    XGRAY_DST_IMAGE src_disp(src_rows, src_cols);
    #pragma HLS stream variable=src_disp dim=1 depth=128
    #pragma HLS dataflow
    xf::AXIvideo2xfMat(src_data_l, src_l);
    xf::AXIvideo2xfMat(src_data_r, src_r);
    xf::bitwise_and<XF_8UC1, src_rows, src_cols, XF_NPPC1> (src_l, src_r, src_disp);
    xf::xfMat2AXIvideo(src_disp, src_data_d);
#elif defined(TEST003)
    #pragma HLS stream variable=src_r dim=1 depth=128
    XGRAY16_DST_IMAGE src_disp16(src_rows, src_cols);
    XGRAY_DST_IMAGE src_disp(src_rows, src_cols);
    #pragma HLS stream variable=src_disp16 dim=1 depth=128
    #pragma HLS stream variable=src_disp dim=1 depth=128
    #pragma HLS dataflow
    xf::AXIvideo2xfMat(src_data_l, src_l);
    xf::AXIvideo2xfMat(src_data_r, src_r);
    xf::addWeighted<XF_8UC1, XF_16UC1, src_rows, src_cols, XF_NPPC1> (src_l, 0.5, src_r, 0.5, 0., src_disp16);
    xf::convertTo<XF_16UC1, XF_8UC1, src_rows, src_cols, XF_NPPC1> (src_disp16, src_disp, XF_CONVERT_16U_TO_8U, 0);
    xf::xfMat2AXIvideo(src_disp, src_data_d);
#elif defined(TEST004)
    #pragma HLS stream variable=src_r dim=1 depth=128
    #pragma HLS dataflow
    XGRAY16_DST_IMAGE src_disp16(dst_rows, dst_cols);
    XGRAY_DST_IMAGE src_disp(dst_rows, dst_cols);
    XGRAY_DST_IMAGE src_disp4(dst_rows, dst_cols);
    #pragma HLS stream variable=src_disp16 dim=1 depth=128
    #pragma HLS stream variable=src_disp dim=1 depth=128
    #pragma HLS stream variable=src_disp4 dim=1 depth=1024
    XGRAY_DST_IMAGE src_disp2(dst_rows, dst_cols);
    XGRAY_DST_IMAGE src_disp3(dst_rows, dst_cols);
    #pragma HLS stream variable=src_disp2 dim=1 depth=1024
    #pragma HLS stream variable=src_disp3 dim=1 depth=1024

    xf::AXIvideo2xfMat(src_data_l, src_l);
    xf::AXIvideo2xfMat(src_data_r, src_r);
    xf::addWeighted<XF_8UC1, XF_16UC1, src_rows, src_cols, XF_NPPC1> (src_l, 0.5, src_r, 0.5, 0., src_disp16);
    xf::convertTo<XF_16UC1, XF_8UC1, src_rows, src_cols, XF_NPPC1> (src_disp16, src_disp, XF_CONVERT_16U_TO_8U, 0);
    xf::duplicateMat<XF_8UC1, src_rows, src_cols, XF_NPPC1>(src_disp, src_disp2, src_disp3);
    xf::equalizeHist<XF_8UC1, src_rows, src_cols, XF_NPPC1>(src_disp2, src_disp3, src_disp4);
    //xf::bitwise_and<XF_8UC1, src_rows, src_cols, XF_NPPC1> (src_disp2, src_disp3, src_disp4);
    xf::xfMat2AXIvideo(src_disp4, src_data_d);
#elif defined(TEST005)
      #pragma HLS stream variable=src_r dim=1 depth=128
    #pragma HLS dataflow
    XGRAY16_DST_IMAGE src_disp16(dst_rows, dst_cols);
    XGRAY_DST_IMAGE src_disp(dst_rows, dst_cols);
    XGRAY_DST_IMAGE src_disp4(dst_rows, dst_cols);
    #pragma HLS stream variable=src_disp16 dim=1 depth=128
    #pragma HLS stream variable=src_disp dim=1 depth=128
    #pragma HLS stream variable=src_disp4 dim=1 depth=1024
    XGRAY_DST_IMAGE src_disp2(dst_rows, dst_cols);
    XGRAY_DST_IMAGE src_disp3(dst_rows, dst_cols);
    #pragma HLS stream variable=src_disp2 dim=1 depth=1024
    #pragma HLS stream variable=src_disp3 dim=1 depth=1024

    xf::AXIvideo2xfMat(src_data_l, src_l);
    xf::AXIvideo2xfMat(src_data_r, src_r);
    xf::addWeighted<XF_8UC1, XF_16UC1, src_rows, src_cols, XF_NPPC1> (src_l, 0.5, src_r, 0.5, 0., src_disp16);
    xf::convertTo<XF_16UC1, XF_8UC1, src_rows, src_cols, XF_NPPC1> (src_disp16, src_disp, XF_CONVERT_16U_TO_8U, 0);
    xf::duplicateMat<XF_8UC1, src_rows, src_cols, XF_NPPC1>(src_disp, src_disp2, src_disp3);
    xf::equalizeHist<XF_8UC1, src_rows, src_cols, XF_NPPC1>(src_disp2, src_disp3, src_disp4);
    xf::xfMat2AXIvideo(src_disp4, src_data_d); 
#endif
}
0 Kudos
1 Reply
Highlighted
Participant eewse
Participant
108 Views
Registered: ‎02-24-2019

Re: xf::equalizeHist does not work with pragma dataflow

No need to be too demanding. It won't work even it is only few lines

 

#include "top.h"
#include "imgproc/xf_hist_equalize.hpp"
#include "imgproc/xf_duplicateimage.hpp"

void equalizeHist(AXI_STREAM& src_axi, AXI_STREAM& dst_axi)
{

#pragma HLS INTERFACE axis port=src_axi
#pragma HLS INTERFACE axis port=dst_axi

#pragma HLS dataflow
XGRAY_SRC_IMAGE  src(src_rows, src_cols);
XGRAY_DST_IMAGE  dst(dst_rows, dst_cols);
XGRAY_DST_IMAGE  dst1(dst_rows, dst_cols);
XGRAY_DST_IMAGE  dst2(dst_rows, dst_cols);
#pragma HLS STREAM variable=src depth=64
#pragma HLS STREAM variable=dst depth=64
#pragma HLS STREAM variable=dst1 depth=64
#pragma HLS STREAM variable=dst2 depth=64

    xf::AXIvideo2xfMat(src_axi, src);
    xf::duplicateMat<XF_8UC1, src_rows, src_cols, XF_NPPC1>(src, dst1, dst2);
    xf::equalizeHist<XF_8UC1, dst_rows, dst_cols, XF_NPPC1>(dst1, dst2, dst);
    xf::xfMat2AXIvideo(dst, dst_axi);
}
0 Kudos