什么'!图像数据"在C++中的意思?

What does '! image.data' mean in C++?

本文关键字:C++ 意思 数据 图像 什么      更新时间:2023-10-16

我是使用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;
}

第三行,!.data是什么意思?他们如何检查无效输入?

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

它相当于c++ 11中image.dataNULL0nullptr的比较。