Changeset 1173 for trunk/src


Ignore:
Timestamp:
Feb 25, 2025, 5:52:46 PM (2 weeks ago)
Author:
sommeria
Message:

bug geometry calibration corrected

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r1165 r1173  
    726726
    727727%------------------------------------------------------------------------
    728 function GeometryCalib=calib_3D_extrinsic(Coord,est_dist, Intrinsic)
     728function [GeometryCalib,errormsg]=calib_3D_extrinsic(Coord,est_dist, Intrinsic)
    729729%------------------------------------------------------------------
     730errormsg='';
    730731path_uvmat=which('geometry_calib');% check the path detected for source file uvmat
    731732path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     
    740741ny=str2double(get(hhuvmat.num_Npy,'String'));
    741742x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates
    742 n_ima=1;
     743%n_ima=1;
    743744GeometryCalib.CalibrationType='3D_extrinsic';
    744745fx=Intrinsic.fx;
     
    747748Cy=Intrinsic.Cy;
    748749kc=Intrinsic.kc;
    749 errormsg='';
    750750if isempty(fx)
    751751    errormsg='focal length fx needs to be introduced';
     
    759759if ~isempty(errormsg)
    760760    GeometryCalib=[];
    761     msgbox_uvmat('ERROR',errormsg)
    762     return
     761     msgbox_uvmat('ERROR',errormsg)
     762     return
    763763end
    764764GeometryCalib.fx_fy(1)=fx;
     
    896896%------------------------------------------------------------------------
    897897choice=get(handles.CheckEnableMouse,'Value');
    898 if choice
     898if choice% if button selected
     899    set(handles.CheckEnableMouse,'BackgroundColor',[1 1 0])
    899900    huvmat=findobj(allchild(0),'tag','uvmat');
    900901    if ishandle(huvmat)
     
    907908        set(hhuvmat.MenuRuler,'checked','off')%desactivate ruler
    908909    end
     910    if ~isequal(get(hhuvmat.TransformName,'Value'),1) %active if transform function is activated to return to the raw image
     911        set(hhuvmat.TransformName,'Value',1)
     912        uvmat('TransformName_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
     913        set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' (to sse the whole field)
     914         PLOT_Callback(hObject, eventdata, handles)
     915    end
     916else
     917      set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
    909918end
    910919
     
    12981307    Heading=s.Heading;
    12991308end
     1309checkcoord=false;
    13001310if isfield (s,'GeometryCalib')
    1301 GeometryCalib=s.GeometryCalib;
    1302 fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
    1303 CoordCell={};
    1304 Tabchar={};%default
    1305 val_cal=1;%default
    1306 if ~isempty(GeometryCalib)
    1307     % choose the calibration option
    1308     if isfield(GeometryCalib,'CalibrationType')
    1309         calib_list=get(handles.calib_type,'String');
    1310         for ilist=1:numel(calib_list)
    1311             if strcmp(calib_list{ilist},GeometryCalib.CalibrationType)
    1312                 val_cal=ilist;
    1313                 break
     1311    GeometryCalib=s.GeometryCalib;
     1312    %fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
     1313    %CoordCell={};
     1314    %Tabchar={};%default
     1315    val_cal=1;%default
     1316    if ~isempty(GeometryCalib)
     1317        % choose the calibration option
     1318        if isfield(GeometryCalib,'CalibrationType')
     1319            calib_list=get(handles.calib_type,'String');
     1320            for ilist=1:numel(calib_list)
     1321                if strcmp(calib_list{ilist},GeometryCalib.CalibrationType)
     1322                    val_cal=ilist;
     1323                    break
     1324                end
    13141325            end
    13151326        end
    1316     end
    1317     display_intrinsic(GeometryCalib,handles)%intrinsic param
    1318     %extrinsic param
    1319     if isfield(GeometryCalib,'Tx_Ty_Tz')
    1320         Tx_Ty_Tz=GeometryCalib.Tx_Ty_Tz;
    1321         set(handles.Tx,'String',num2str(GeometryCalib.Tx_Ty_Tz(1),4))
    1322         set(handles.Ty,'String',num2str(GeometryCalib.Tx_Ty_Tz(2),4))
    1323         set(handles.Tz,'String',num2str(GeometryCalib.Tx_Ty_Tz(3),4))
    1324     end
    1325     if isfield(GeometryCalib,'omc')
    1326         set(handles.Phi,'String',num2str(GeometryCalib.omc(1),4))
    1327         set(handles.Theta,'String',num2str(GeometryCalib.omc(2),4))
    1328         set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    1329     end
    1330     if isfield(GeometryCalib,'SourceCalib')&& isfield(GeometryCalib.SourceCalib,'PointCoord')
    1331         calib=GeometryCalib.SourceCalib.PointCoord;
    1332         Coord=[calib zeros(size(calib,1),1)];
    1333         set(handles.ListCoord,'Data',Coord)
    1334     end
    1335     PLOT_Callback(handles.geometry_calib, [], handles)
    1336     set(handles.APPLY,'BackgroundColor',[1 0 1])
    1337 end
    1338 set(handles.calib_type,'Value',val_cal)
    1339 
    1340 if isempty(CoordCell)% allow mouse action by default in the absence of input points
     1327        display_intrinsic(GeometryCalib,handles)%intrinsic param
     1328        %extrinsic param
     1329        if isfield(GeometryCalib,'Tx_Ty_Tz')
     1330            %Tx_Ty_Tz=GeometryCalib.Tx_Ty_Tz;
     1331            set(handles.Tx,'String',num2str(GeometryCalib.Tx_Ty_Tz(1),4))
     1332            set(handles.Ty,'String',num2str(GeometryCalib.Tx_Ty_Tz(2),4))
     1333            set(handles.Tz,'String',num2str(GeometryCalib.Tx_Ty_Tz(3),4))
     1334        end
     1335        if isfield(GeometryCalib,'omc')
     1336            set(handles.Phi,'String',num2str(GeometryCalib.omc(1),4))
     1337            set(handles.Theta,'String',num2str(GeometryCalib.omc(2),4))
     1338            set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
     1339        end
     1340        if isfield(GeometryCalib,'SourceCalib')&& isfield(GeometryCalib.SourceCalib,'PointCoord')
     1341            calib=GeometryCalib.SourceCalib.PointCoord;
     1342            Coord=[calib zeros(size(calib,1),1)];
     1343            set(handles.ListCoord,'Data',Coord)
     1344            checkcoord=true;
     1345        end
     1346        PLOT_Callback(handles.geometry_calib, [], handles)
     1347        set(handles.APPLY,'BackgroundColor',[1 0 1])
     1348    end
     1349    set(handles.calib_type,'Value',val_cal)
     1350end   
     1351if checkcoord % does not allow mouse action by default in the presence of input points
     1352    set(handles.CheckEnableMouse,'Value',0)
     1353    set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
     1354else   % allow mouse action by default in the absence of input points
    13411355    set(handles.CheckEnableMouse,'Value',1)
    13421356    set(handles.CheckEnableMouse,'BackgroundColor',[1 1 0])
    1343 else % does not allow mouse action by default in the presence of input points
    1344     set(handles.CheckEnableMouse,'Value',0)
    1345     set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
    1346 end
    1347 end
     1357end
     1358
    13481359%------------------------------------------------------------------------
    13491360%---display calibration intrinsic parameters
     
    14561467Coord=get(handles.ListCoord,'Data');
    14571468iline=eventdata.Indices(1);% selected line number
    1458 if size(Coord,1)<iline+numel(Input)
     1469if numel(Input)>1 && size(Coord,1)<iline+numel(Input)
    14591470    Coord=[Coord ; zeros(iline+numel(Input)-size(Coord,1),6)];% append zeros to fit the new column
    14601471end
  • trunk/src/mouse_down.m

    r1172 r1173  
    485485    h_CheckEnableMouse=hh_geometry_calib.CheckEnableMouse;
    486486    if isequal(get(h_CheckEnableMouse,'Value'),1) && ~isempty(haxes)
    487         if ~isequal(get(hhuvmat.TransformName,'Value'),1); %active only with no transform (px coordinates)
     487        if ~isequal(get(hhuvmat.TransformName,'Value'),1) %active only with no transform (px coordinates)
    488488            set(hhuvmat.TransformName,'Value',1)
    489489            uvmat('TransformName_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
     
    493493        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
    494494        Coord=get(h_ListCoord,'Data');
    495         Coord=Coord(:,1:6);
     495        if size(Coord,2)>6
     496        Coord(:,7:end)=[];
     497        end
    496498        %data=read_geometry_calib(Coord);%transform char cell to numbers
    497499        xlim=get(haxes,'XLim');
Note: See TracChangeset for help on using the changeset viewer.