Ubuntu使用OpenCV报错
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.4) /home/king/下载/opencv-4.5.4/modules/core/src/array.cpp:2494: error: (-206:Bad flag (parameter or structure field)) Unrecognized or unsupported array type in function 'cvGetMat'
此错误的原因是由于cv::image(image_file,0)函数读取文件的路径不正确导致的,可将路径转换为绝对路径
//string image_file = "./distorted.png"; // 请确保路径正确
string image_file = "/home/king/下载/slambook2-master/ch5/imageBasics/distorted.png";
将文件路径转为绝对路径是最不容易出错的。