2016-11-02

I would like to retrieve the camera calibration parameters from "intrinsic.yml" and "extrinsic.yml" file and use the parameter to rectify the Infrared images from the Realsense R200 camera. I have tried using the opencv FileStorage method but the program is unable to open both files. Below is a portion of the code that I used to open and extract the parameters from the ".yml" file.

std::string intrinsic_filename = "intrinsics.yml";
std::string extrinsic_filename = "extrinsics.yml";

if( (!intrinsic_filename.empty()) ^ (!extrinsic_filename.empty()) )
{
printf("Command-line parameter error: either both intrinsic and extrinsic parameters must be specified, or none of them (when the stereo pair is already rectified)\n");
//return -1;
}

if( !intrinsic_filename.empty() ) // rectify and undistort images
{
// reading intrinsic parameters
cv::FileStorage fs(intrinsic_filename, cv::FileStorage::READ);
if(!fs.isOpened())
{
printf("Failed to open file %s\n", intrinsic_filename.c_str());
//return -1;
}

cv::Mat M1, D1, M2, D2;
fs["M1"] >> M1;
fs["D1"] >> D1;
fs["M2"] >> M2;
fs["D2"] >> D2;

M1 *= scale;
M2 *= scale;

fs.open(extrinsic_filename, cv::FileStorage::READ);
if(!fs.isOpened())
{
printf("Failed to open file %s\n", extrinsic_filename.c_str());
//return -1;
}

cv::Mat R, T, R1, P1, R2, P2;
fs["R"] >> R;
fs["T"] >> T;
fs["F"] >> F;

//stereoRectify( M1, D1, M2, D2, img_size, R, T, R1, R2, P1, P2, Q, 1024, -1, img_size, &roi1, &roi2 );

cv::Mat map11, map12, map21, map22;
//initUndistortRectifyMap(M1, D1, R1, P1, img_size, CV_16SC2, map11, map12);
//initUndistortRectifyMap(M2, D2, R2, P2, img_size, CV_16SC2, map21, map22);

//remap(src, img1r, map11, map12, 1); // rectified image: img1r
//remap(src, img2r, map21, map22, 1); // rectified image: img2r
}

Both the "intrinsic.yml" and "extrinsic.yml" file are located at the package root location.
The output that I get is as follows:
"Failed to open file intrinsic.yml" and "Failed to open file extrinsic.yml". How do I go about solving this problem?

Show more