ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The best way is to write a small Matlab code that will load parameters and export them to the YAML file

There is a small bridge tool to do this yamlmatlab

Example for creating yaml file from stereo calibration

addpath(genpath('/home/adamanov/Libraries/yamlmatlab-master'));

load('stereoParams.mat');
load('estimationErrors.mat');

%% -----------Left Camera (=Camera_1) ----------------
l.image_width  = stereoParams.CameraParameters1.ImageSize(2);
l.image_height = stereoParams.CameraParameters1.ImageSize(1);

l.camera_matrix = '' ;
l.camera_matrix.rows = 3;
l.camera_matrix.cols = 3;
l.camera_matrix.dt = 'd';
fx = stereoParams.CameraParameters1.IntrinsicMatrix(1,1);
fy = stereoParams.CameraParameters1.IntrinsicMatrix(2,2);
s =  stereoParams.CameraParameters1.IntrinsicMatrix(2,1);
cx = stereoParams.CameraParameters1.IntrinsicMatrix(3,1);
cy = stereoParams.CameraParameters1.IntrinsicMatrix(3,2);

l.camera_matrix.data = [fx, s, cx , 0, fy, cy, 0, 0,  1];

k1 = stereoParams.CameraParameters1.RadialDistortion(1);
k2 = stereoParams.CameraParameters1.RadialDistortion(2);
k3 = stereoParams.CameraParameters1.RadialDistortion(3);
p1 = stereoParams.CameraParameters1.TangentialDistortion(1);
p2 = stereoParams.CameraParameters1.TangentialDistortion(2);

l.distortion_coefficients = '';
l.distortion_coefficients.rows = 1;
l.distortion_coefficients.cols = 5;
l.distortion_coefficients.dt = 'd';
l.distortion_coefficients.data = [k1,k2,p1,p2,k3];


yaml.WriteYaml('camera_info_left.yaml',l)