int StereoMatch::loadCalibData(const char* xmlFilePath)
{
// 读入摄像头定标参数 Q roi1 roi2 mapx1 mapy1 mapx2 mapy2
try
{
cv::FileStorage fs(xmlFilePath, cv::FileStorage::READ);
if ( !fs.isOpened() )
{
return (0);
}
cv::Size imageSize;
cv::FileNodeIterator it = fs["imageSize"].begin();
it >> imageSize.width >> imageSize.height;
if (imageSize.width != m_frameWidth || imageSize.height != m_frameHeight)
{
return (-1);
}
vector<int> roiVal1;
vector<int> roiVal2;
fs["leftValidArea"] >> roiVal1;
m_Calib_Roi_L.x = roiVal1[0];
m_Calib_Roi_L.y = roiVal1[1];
m_Calib_Roi_L.width = roiVal1[2];
m_Calib_Roi_L.height = roiVal1[3];
fs["rightValidArea"] >> roiVal2;
m_Calib_Roi_R.x = roiVal2[0];
m_Calib_Roi_R.y = roiVal2[1];
m_Calib_Roi_R.width = roiVal2[2];
m_Calib_Roi_R.height = roiVal2[3];
fs["QMatrix"] >> m_Calib_Mat_Q;
fs["remapX1"] >> m_Calib_Mat_Remap_X_L;
fs["remapY1"] >> m_Calib_Mat_Remap_Y_L;
fs["remapX2"] >> m_Calib_Mat_Remap_X_R;
fs["remapY2"] >> m_Calib_Mat_Remap_Y_R;
cv::Mat lfCamMat;
fs["leftCameraMatrix"] >> lfCamMat;
m_FL = lfCamMat.at<double>(0,0);