1. 程式人生 > >opencv yml 讀取寫入 攝像機標定引數

opencv yml 讀取寫入 攝像機標定引數

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