我正在尝试保存相机矩阵和失真系数以供以后使用,但是我编写的代码似乎不起作用。它不在 yml 文件中存储任何类型的数据。即使我读回来,它也不会向指定的矩阵输入任何内容。如果我做错了什么,请帮助我理解。我正在使用带有 OpenCV 2.4.5 的 VS2010
cv::Mat CameraMatrix, DistCoeffs;
CameraMatrix = (cv::Mat_<double>(3,3) << 1,2,3,4,5,6,7,8,9);
DistCoeffs = (cv::Mat_<double>(1,5) << 10, 11, 12, 13, 15);
cv::FileStorage fs("IntCali.yml", cv::FileStorage::WRITE);
fs << "CameraMatrix" << CameraMatrix;
fs << "DistCoeffs" << DistCoeffs;
fs.release();
cv::FileStorage fs2("IntCali.yml", cv::FileStorage::READ);
cv::Mat cm; fs2["CameraMatrix"] >> cm;
cv::Mat dc;
fs2["DistCoeffs"] >> dc;
fs2.release();