| 1 | %'imadoc2struct': reads the xml file for image documentation
|
|---|
| 2 | %------------------------------------------------------------------------
|
|---|
| 3 | % function [s,errormsg]=imadoc2struct(ImaDoc,option)
|
|---|
| 4 | %
|
|---|
| 5 | % OUTPUT:
|
|---|
| 6 | % s: structure representing ImaDoc
|
|---|
| 7 | % s.Heading: information about the data hierarchical structure
|
|---|
| 8 | % s.Time: matrix of times, note that s.Time(i+1,j+1) is the time for file indices i and j (in order to deal with index 0)
|
|---|
| 9 | % s.TimeUnit
|
|---|
| 10 | % s.GeometryCalib: substructure containing the parameters for geometric calibration
|
|---|
| 11 | % errormsg: error message
|
|---|
| 12 | %
|
|---|
| 13 | % INPUT:
|
|---|
| 14 | % ImaDoc: full name of the xml input file with head key ImaDoc
|
|---|
| 15 | % varargin: optional list of strings to restrict the reading to a selection of subtrees, for instance 'GeometryCalib' (save time)
|
|---|
| 16 |
|
|---|
| 17 | %=======================================================================
|
|---|
| 18 | % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
|
|---|
| 19 | % http://www.legi.grenoble-inp.fr
|
|---|
| 20 | % Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
|
|---|
| 21 | %
|
|---|
| 22 | % This file is part of the toolbox UVMAT.
|
|---|
| 23 | %
|
|---|
| 24 | % UVMAT is free software; you can redistribute it and/or modify
|
|---|
| 25 | % it under the terms of the GNU General Public License as published
|
|---|
| 26 | % by the Free Software Foundation; either version 2 of the license,
|
|---|
| 27 | % or (at your option) any later version.
|
|---|
| 28 | %
|
|---|
| 29 | % UVMAT is distributed in the hope that it will be useful,
|
|---|
| 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 32 | % GNU General Public License (see LICENSE.txt) for more details.
|
|---|
| 33 | %=======================================================================
|
|---|
| 34 |
|
|---|
| 35 | function [s,errormsg]=imadoc2struct(ImaDoc,varargin)
|
|---|
| 36 |
|
|---|
| 37 | s=[]; %default output
|
|---|
| 38 |
|
|---|
| 39 | %% opening the xml file
|
|---|
| 40 | if nargin ==1% no additional input variable beyond 'ImaDoc'
|
|---|
| 41 | [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
|
|---|
| 42 | elseif nargin ==2 %one additional input variable beyond 'ImaDoc'specifying the subtree to read
|
|---|
| 43 | [s,Heading,errormsg]=xml2struct(ImaDoc,varargin{1});% convert the xml file in a structure s, keeping only the subtree defined in input
|
|---|
| 44 | else % case of two subtrees, TODO: deal with more than two subtrees?
|
|---|
| 45 | [s,Heading,errormsg]=xml2struct(ImaDoc,varargin{1},varargin{2});% convert the xml file in a structure s, keeping only the subtree defined in input
|
|---|
| 46 | end
|
|---|
| 47 | if ~isempty(errormsg)
|
|---|
| 48 | errormsg=['error in reading ImaDoc xml file: ' errormsg];
|
|---|
| 49 | return
|
|---|
| 50 | end
|
|---|
| 51 | if ~strcmp(Heading,'ImaDoc')
|
|---|
| 52 | errormsg='imadoc2struct/the input xml file is not ImaDoc';
|
|---|
| 53 | return
|
|---|
| 54 | end
|
|---|
| 55 |
|
|---|
| 56 | %% reading timing
|
|---|
| 57 | if isfield(s,'Camera')
|
|---|
| 58 | if isfield(s.Camera,'TimeUnit')
|
|---|
| 59 | s.TimeUnit=s.Camera.TimeUnit;
|
|---|
| 60 | end
|
|---|
| 61 | if ~isfield(s.Camera,'FirstFrameIndexI')
|
|---|
| 62 | s.Camera.FirstFrameIndexI=1; %first index assumed equl to 1 by default
|
|---|
| 63 | end
|
|---|
| 64 | s.Time=xmlburst2time(s.Camera.BurstTiming,s.Camera.FirstFrameIndexI);
|
|---|
| 65 | end
|
|---|
| 66 |
|
|---|