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);
++++++++++++++++++++++++++++++++++++++++++++++