cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mian_m_awais
Newbie
Newbie
4,227 Views
Registered: ‎12-16-2016

Problem with HLS, AXI streaming and hls::Duplicate function

I am trying to implement sobel filter with enable/disable feature. It means input stream is sent to output as it is when disabled.
Sobel filter code works fine alone but when i create 2 streams with duplicate function, nothing is displayed at output.

My code is:

//sobel1_en.cpp
#include <hls_video.h>
#include "ap_int.h"

void sobel1_en(hls::stream<ap_axiu<24,1,1,1> >& IN_STREAM, hls::stream<ap_axiu<24,1,1,1> >& OUT_STREAM, ap_uint<1> sobel_en)
{
    #pragma HLS INTERFACE axis port=INPUT_STREAM
    #pragma HLS INTERFACE axis port=OUTPUT_STREAM
    #pragma HLS INTERFACE ap_none port=sobel_en
    #pragma HLS INTERFACE ap_ctrl_none port=return

    hls::Mat<720, 1280, HLS_8UC3>    img_0(720, 1280);
    hls::Mat<720, 1280, HLS_8UC3>    img_1(720, 1280);
    hls::Mat<720, 1280, HLS_8UC3>    img_2(720, 1280);
    hls::Mat<720, 1280, HLS_8UC1>    img_3(720, 1280);
    hls::Mat<720, 1280, HLS_8UC1>    img_4(720, 1280);
    hls::Mat<720, 1280, HLS_8UC3>    img_5(720, 1280);
    
    #pragma HLS dataflow

    hls::AXIvideo2Mat(IN_STREAM, img_0);
    hls::Duplicate(img_0,img_1,img_2);
    hls::CvtColor<HLS_RGB2GRAY>(img_2, img_3);
    hls::Sobel<1,0,3>(img_3, img_4);
    hls::CvtColor<HLS_GRAY2RGB>(img_4, img_5);

    if(sobel_en)
    {
        hls::Mat2AXIvideo(img_5, OUT_STREAM);
    }
    else
    {
        hls::Mat2AXIvideo(img_1, OUT_STREAM);
    }
}

 

The code that works fine is:

//sobel1.cpp
#include <hls_video.h>
#include "ap_int.h"

void sobel1(hls::stream<ap_axiu<24,1,1,1> >& IN_STREAM, hls::stream<ap_axiu<24,1,1,1> >& OUT_STREAM)
{
    #pragma HLS INTERFACE axis port=INPUT_STREAM
    #pragma HLS INTERFACE axis port=OUTPUT_STREAM
    #pragma HLS INTERFACE ap_ctrl_none port=return

    hls::Mat<720, 1280, HLS_8UC3>    img_0(720, 1280);
    hls::Mat<720, 1280, HLS_8UC1>    img_1(720, 1280);
    hls::Mat<720, 1280, HLS_8UC1>    img_2(720, 1280);
    hls::Mat<720, 1280, HLS_8UC3>    img_3(720, 1280);
    
    #pragma HLS dataflow

    hls::AXIvideo2Mat(IN_STREAM, img_0);
    hls::CvtColor<HLS_RGB2GRAY>(img_0, img_1);
    hls::Sobel<1,0,3>(img_1, img_2);
    hls::CvtColor<HLS_GRAY2RGB>(img_2, img_3);
    hls::Mat2AXIvideo(img_3, OUT_STREAM);
}

 

How can I solve this problem? Thanks a lot !

1 Reply
u4223374
Advisor
Advisor
4,183 Views
Registered: ‎04-26-2015

The problem is that either img5 or img1 is not used, depending on the settings. HLS cannot deal with that; all streams must be used (in fact, "duplicate" won't output either stream unless something is ready to read from both).

 

What you need is a "termination" function that just reads a stream and does nothing with it; then you can attach that to the unused stream to absorb the data.

0 Kudos