......
Mat mapx, mapy; //可以只定义,不初始化
......
SaveMapXY(direct,mapx,mapy); //存xml文件
//必须初始化,只定义“Mat mapx_read”会报错!!!!!
Mat mapx_read(Height_UndistortImg, Width_UndistortImg, CV_32FC1, Scalar(0));
Mat mapy_read(Height_UndistortImg, Width_UndistortImg, CV_32FC1, Scalar(0));
ReadMapXY(direct, mapx_read, mapy_read); //读mapx、mapy
//将Mat存为mapx.xml
void SaveMapXY(Mat mapx)
{
//写mapx,mapy为xml文件
string mapx_xml = "mapx";
string mapx_xml_name = ".\\" + mapx_xml + ".xml";
FileStorage save_mpx(mapx_xml_name.c_str(), FileStorage::WRITE);
save_mpx << mapx_xml.c_str() << mapx;
save_mpx.release();
}
//加载mapx.xml到Mat
void ReadMapXY(Mat mapx)
{
//读mapx,mapy为xml文件
string mapx_xml = "mapx";
string mapx_xml_name = ".\\" + mapx_xml + ".xml";
FileStorage read_mpx(mapx_xml_name.c_str(), FileStorage::READ);
read_mpx[mapx_xml.c_str()] >> mapx;
}