Ignore:
Timestamp:
Oct 16, 2010, 5:56:00 PM (14 years ago)
Author:
sommeria
Message:

geometry_calib is now updated when a new image is viewed by uvmat
imadoc2struct corrected for time reading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r114 r116  
    7171% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
    7272%------------------------------------------------------------------------
    73 function geometry_calib_OpeningFcn(hObject, eventdata, handles, handles_uvmat,pos,inputfile)
     73function geometry_calib_OpeningFcn(hObject, eventdata, handles,inputfile,pos)
    7474%------------------------------------------------------------------------
    7575% Choose default command line output for geometry_calib
     
    8181
    8282%set the position of the interface
    83 if exist('pos','var')& length(pos)>2
     83if exist('pos','var')&& length(pos)>2
    8484    pos_gui=get(hObject,'Position');
    8585    pos_gui(1)=pos(1);
     
    9292set(handles.calib_type,'String',{'rescale';'linear';'quadr';'3D_linear';'3D_quadr';'3D_extrinsic'})
    9393inputxml='';
    94 if exist('inputfile','var')& ~isempty(inputfile)
     94if exist('inputfile','var')&& ~isempty(inputfile)
    9595    struct.XmlInputFile=inputfile;
    9696    set(hObject,'UserData',struct)
    9797    [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile);
    98     inputxml=[fullfile(Pathsub,RootFile) '.xml'];
     98    if ~strcmp(ext,'.xml')
     99        inputfile=[fullfile(Pathsub,RootFile) '.xml']%xml file corresponding to the input file
     100    end
    99101end
    100102set(handles.ListCoord,'String',{'......'})
    101 if exist(inputxml,'file')
    102     loadfile(handles,inputxml)% load the point coordiantes existing in the xml file
     103if exist(inputfile,'file')
     104    loadfile(handles,inputfile)% load the point coordiantes existing in the xml file
    103105end
    104106set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
     
    232234    set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off'
    233235    set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
     236    UserData=get(handles.geometry_calib,'UserData');
     237    UserData.XmlInputFile=outputfile;%save the current xml file name
     238    set(handles.geometry_calib,'UserData',UserData)
    234239    uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    235240    MenuPlot_Callback(hObject, eventdata, handles)
     
    294299    %record the points
    295300    GeometryCalib.SourceCalib.PointCoord=Coord;
    296     errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file
    297     if ~strcmp(errormsg,'')
    298         msgbox_uvmat('ERROR',errormsg);
    299     end
     301%     errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file
     302%     if ~strcmp(errormsg,'')
     303%         msgbox_uvmat('ERROR',errormsg);
     304%     end
    300305end
    301306display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters
     
    412417% y1=XY_mat*a_Y1;
    413418% err_Y1=max(abs(y1-y_ima));%error
     419R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,0];
     420norm=abs(det(R));
    414421GeometryCalib.CalibrationType='linear';
    415 GeometryCalib.focal=1;
     422GeometryCalib.fx_fy=[norm norm];
    416423GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    417424R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,0];
    418 norm=det(R);
    419 GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) norm];
     425GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) 1];
    420426GeometryCalib.R=R/norm;
    421 
     427GeometryCalib.omc=(180/pi)*[acos(R(1,1)) 0 0];
    422428%------------------------------------------------------------------------
    423429% determine the tsai parameters for a view normal to the grid plane
     
    600606path_uvmat=which('geometry_calib');% check the path detected for source file uvmat
    601607path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    602 x_1=Coord(:,4:5)';
    603 X_1=Coord(:,1:3)';
     608x_1=double(Coord(:,4:5)');%image coordiantes
     609X_1=double(Coord(:,1:3)');% phys coordinates
    604610huvmat=findobj(allchild(0),'Tag','uvmat');
    605611hhuvmat=guidata(huvmat);
    606 ny=str2num(get(hhuvmat.npy,'String'));
     612ny=str2double(get(hhuvmat.npy,'String'));
    607613x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates
    608614n_ima=1;
     
    615621fct_path=fullfile(path_UVMAT,'toolbox_calib');
    616622addpath(fct_path)
    617 Cx_Cy=ny-(GeometryCalib.Cx_Cy)';%reverse Cx_Cy(2) for calibration (inversion of px ordinate)
     623GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%reverse Cx_Cy(2) for calibration (inversion of px ordinate)
    618624% [omc1,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,...
    619625%     [Calib.f Calib.f*Calib.sx]',...
     
    621627%     [-Calib.kappa1*Calib.f^2 0 0 0 0]);
    622628[omc,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,...
    623     (GeometryCalib.fx_fy)',...
    624     Cx_Cy,[GeometryCalib.kc 0 0 0 0]);
    625 %get the euler angles ???
     629    (GeometryCalib.fx_fy)',GeometryCalib.Cx_Cy',[GeometryCalib.kc 0 0 0 0]);
    626630rmpath(fct_path);
    627 
    628 std(ex')
    629631GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    630632GeometryCalib.Tx_Ty_Tz=Tc1';
     
    633635GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
    634636GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate
    635 %GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
     637GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
    636638GeometryCalib.omc=(180/pi)*omc';
    637639%GeometryCalib.R(3,1:3)=-GeometryCalib.R(3,1:3);%inversion for z upward
     640
    638641
    639642
     
    993996% --------------------------------------------------------------------
    994997function MenuHelp_Callback(hObject, eventdata, handles)
    995 path_to_uvmat=which ('uvmat');% check the path of uvmat
     998path_to_uvmat=which('uvmat');% check the path of uvmat
    996999pathelp=fileparts(path_to_uvmat);
    997     helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
     1000helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
    9981001if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    9991002else
     
    14091412GeometryCalib=s.GeometryCalib;
    14101413%GeometryCalib=load_calib(hObject, eventdata, handles)
    1411 calib=reshape(GeometryCalib.PointCoord',[],1);
     1414calib=reshape(GeometryCalib.PointCoord,[],1);
    14121415for ilist=1:numel(calib)
    14131416    CoordCell{ilist}=num2str(calib(ilist));
     
    14741477fileinput=[];%default
    14751478oldfile=''; %default
    1476 UserData=get(handles.geometry_calib,'UserData')
     1479UserData=get(handles.geometry_calib,'UserData');
    14771480if isfield(UserData,'XmlInputFile')
    14781481    oldfile=UserData.XmlInputFile;
     
    14971500function loadfile(handles,fileinput)
    14981501%------------------------------------------------------------------------
    1499 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib');
    1500 GeometryCalib=s.GeometryCalib
     1502fileinput
     1503[s,errormsg]=imadoc2struct(fileinput,'GeometryCalib')
     1504GeometryCalib=s.GeometryCalib;
    15011505fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
    15021506%     Tabchar={};
     
    15341538        set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    15351539    end
    1536     calib=reshape(GeometryCalib.PointCoord',[],1);
     1540    calib=reshape(GeometryCalib.PointCoord,[],1);
    15371541    for ilist=1:numel(calib)
    15381542        CoordCell{ilist}=num2str(calib(ilist));
Note: See TracChangeset for help on using the changeset viewer.