HLS第九课(图像算法testbench基本框架,xfopencv)

0)入口参数检查,保护

int main(int argc, char *argv[])
{	
	if (argc != 2)
	{
		printf("usage: %s bayer.png\n", argv[0]);
		return -1;
	}	

++++++++++++++++++++++++++++++++++++++++++++++++

1)定义输入CVMat,读入图像文件,存储为CVMat

	cv::Mat in_img;
	in_img = cv::imread(argv[1], 0);
	if (in_img.data == NULL)
	{
		fprintf(stderr,"Cannot open image at %s\n", argv[1]);
		return 0;
	}

函数调用完成后,进行返回结果检查保护。
++++++++++++++++++++++++++++++++++++++++

2)根据CVMat的属性参数,定义局部变量。

	int width = in_img.size().width;
	int height = in_img.size().height;
	unsigned char bayer_mode = 0;
	int crop_width = 2048;
	int crop_height = 1200;
    int crop_x = width - crop_width;
	int crop_y = height - crop_height;
	
	if ((width != BAYER_WIDTH) || (height != BAYER_HEIGHT))
	{
		printf("image size is wrong, real:%dx%d, needed:%dx%d \n", width, height, BAYER_WIDTH, BAYER_HEIGHT);
		return 0;
	}

函数调用完成后,进行返回结果检查保护。
+++++++++++++++++++++++++++++++++++++++++++++++
3)定义输出CVMat,定义中间stream。

	cv::Mat out_img;
	out_img.create(VIDEO_HEIGHT, VIDEO_WIDTH, CV_8U);
	
	 
	hls::stream<T_AXIU(BAYER_BPP, BAYER_NPPC)> src;
	hls::stream<T_AXIU(VIDEO_BPP, VIDEO_NPPC)> dst;

+++++++++++++++++++++++++++++++++++++++++++++
4)调用函数,将mat转换成stream。存放在DUT的输入流中。

cvMat2AXIvideoxf<BAYER_NPPC>(in_img, src);

+++++++++++++++++++++++++++++++++++++++++++++++++
5)调用DUT,结果存放在输出流中。

axim_read(src, dst, crop_x, crop_y, crop_width, crop_height); 

+++++++++++++++++++++++++++++++++++++++++++++++
6)调用函数,将stream转换成mat,存放在输出mat中。

AXIvideo2cvMatxf<BAYER_NPPC>(dst, out_img);

+++++++++++++++++++++++++++++++++++++++++++++++
7)将mat存储为图像文件。

cv::imwrite("hls.bmp", out_img);
cv::imwrite("image.bmp", in_img);

++++++++++++++++++++++++++++++++++++++++++++++

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值