Xilinx/Vitis_Libraries

Syntax problem after the migration from HLS_video to vitis_vision.

jimmy-adams opened this issue · 3 comments

Hello all,

I am using the vitis 2022.2, where the support for HLS_video.h is deprecated and one of the import class HLS::MAT is converted to CV::XF::MAT. But when i try to realize the function below to convert the HLS::stream<ap_uint> to xf::cv::MAT, the simulator gave error saying the << operator is not supported anymore.

#==========================================================================#

template <unsigned IMAGE_HEIGHT, unsigned IMAGE_WIDTH>

void stream_to_mat (stream<ap_uint<24> >&in,

     xf::cv::Mat<XF_8UC3, IMAGE_HEIGHT, IMAGE_WIDTH, XF_NPPC1> & raw_img) {

for (int i=0; i<IMAGE_HEIGHT; i++) {

    for (int j=0; j<IMAGE_WIDTH; j++) {

#pragma HLS pipeline II = 1

        Scalar<3, ap_uint<8> > pix;

        ap_uint<24> in_data = in.read();

        for (unsigned int p=0; p < 3; p ++) {

            pix.val[p] = in_data(8*p+7, 8*p);

        }

        // cout<<"======>"<<endl;

        // cout<<pix<<endl;

        raw_img << pix;

    }   

}

}

#==========================================================================#

I want to know if there are some other methods or similar functions in new vitis vision or HLS can realize the same function.

Also i have tried with the direct copying of the scalar pix to cv::xf::mat, and it will gice the @e simulation error failed: SIGSEGV

I am not sure if it related to the primary memory setting.

Another related question i want to confirm is whether the axiu can be used inside the design module and not as the output or input port to communication with PS.

Thanks in advance!

Hello @jimmy-adams ,

You can try this:

#include "<Vision-lib>/L1/include/common/xf_common.h"

template <unsigned IMAGE_HEIGHT, unsigned IMAGE_WIDTH>

void stream_to_mat (stream<ap_uint<24> >&in,   xf::cv::Mat<XF_8UC3, IMAGE_HEIGHT, IMAGE_WIDTH, XF_NPPC1> & raw_img) {
     
     xf::cv::AxiStream2Mat(in, raw_img.data, IMAGE_HEIGHT, IMAGE_WIDTH, -1);
}

static void AxiStream2Mat(hls::stream<ap_uint<PTR_WIDTH> >& din,

Dear @vt-lib-support
Thank you for your suggestion. I am trying with this method, but when it gets compiled, the error appears saying error: ‘AxiStream2Mat’ is not a member of ‘xf::cv’
xf::cv::AxiStream2Mat(in, raw_img.data, IMAGE_HEIGHT, IMAGE_WIDTH, -1);
Best Regards

@jimmy-adams

Please try this:

#include "<Vision-lib>/L1/include/common/xf_common.h"

#define PTR_WIDTH 32

template <unsigned IMAGE_HEIGHT, unsigned IMAGE_WIDTH>

void stream_to_mat (stream<ap_uint<24> >&in,   xf::cv::Mat<XF_8UC3, IMAGE_HEIGHT, IMAGE_WIDTH, XF_NPPC1> & raw_img) {

                MMIterIn<PTR_WIDTH, XF_8UC3, IMAGE_HEIGHT, IMAGE_WIDTH, XF_NPPC1>::AxiStream2Mat(in, raw_img.data, IMAGE_HEIGHT, IMAGE_WIDTH, -1);
}