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!

取消
显示结果 
搜索替代 
您的意思是: 
Visitor wangcheng
Visitor
379 次查看
注册日期: ‎06-25-2018

HLS 函数hls::Dilate无图像数据输出

使用HLS 的opencv函数hls::Dilate<hls::MORPH_ELLIPSE,1>(temp0_pre,temp1_pre,k5);综合RTL仿真,图像数据输出全为FF,

没有正常的像素数据输出。

代码如下:

1.hls代码

void hls_Dilate_8bit(AXI_STREAM_IN& input, AXI_STREAM_OUT& output, int rows, int cols) {

#pragma HLS RESOURCE variable=input core=AXI4Stream metadata="-bus_bundle INPUT_STREAM"

#pragma HLS RESOURCE variable=output core=AXI4Stream metadata="-bus_bundle OUTPUT_STREAM"

#pragma HLS INTERFACE ap_none port=cols

#pragma HLS INTERFACE ap_none port=rows

RGB_IMAGE img_0(rows, cols);

RGB_IMAGE img_1(rows, cols);

RGB_IMAGE img_2(rows, cols);

hls::Window<9,9,unsigned char> k4;

#pragma HLS DATAFLOW // must use data flow to stream the data

hls::AXIvideo2Mat(input, img_0); //read video stream by frames

hls::Dilate<hls::MORPH_ELLIPSE,2>(img_0,img_1,k4);

hls::Erode<hls::MORPH_ELLIPSE,2>(img_1,img_2,k4);

hls::Mat2AXIvideo(img_2, output); //write the frames to video stream

}

顶层代码

#include "top.h"

#include "opencv/cv.h"

#include "opencv/cxcore.h"

#include "opencv/highgui.h"

#include "hls_opencv.h"

int main (int argc, char** argv) {

    IplImage* src=cvLoadImage(INPUT_IMAGE,0);

    IplImage* dst = cvCreateImage(cvGetSize(src), src->depth, src->nChannels);

    AXI_STREAM_IN src_axi;

    AXI_STREAM_OUT dst_axi;

    IplImage2AXIvideo(src, src_axi); //将图像转为视频流结构

    hls_Dilate_8bit(src_axi, dst_axi, src->height, src->width);

    AXIvideo2IplImage(dst_axi, dst);

    cvSaveImage(OUTPUT_IMAGE, dst);

    cvReleaseImage(&src);

    cvReleaseImage(&dst);

 

}

toph代码

#ifndef _TOP_H_

#define _TOP_H_

#include"hls_video.h" //这里调用可以综合的视频库

// maximum image size

#define MAX_WIDTH 1280

#define MAX_HEIGHT 1024

 

// I/O Image Settings

#define INPUT_IMAGE "6.jpg"

#define OUTPUT_IMAGE "result_out.jpg"

#define OUTPUT_IMAGE_GOLDEN "result_golden.jpg"

// typedef video library core structures

typedef hls::stream<ap_axiu<8,1,1,1> > AXI_STREAM_IN;

typedef hls::stream<ap_axiu<8,1,1,1> > AXI_STREAM_OUT;

typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC1> RGB_IMAGE;

typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC1> GRAY_IMAGE;

 

// top level function for HW synthesis

void hls_Dilate_8bit(AXI_STREAM_IN& src_axi, AXI_STREAM_OUT& dst_axi, int rows, int cols);

 

#endif

 

2.上述代码是闭运算,c仿真后图像有明显的的补偿像素的结果。1.png

3.综合仿真后RTL仿真结果(输入图片数据,但是输出全为ff)没有图像数据输出

2.png

4.下载到硬件显示也是白色的图片。

 

问题是在使用hls::Dilate<hls::MORPH_ELLIPSE,2>(img_0,img_1,k4);综合后RTL仿真没有图像数据输出

 

0 项奖励