图像处理---读取图像后“是否读入成功”的几种提示

《图像处理---读取图像后“是否读入成功”的几种提示》

  图像读取之后,判断是否读取成功,对程序调试会有一定的帮助。  

  使用的环境VS2010 + OPenCV2.4.3

//方式一:
//加载图像
Mat src = imread("D:\\003_test_img\\stripe003.png");
if (src.empty())
{
    printf("could not load image ...\n");
    return -1;        //return 0 成功完成本函数;return -1 未能完成本函数
}
//方式二:
//加载图像
Mat src;
src = imread("D:\\003_test_img\\test001.png");
if (!src.data)
{
  printf("could not load image ...\n");
  return -1;   //return 0 成功完成本函数;return -1 未能完成本函数
}

猜你喜欢

转载自www.cnblogs.com/carle-09/p/11027563.html
今日推荐