Ignore:
Timestamp:
Nov 21, 2010, 10:06:11 PM (13 years ago)
Author:
sommeria
Message:

series: give writting access to the group for all subdirectories produced
uvmat.fig: change of vect and scalar frames (to be consistent with view_field)
uvmat: various cleaning
plot_field: various cleaning to improve axes definition and avoid blinking
geometry_calib: improved dispay of point coordiantes, improved link with dataview for REPLICATE.
struct2nc: repair bug , file was not closed.
cell2tab: cleaning
dataview: improve the browser
civ: solve pb of image naming

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r121 r128  
    5454                   'gui_LayoutFcn',  [] , ...
    5555                   'gui_Callback',   []);
    56 if nargin && ischar(varargin{1})
     56if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))
    5757    gui_State.gui_Callback = str2func(varargin{1});
    5858end
     
    9595if exist('inputfile','var')&& ~isempty(inputfile)
    9696    struct.XmlInputFile=inputfile;
    97     set(hObject,'UserData',struct)
    98     [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile);
     97    [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile);
    9998    if ~strcmp(ext,'.xml')
    10099        inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file
     
    103102set(handles.ListCoord,'String',{'......'})
    104103if exist(inputfile,'file')
    105     loadfile(handles,inputfile)% load the point coordiantes existing in the xml file
    106 end
     104    Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
     105end
     106if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
     107    struct.Campaign=Heading.Campaign;
     108end
     109set(hObject,'UserData',struct)
    107110set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
    108111
     
    213216    ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
    214217    ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']});
     218
     219%% record the calibration parameters and display the current image of uvmat in the new phys coordinates
    215220if strcmp(answer,'Yes')
    216221    if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration
     
    219224            Z_plane=0; %default
    220225        else
    221             Z_plane=str2num(answer_1);
     226            Z_plane=str2double(answer_1);
    222227        end
    223228        GeometryCalib.NbSlice=1;
     
    228233        msgbox_uvmat('ERROR',errormsg);
    229234    end
     235   
    230236    %display image with new calibration in the currently opened uvmat interface
    231237    hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers
     
    251257%------------------------------------------------------------------
    252258% --- Executes on button press in calibrate_lin.
     259
    253260function REPLICATE_Callback(hObject, eventdata, handles)
    254 % %%%%%%Todo: correct on the model of APPLY_Callback%%%%%%%%%%
    255 %------------------------------------------------------------------------
    256 calib_cell=get(handles.calib_type,'String');
    257 val=get(handles.calib_type,'Value');
    258 Coord_cell=get(handles.ListCoord,'String');
    259 Object=read_geometry_calib(Coord_cell);
    260 GeometryCalib=feval(['calib_' calib_cell{val}],Object.Coord,handles);
     261%------------------------------------------------------------------------
     262
     263%% Apply calibration
     264calib_cell=get(handles.calib_type,'String'); %#ok<NASGU>
     265val=get(handles.calib_type,'Value'); %#ok<NASGU>
    261266
    262267%read the current calibration points
     
    288293    [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima));
    289294    [EM,ind_dim]=max(GeometryCalib.ErrorMax);
    290     index=index(ind_dim);
     295%     index=index(ind_dim);
    291296    %set the Z position of the reference plane used for calibration
    292297    Z_plane=[];
     
    295300    end
    296301    answer_1=msgbox_uvmat('INPUT_TXT',' Z= ',num2str(Z_plane));
    297     Z_plane=str2num(answer_1);
     302    Z_plane=str2double(answer_1);
    298303    GeometryCalib.NbSlice=1;
    299304    GeometryCalib.SliceCoord=[0 0 Z_plane];
     
    304309    %record the points
    305310    GeometryCalib.SourceCalib.PointCoord=Coord;
    306 %     errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file
    307 %     if ~strcmp(errormsg,'')
    308 %         msgbox_uvmat('ERROR',errormsg);
    309 %     end
    310 end
     311end
     312
     313%% display calibration paprameters
    311314display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters
    312315
     
    319322set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    320323
    321 % indicate the plane of the calibration grid if defined
    322 % huvmat=findobj(allchild(0),'Name','uvmat');
    323 % hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
    324 % RootPath='';
    325 % RootFile='';
    326 % if ~isempty(hhuvmat.RootPath)& ~isempty(hhuvmat.RootFile)
    327 %     testhandle=1;
    328 %     RootPath=get(hhuvmat.RootPath,'String');
    329 %     RootFile=get(hhuvmat.RootFile,'String');
    330 %     filebase=fullfile(RootPath,RootFile);
    331 %     outputfile=[filebase '.xml'];
    332 % else
    333 %     question={'save the calibration data and point coordinates in'};
    334 %     def={fullfile(RootPath,['ObjectCalib.xml'])};
    335 %     options.Resize='on';
    336 %     answer=inputdlg(question,'save average in a new file',1,def,options);
    337 %     outputfile=answer{1};
    338 % end
    339 
    340 %open and read the dataview GUI
     324%% open the GUI dataview
    341325h_dataview=findobj(allchild(0),'name','dataview');
    342326if ~isempty(h_dataview)
     
    344328end
    345329CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata
    346 
     330InputFile='';
    347331if isfield(CalibData,'XmlInputFile')
    348     XmlInput=fileparts(CalibData.XmlInputFile);
    349     [XmlInput,filename,ext]=fileparts(XmlInput);
     332    InputDir=fileparts(CalibData.XmlInputFile);
     333    [InputDir,DirName]=fileparts(InputDir);
    350334end
    351335SubCampaignTest='n'; %default
    352 testinput=0;
    353 if isfield(CalibData,'Heading')
    354     Heading=CalibData.Heading;
    355     if isfield(Heading,'Record') && isequal([filename ext],Heading.Record)
    356         [XmlInput,filename,ext]=fileparts(XmlInput);
    357     end
    358     if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
    359         [XmlInput,filename,ext]=fileparts(XmlInput);
    360         Device=Heading.Device;
    361     end
    362     if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
    363         [PP,filename,ext]=fileparts(XmlInput);
    364     end
    365     testinput=0;
    366     if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
    367         SubCampaignTest='y';
    368         testinput=1;
    369     elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
    370         testinput=1;
    371     end
    372 end
    373 if ~testinput
    374     filename='PROJETS';%default
    375     if isfield(CalibData,'XmlInputFile')
    376          [pp,filename]=fileparts(CalibData.XmlInputFile);
    377     end
    378     while ~isequal(filename,'PROJETS') && numel(filename)>1
    379         filename_1=filename;
    380         pp_1=pp;
    381         [pp,filename]=fileparts(pp);
    382     end
    383     XmlInput=fullfile(pp_1,filename_1);
    384     testinput=1;
    385 end
    386 if testinput
    387     outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib);
    388 end
     336testup=0;
     337if isfield(CalibData,'SubCampaign')
     338    SubCampaignTest='y';
     339    dir_ref=CalibData.SubCampaign;
     340    testup=1;
     341elseif isfield(CalibData,'Campaign')
     342    dir_ref=CalibData.Campaign;
     343    testup=1;
     344end
     345while testup
     346    [InputDir,DirName]=fileparts(InputDir);
     347    if strcmp(DirName,dir_ref)
     348        break
     349    end
     350end
     351InputDir=fullfile(InputDir,DirName);
     352answer=msgbox_uvmat('INPUT_TXT','Campaign ?',InputDir);
     353if strcmp(answer,'Cancel')
     354    return
     355end
     356
     357dataview(answer,SubCampaignTest,GeometryCalib);
     358       
     359%     if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
     360%         [XmlInput,filename,ext]=fileparts(XmlInput);
     361%         Device=Heading.Device;
     362%     end
     363%     if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
     364%         [PP,filename,ext]=fileparts(XmlInput);
     365%     end
     366%     testinput=0;
     367%     if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
     368%         SubCampaignTest='y';
     369%         testinput=1;
     370%     elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
     371%         testinput=1;
     372% %     end
     373% end
     374% if ~testinput
     375%     filename='PROJETS';%default
     376%     if isfield(CalibData,'XmlInputFile')
     377%          [pp,filename]=fileparts(CalibData.XmlInputFile);
     378%     end
     379%     while ~isequal(filename,'PROJETS') && numel(filename)>1
     380%         filename_1=filename;
     381%         pp_1=pp;
     382%         [pp,filename]=fileparts(pp);
     383%     end
     384%     XmlInput=fullfile(pp_1,filename_1);
     385%     testinput=1;
     386% end
     387% if testinput
     388%     outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib);
     389% end
    389390
    390391%------------------------------------------------------------------------
     
    434435R=[R;[0 0]];
    435436GeometryCalib.R=[R [0;0;1]];
    436 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0]
     437GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0];
    437438%------------------------------------------------------------------------
    438439% determine the tsai parameters for a view normal to the grid plane
     
    700701
    701702%--------------------------------------------------------------------------
    702 function GeometryCalib=calib_tsai(Coord,handles)% old version using gauthier's bianry ccal_fo
     703function GeometryCalib=calib_tsai(Coord,handles)% OBSOLETE: old version using gauthier's bianry ccal_fo
    703704% NOT USED
    704705%------------------------------------------------------------------------
     
    811812huvmat=findobj(allchild(0),'Name','uvmat');
    812813hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
    813 RootPath='';
    814 RootFile='';
     814% RootPath='';
     815% RootFile='';
    815816if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile)
    816817    testhandle=1;
     
    830831        listfile={outputfile};
    831832    else
    832         listfile=[listfile;{outputfile}]%update the list of coord files
     833        listfile=[listfile;{outputfile}];%update the list of coord files
    833834    end
    834835    set(handles.coord_files,'string',listfile);
     
    901902end
    902903coord_str=Coord_cell{val};
    903 k=findstr('|',coord_str);
     904k=findstr(' | ',coord_str);
    904905if isempty(k)%last line '.....' selected
    905906    if ~isempty(hhh)
     
    10001001%------------------------------------------------------------------------
    10011002huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    1002 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
     1003%UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    10031004hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
    1004 hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
     1005%hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
    10051006h_menu_coord=findobj(huvmat,'Tag','transform_fct');
    10061007menu=get(h_menu_coord,'String');
     
    10791080
    10801081%size(data.Coord,1)
    1081 Tabchar=cell2tab(Coord,'    |    ');
     1082Tabchar=cell2tab(Coord,' | ');
    10821083Tabchar=[Tabchar ;{'......'}];
    10831084set(handles.ListCoord,'String',Tabchar)
     
    12361237     Coord{ipoint,5}=num2str(Ypx(ipoint),4);%display coordiantes with 4 digits
    12371238end
    1238 Tabchar=cell2tab(Coord(end:-1:1,:),'    |    ');
     1239Tabchar=cell2tab(Coord(end:-1:1,:),' | ');
    12391240Tabchar=[Tabchar ;{'......'}];
    12401241set(handles.ListCoord,'Value',1)
     
    12661267   end
    12671268end
    1268 Tabchar=cell2tab(Coord,'    |    ');
     1269Tabchar=cell2tab(Coord,' | ');
    12691270Tabchar=[Tabchar; {'.....'}];
    12701271%set(handles.ListCoord,'Value',1)
     
    13101311   end
    13111312end
    1312 Tabchar=cell2tab(Coord,'    |    ');
     1313Tabchar=cell2tab(Coord,'| ');
    13131314Tabchar=[Tabchar;{'......'}];
    13141315set(handles.ListCoord,'Value',1)
     
    14601461end
    14611462CoordCell=reshape(CoordCell,[],5);
    1462 Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
     1463Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
    14631464Tabchar=[Tabchar;{'......'}];
    14641465set(handles.ListCoord,'Value',1)
     
    15411542
    15421543% -----------------------------------------------------------------------
    1543 function loadfile(handles,fileinput)
    1544 %------------------------------------------------------------------------
     1544function Heading=loadfile(handles,fileinput)
     1545%------------------------------------------------------------------------
     1546Heading=[];%default
    15451547[s,errormsg]=imadoc2struct(fileinput,'GeometryCalib');
     1548if ~isempty(errormsg)
     1549    msgbox_uvmat('ERROR',['Error for reading ' fileinput ': '  errormsg])
     1550    return
     1551end
     1552if ~isempty(s.Heading)
     1553    Heading=s.Heading;
     1554end
     1555   
    15461556GeometryCalib=s.GeometryCalib;
    15471557fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
     
    15851595    end
    15861596    CoordCell=reshape(CoordCell,[],5);
    1587     Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
     1597    Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
    15881598    MenuPlot_Callback(handles.geometry_calib, [], handles)
    15891599end
Note: See TracChangeset for help on using the changeset viewer.