什么'!image.data'在C++中意味着什么?

1 c++ opencv

我是使用OpenCV和Visual Studio进行图像处理的初学者.我有一段代码,我不明白:

Mat image;
image = imread(filename, IMREAD_COLOR); // Read the file
if (! image.data )                      // Check for invalid input
{
    cout <<  "Could not open or find the image" << std::endl ;
    return -1;
}
Run Code Online (Sandbox Code Playgroud)

在第三行,做什么!.data意味着什么?他们如何检查无效输入?

jua*_*nza 6

cv::Mat::data是指向cv::Mat对象内部保存的数据缓冲区的指针.如果它的计算结果为false,则表示没有加载任何数据,并且无法取消引用指针.

它是比较相当于image.dataNULL,0nullptr在C++ 11.