Skip to content

Commit

Permalink
Saving calibration model to XML meta-file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Francois Lalonde committed Jun 12, 2013
1 parent 392d9e0 commit 0d2bcbb
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions mycode/EnvironmentMap.m
Expand Up @@ -81,6 +81,8 @@
bgColor = 0;

parseVarargin(varargin{:});

e.calibrationModel = calibModel;

if ischar(input)
% we're given the filename
Expand Down Expand Up @@ -203,14 +205,13 @@
e.fisheyeInverseFcn = @(r) r./e.focalLength;

case EnvironmentMapFormat.Omnidirectional
assert(~isempty(calibModel), ...
assert(~isempty(e.calibrationModel), ...
'Omnidirectional format requires calibration model');

e.calibrationModel = calibModel;

% resize according to dimensions in the model
e.data = imresize(e.data, [size(e.data, 1), ...
size(e.data,1)*calibModel.width/calibModel.height]);
size(e.data,1)*e.calibrationModel.width/...
e.calibrationModel.height]);

otherwise
assert(isempty(hfov), ...
Expand Down Expand Up @@ -1213,6 +1214,12 @@ function display(e)

% fill in the information from the XML file
e.format = EnvironmentMapFormat.format(xmlInfo.data.format);

% check for the calibration model information
if isfield(xmlInfo, 'calibrationModel')
e.calibrationModel = xmlInfo.calibrationModel;
e.calibrationModel.ss = vertcat(e.calibrationModel.ss(:).s);
end
end

end
Expand All @@ -1229,6 +1236,13 @@ function writeMetadataFile(e, outFile)

% store full path to data file
xmlInfo.data.file = outFile;

% store calibration model
if ~isempty(e.calibrationModel)
xmlInfo.calibrationModel = e.calibrationModel;
xmlInfo.calibrationModel.ss = ...
arrayfun(@(s) struct('s', s), xmlInfo.calibrationModel.ss);
end

% save information
write_xml(metadataFile, xmlInfo);
Expand Down

0 comments on commit 0d2bcbb

Please sign in to comment.