source: trunk/src/update_imadoc.m @ 129

Last change on this file since 129 was 114, checked in by sommeria, 14 years ago

geometric calibration procedures updated

File size: 2.3 KB
RevLine 
[13]1%'update_imadoc': update an xml file with geometric calibration parameters
2%--------------------------------------------------------------------------
3%  function update_imadoc(GeometryCalib,outputfile)
4%
5%INPUT:
6% GeometryCalib: structure containing the calibration parameters
7% outputfile: xml file to modify
8%-------------------------------------------------------------
[114]9function errormsg=update_imadoc(GeometryCalib,outputfile)
10errormsg='';
[13]11testappend=0;
12if exist(outputfile,'file');%=1 if the output file already exists, 0 else 
[29]13    testappend=1;
[13]14    t=xmltree(outputfile); %read the file
[17]15    backupfile=outputfile;
16    testexist=2;
17    while testexist==2
18       backupfile=[backupfile '~'];
19       testexist=exist(backupfile,'file');
20    end
21    [success,message]=copyfile(outputfile,backupfile);%make backup
[114]22    if success==0
23        errormsg=message
24    end
[13]25    uid=find(t,'ImaDoc');
26    if ~isequal(uid,1)
27        return
[114]28    end       
[13]29    %if the xml file is  ImaDoc
30    uid_calib=find(t,'ImaDoc/GeometryCalib');
31    if isempty(uid_calib)  %if GeometryCalib does not already exists, create it
32        [t,uid_calib]=add(t,1,'element','GeometryCalib');
33    else %if GeometryCalib already exists, delete its content
34        if isequal(success,1)
35            delete(outputfile)
36        else
37            return
38        end
39        uid_child=children(t,uid_calib);
40        t=delete(t,uid_child);
41    end
42end
[84]43%create a new xml file
[13]44if ~testappend
45    t=xmltree;
46    t=set(t,1,'name','ImaDoc');
[84]47    % in case of movie (avi file), copy timing info in the new xml file
48    [pp,outputroot]=fileparts(outputfile);
49    info=[];
50    if exist(fullfile(pp,[outputroot '.avi']),'file')
51        info=aviinfo(fullfile(pp,[outputroot '.avi']));
52    elseif exist(fullfile(pp,[outputroot '.AVI']),'file')
53        info=fullfile(pp,[outputroot '.AVI']);
54    end
55    if ~isempty(info)
56        [t,uid_camera]=add(t,1,'element','Camera');
57        Camera.TimeUnit='s';
58%         Camera.BurstTiming.FrameFrequency=info.FramesPerSecond;
59        Camera.BurstTiming.Time=0;
60        Camera.BurstTiming.Dti=1/info.FramesPerSecond;
61        Camera.BurstTiming.NbDti=info.NumFrames-1;
62        t=struct2xml(Camera,t,uid_camera)
63    end
64   [t,uid_calib]=add(t,1,'element','GeometryCalib');
[13]65end
66t=struct2xml(GeometryCalib,t,uid_calib);
67save(t,outputfile);
Note: See TracBrowser for help on using the repository browser.