Changeset 1113


Ignore:
Timestamp:
Feb 8, 2022, 1:58:47 PM (2 years ago)
Author:
sommeria
Message:

bug corrected in 3D calibration

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r1112 r1113  
    5252% Edit the above text to modify the response to help geometry_calib
    5353
    54 % Last Modified by GUIDE v2.5 20-Sep-2018 19:04:30
     54% Last Modified by GUIDE v2.5 05-Feb-2022 22:24:55
    5555
    5656% Begin initialization code - DO NOT edit
     
    232232
    233233%% Apply calibration
    234 [GeometryCalib,index,ind_removed,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration
     234[GeometryCalib,index,ind_removed]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration
    235235if isempty(GeometryCalib)
    236236    return
     
    245245GeometryCalib.SourceCalib.PointCoord=Coord;
    246246
    247 %% display calibration results on the GUI geometry_calib
    248 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters
    249 display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters
    250 %     (rotation and translation of camera with  respect to the phys coordinates)
    251 
    252247%% set the default plane and display the calibration data errors for validation
    253248answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';...
    254249    ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
    255250    ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels'];
    256     [num2str(numel(ind_removed)) ' points removed']});
    257 % SliceCoord_ref=[0 0 0]; %default reference plane
     251    [num2str(numel(ind_removed)) ' points removed with ErrorMax > 3 rms']});
    258252checkslice=0;
    259253if strcmp(answer,'Yes') %store the calibration data
     254    display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters on the GUI geometry_calib
     255    display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters on the GUI geometry_calib
    260256    Z=Coord(:,3);
    261257    if strcmp(calib_cell{val}(1:2),'3D') && isequal(max(Z),min(Z))%set the plane position for 3D (projection) calibration
     
    348344        errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file
    349345        if checkslice
    350                     errormsg=update_imadoc(Slice,outputfile,'Slice');% introduce the slice position in the xml file
     346            errormsg=update_imadoc(Slice,outputfile,'Slice');% introduce the slice position in the xml file
    351347        end
    352348        if ~strcmp(errormsg,'')
    353349            msgbox_uvmat('ERROR',errormsg);
    354350        end
    355        
     351
    356352        %% display image with new calibration in the currently opened uvmat GUI
    357353        FieldList=get(hhuvmat.FieldName,'String');
     
    397393%------------------------------------------------------------------------
    398394% --- activate calibration and store parameters in ouputfile .
    399 function [GeometryCalib,ind_max,ind_removed,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic)
     395function [GeometryCalib,ind_max,ind_removed]=calibrate(Coord,CalibFcn,Intrinsic)
    400396%------------------------------------------------------------------------
    401397
    402398index=[];
    403399GeometryCalib=[];
    404 ind_max=[];ind_removed=[];Z_plane=[];
     400ind_max=[];ind_removed=[];
    405401% apply the calibration, whose type is selected in  handles.calib_type
    406402CoordFlip=Coord;
    407 CoordFlip(:,3)=-Coord(:,3);
     403CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours
    408404if ~isempty(Coord)
    409405    GeometryCalib=feval(CalibFcn,CoordFlip,Intrinsic);
     
    414410    return
    415411end
    416 Z_plane=[];
    417412
    418413% estimate calibration error rms and max
    419 % X=Coord(:,1);
    420 % Y=Coord(:,2);
    421 Z=Coord(:,3);
    422414x_ima=Coord(:,4);
    423415y_ima=Coord(:,5);
    424 [Xpoints,Ypoints]=px_XYZ(GeometryCalib,[],Coord(:,1),Coord(:,2),Coord(:,3));% convention of downward z coordinate (facing the camera)
     416[Xpoints,Ypoints]=px_XYZ(GeometryCalib,[],Coord(:,1),Coord(:,2),Coord(:,3));
    425417GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
    426418GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
     
    430422ind_max=index(ind_dim); % mark the index with maximum deviation
    431423
    432 % detect bad calibration points, marked by indices ind_bad, if the
     424% detect bad calibration points, marked by indices ind_removed, if the
    433425% difference of actual image coordinates and those given by calibration is
    434 % greater than 2 pixels and greater than 4 rms.
     426% greater than 2 pixels and greater than 3 rms.
    435427check_x=abs(Xpoints-x_ima)>max(2,3*GeometryCalib.ErrorRms(1));
    436428check_y=abs(Ypoints-y_ima)>max(2,3*GeometryCalib.ErrorRms(2));
    437 ind_removed=find(check_x | check_y)
     429ind_removed=find(check_x | check_y);
    438430% repeat calibration without the excluded points:
    439431if ~isempty(ind_removed)
    440432    Coord(ind_removed,:)=[];
    441     GeometryCalib=feval(CalibFcn,Coord,Intrinsic);
     433    CoordFlip=Coord;
     434    CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours
     435    GeometryCalib=feval(CalibFcn,CoordFlip,Intrinsic);
    442436    X=Coord(:,1);
    443437    Y=Coord(:,2);
     
    450444end
    451445GeometryCalib.ErrorMax=ErrorMax;
    452 % %set the Z position of the reference plane used for calibration
    453 % if isequal(max(Z),min(Z))%Z constant
    454 %     Z_plane=Z(1);
    455 %     GeometryCalib.NbSlice=1;
    456 %     GeometryCalib.SliceCoord=[0 0 Z_plane];
    457 % end
    458446
    459447
     
    468456[px]=polyfit(X,x_ima,1);
    469457[py]=polyfit(Y,y_ima,1);
    470 % T_x=px(2);
    471 % T_y=py(2);
    472458GeometryCalib.CalibrationType='rescale';
    473459GeometryCalib.fx_fy=[px(1) py(1)];%.fx_fy corresponds to pxcm along x and y
     
    620606run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
    621607if exist('Rc_1','var')
    622     GeometryCalib.CalibrationType='3D_linear';
     608    GeometryCalib.CalibrationType='3D_extrinsic';
    623609    GeometryCalib.fx_fy=fc';
    624610    GeometryCalib.Cx_Cy=cc';
     
    698684
    699685if exist('Rc_1','var')
    700     GeometryCalib.CalibrationType='3D_quadr';
     686    GeometryCalib.CalibrationType='3D_extrinsic';
    701687    GeometryCalib.fx_fy=fc';
    702688    GeometryCalib.Cx_Cy=cc';
     
    11631149
    11641150% --------------------------------------------------------------------
    1165 function MenuFlip_x_Callback(hObject, eventdata, handles)
     1151function MenuFlip_xy_Callback(hObject, eventdata, handles)
    11661152Coord=get(handles.ListCoord,'Data');
    11671153Coord(:,1)=-Coord(:,1);
     1154Coord(:,2)=-Coord(:,2);
    11681155set(handles.ListCoord,'Data',Coord)
    11691156
    11701157% --------------------------------------------------------------------
    1171 function MenuFlip_y_Callback(hObject, eventdata, handles)
     1158function MenuFlip_xz_Callback(hObject, eventdata, handles)
    11721159Coord=get(handles.ListCoord,'Data');
    1173 Coord(:,2)=-Coord(:,2);
     1160Coord(:,1)=-Coord(:,1);
     1161Coord(:,3)=-Coord(:,3);
    11741162set(handles.ListCoord,'Data',Coord)
    11751163
  • trunk/src/phys_XYZ.m

    r1112 r1113  
    7979if isfield(Calib,'R')
    8080    R=(Calib.R)';
    81     R(3)=-R(3);
    82     R(6)=-R(6);
    83     R(9)=-R(9);
     81%     R(3)=-R(3);
     82%     R(6)=-R(6);
     83%     R(9)=-R(9);
    8484    c=Z0virt;
    8585    cvirt=Z0virt;
  • trunk/src/px_XYZ.m

    r1112 r1113  
    5757   
    5858    %camera coordinates
    59     Zphys=-Zphys;%flip z coordinates
     59    Zphys=Zphys;%flip z coordinates
    6060    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);
    6161    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);
  • trunk/src/series.m

    r1108 r1113  
    31433143if get(handles.CheckObject,'Value')
    31443144    SeriesData=get(handles.series,'UserData');
    3145     if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)
     3145    if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)% a projection object is already loaded in the GUI series
    31463146        set(handles.ViewObject,'Value',1)
    31473147        ViewObject_Callback(hObject, eventdata, handles)
    31483148    else
    3149         if ishandle(hset_object)
     3149        if ishandle(hset_object)% a projection object is already displayed in a GUI set_object
    31503150            uistack(hset_object,'top')% show the GUI set_object if opened
    31513151        else
     
    32153215    set(handles.ViewObject,'Value',0)
    32163216    UserData=get(handles.series,'UserData');
     3217    if isfield(UserData,'ProjObject')
    32173218    hset_object=set_object(UserData.ProjObject);
    32183219    set(hset_object,'Name','edit_object_series')
    32193220    set(get(hset_object,'Children'),'Enable','on')
     3221    else
     3222        msgbox_uvmat('ERROR','no projection object available');
     3223    end
    32203224else
    32213225    hset_object=findobj(allchild(0),'Tag','set_object');
  • trunk/src/series/extract_rdvision.m

    r1112 r1113  
    206206                logdir=[Param.OutputSubDir Param.OutputDirExt];
    207207                [success,errormsg] = copyfile(filename_seq,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.seq']); %copy the seq file in the upper folder
     208                if ~success
     209                    disp(errormsg)
     210                end
    208211                [success,errormsg] = copyfile(filename_sqb,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.sqb']); %copy the sqb file in the upper folder
     212                if ~success
     213                    disp(errormsg)
     214                end
    209215                if check_xml
    210216                    [success,errormsg] = copyfile(filexml,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.xml']); %copy the original xml file in the upper folder
     217                if ~success
     218                    disp(errormsg)
     219                end
    211220                else
    212                     errormsg=[filexml ' missing'];
     221                    disp(['error:' filexml ' missing']);
    213222                    return
    214223                end
  • trunk/src/transform_field/FFT2_detrend.m

    r1107 r1113  
    8585        DataOut.ListVarName=[CoordName {VarName}];%list of variables
    8686        DataOut.VarDimName=[CoordName {CoordName}];%list of dimensions for variables
     87        DataOut.VarAttribute{1}.Role='coord_y';
     88        DataOut.VarAttribute{2}.Role='coord_x';
     89        DataOut.VarAttribute{3}.Role='scalar';
    8790        break
    8891    end
  • trunk/src/xml2struct.m

    r1107 r1113  
    8484    case 'char'
    8585        % try to convert to number if the char does not correspond to a function (otherwise str2num calls this function as it uses 'eval')
    86         if exist(ss,'builtin')||exist(ss,'file')% ss corresponds to the name of a builtin Matlab function or a file
    87             out=ss; %reproduce the input string
    88         else
     86%         if exist(ss,'builtin')||exist(ss,'file')% ss corresponds to the name of a builtin Matlab function or a file
     87%             out=ss; %reproduce the input string
     88%         else
    8989            out=str2num(ss);% convert to number or vector (str2num applied to a fct name executes this fct by 'eval', thus this possibility had to be ruled out above
    9090            if isempty(out)
     
    100100                end
    101101            end
    102         end
     102%         end
    103103    case 'cell'
    104104        out={};%default
Note: See TracChangeset for help on using the changeset viewer.