请问如果想在一个工程实现HLS中的两种视频处理的算法应该进行怎样设计阿,我直接用变量传过来用if else控制,c仿真是对着呢,下板子就是乱码那种的。 下面是我的设计代码 #include"hls_video.h"
//图像最大尺寸
#define MAX_WIDTH 1280
#define MAX_HEIGHT 800
//定义图像处理核,要用到的结构体
typedef hls::stream<ap_axiu<24,1,1,1> > AXI_STREAM_IN;
typedef hls::stream<ap_axiu<24,1,1,1> > AXI_STREAM_OUT;
typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC3> RGB_IMAGE;
typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC1> GRAY_IMAGE; void rgb2gray_2mux1_ip(AXI_STREAM_IN& INPUT_STREAM,
AXI_STREAM_OUT& OUTPUT_STREAM,
int rows, int cols,
int mode){
#pragma HLS INTERFACE axis port=INPUT_STREAM
#pragma HLS INTERFACE axis port=OUTPUT_STREAM
#pragma HLS INTERFACE s_axilite port=rows
#pragma HLS INTERFACE s_axilite port=cols
#pragma HLS INTERFACE s_axilite port=mode
#pragma HLS interface s_axilite port=return RGB_IMAGE img_in(rows,cols);
RGB_IMAGE img_in1(rows,cols);
RGB_IMAGE img_in2(rows,cols);
RGB_IMAGE img_out0(rows,cols);
RGB_IMAGE img_out1(rows,cols);
GRAY_IMAGE img_gray(rows,cols);
#pragma HLS DATAFLOW // must use data flow to stream the data
//#pragma HLS stream depth=20000 variable=img_in2.data_stream
hls::AXIvideo2Mat(INPUT_STREAM, img_in); //读输入到img_0
//把input复制了两份
hls:: Duplicate(img_in,img_in1,img_in2);
//将RGB888格式的彩色数据转换成灰度数据
hls:: CvtColor<HLS_RGB2GRAY,HLS_8UC3,HLS_8UC1>(img_in1,img_gray);
//将灰度数据转换成三个通道的灰度图像
hls::CvtColor<HLS_GRAY2RGB,HLS_8UC1,HLS_8UC3>(img_gray,img_out0);
if(mode == 0)
hls::Mat2AXIvideo(img_out0, OUTPUT_STREAM);
else
hls::Mat2AXIvideo(img_out1, OUTPUT_STREAM);
}
C仿真测试功能正常,下板子图像是乱码无法实现灰度和原图像的切换
|