opencv yml 读取写入 摄像机标定参数

#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char** argv)
{
	FileStorage fs("test.yml", FileStorage::WRITE);
	Mat cameraMatrix = (Mat_(3, 3) << 1000, 0, 320, 0, 1000, 240, 0, 0, 1);
	Mat distCoeffs = (Mat_(5, 1) << 0.1, 0.01, -0.001, 0, 0);
	fs << "cameraMatrix" << cameraMatrix << "distCoeffs" << distCoeffs;
	fs.release();
	return 0;
}


#include "opencv2/opencv.hpp"
#include
using namespace cv;
using namespace std;
int main()
{
	FileStorage fs2("C:/Users/Administrator/Desktop/test.yml", FileStorage::READ);
	Mat cameraMatrix2, distCoeffs2;
	fs2["cameraMatrix"] >> cameraMatrix2;
	fs2["distCoeffs"] >> distCoeffs2;
	cout << cameraMatrix2 << endl;
	cout << distCoeffs2 << endl;
}


你可能感兴趣的:(c++,OPENCV)