操作系统:Win10
工具:VS2019、OpenCV4.0.0
测试结果 测试代码 #include <opencv.hpp> #include int main(int argc, char* argv[])
{
//imread读取图像,返回Mat类用于存储
cv::Mat src_mat = cv::imread(“C:/Users/Cocos/Desktop/1.JPG”);
//判断是否读取成功
if (src_mat.empty())
{
std::cout << “读取文件失败” << std::endl;
return EXIT_FAILURE;
}
std::cout << “读取文件成功” << std::endl;
//创建标识符为hello的窗体
cv::namedWindow(“hello”,cv::WINDOW_AUTOSIZE);
//将srt_mat显示在hello窗体上
cv::imshow(“hello”, src_mat);
cv::waitKey(0);
return EXIT_SUCCESS;
}