Ignore:
Timestamp:
Sep 2, 2013, 7:44:19 PM (11 years ago)
Author:
sommeria
Message:

various bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r680 r682  
    5050% Edit the above text to modify the response to help geometry_calib
    5151
    52 % Last Modified by GUIDE v2.5 31-Jul-2013 23:03:18
     52% Last Modified by GUIDE v2.5 02-Sep-2013 16:47:27
    5353
    5454% Begin initialization code - DO NOT edit
     
    147147end
    148148
    149 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
    150 
    151 
    152149%------------------------------------------------------------------------
    153150% --- Outputs from this function are returned to the command line.
     
    181178%------------------------------------------------------------------------
    182179%% look for the GUI uvmat and check for an image as input
     180set(handles.APPLY,'BackgroundColor',[1 1 0])
    183181huvmat=findobj(allchild(0),'Name','uvmat');
    184182hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
     
    198196[GeometryCalib,index]=calibrate(handles,hhuvmat);% apply calibration
    199197
    200 %% copy the xml file from the old location if appropriate, then update with the calibration parameters
    201 if ~exist(outputfile,'file') && ~isempty(SubDirBase)
    202     oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml'];
    203     if exist(oldxml,'file')
    204         [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention
    205     end
    206 end
    207 errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file
    208 if ~strcmp(errormsg,'')
    209     msgbox_uvmat('ERROR',errormsg);
    210 end
    211 
    212 %% display image with new calibration in the currently opened uvmat interface
    213 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers
    214 if ~isempty(hhh)
    215     delete(hhh);
    216 end
    217 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points');
    218 if ~isempty(hhh)
    219     delete(hhh);
    220 end
    221 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off'
    222 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
    223 UserData=get(handles.geometry_calib,'UserData');
    224 UserData.XmlInputFile=outputfile;%save the current xml file name
    225 set(handles.geometry_calib,'UserData',UserData)
    226 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    227 PLOT_Callback(hObject, eventdata, handles)
    228 Data=get(handles.ListCoord,'Data');
    229 Data(:,6)=zeros(size(Data,1),1);
    230 Data(index,6)=1;% indicate in the list the point with max deviation (possible mistake)
    231 set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake)
    232 figure(handles.geometry_calib)
     198if isempty(GeometryCalib) % if calibration cancelled
     199    set(handles.APPLY,'BackgroundColor',[1 0 1])
     200else   % if calibration confirmed
     201   
     202    %% copy the xml file from the old location if appropriate, then update with the calibration parameters
     203    if ~exist(outputfile,'file') && ~isempty(SubDirBase)
     204        oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml'];
     205        if exist(oldxml,'file')
     206            [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention
     207        end
     208    end
     209    errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file
     210    if ~strcmp(errormsg,'')
     211        msgbox_uvmat('ERROR',errormsg);
     212    end
     213   
     214    %% display image with new calibration in the currently opened uvmat interface
     215    hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers
     216    if ~isempty(hhh)
     217        delete(hhh);
     218    end
     219    hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points');
     220    if ~isempty(hhh)
     221        delete(hhh);
     222    end
     223    set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off'
     224    set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     225    UserData=get(handles.geometry_calib,'UserData');
     226    UserData.XmlInputFile=outputfile;%save the current xml file name
     227    set(handles.geometry_calib,'UserData',UserData)
     228    uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     229    PLOT_Callback(hObject, eventdata, handles)
     230    Data=get(handles.ListCoord,'Data');
     231    Data(:,6)=zeros(size(Data,1),1);
     232    Data(index,6)=1;% indicate in the list the point with max deviation (possible mistake)
     233    set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake)
     234    figure(handles.geometry_calib)
     235    set(handles.APPLY,'BackgroundColor',[1 0 0])
     236end
    233237
    234238%------------------------------------------------------------------------
     
    348352%% get plane position(s)
    349353if ~strcmp(answer,'Yes')
     354    GeometryCalib=[];
     355    index=1;
    350356    return
    351357end
     
    773779set(handles.ListCoordFiles,'String',{''})
    774780
    775 % %------------------------------------------------------------------------
    776 % function XObject_Callback(hObject, eventdata, handles)
    777 % %------------------------------------------------------------------------
    778 % update_list(hObject, eventdata,handles)
    779 %
    780 % %------------------------------------------------------------------------
    781 % function YObject_Callback(hObject, eventdata, handles)
    782 % %------------------------------------------------------------------------
    783 % update_list(hObject, eventdata,handles)
    784 %
    785 % %------------------------------------------------------------------------
    786 % function ZObject_Callback(hObject, eventdata, handles)
    787 % %------------------------------------------------------------------------
    788 % update_list(hObject, eventdata,handles)
    789 %
    790 % %------------------------------------------------------------------------
    791 % function update_list(hObject, eventdata, handles)
    792 % %------------------------------------------------------------------------
    793 % newval(4)=str2double(get(handles.XImage,'String'));
    794 % newval(5)=str2double(get(handles.YImage,'String'));
    795 % newval(1)=str2double(get(handles.XObject,'String'));
    796 % newval(2)=str2double(get(handles.YObject,'String'));
    797 % newval(3)=str2double(get(handles.ZObject,'String'));
    798 % if isnan(newval(3))
    799 %     newval(3)=0;%put z to 0 by default
    800 % end
    801 % Coord=get(handles.ListCoord,'String');
    802 % Coord(end)=[]; %remove last string '.....'
    803 % val=get(handles.ListCoord,'Value');
    804 % data=read_geometry_calib(Coord);
    805 % data.Coord(val,:)=newval;
    806 % for i=1:size(data.Coord,1)
    807 %     for j=1:5
    808 %           Coord_cell{i,j}=num2str(data.Coord(i,j),4);%display coordiantes with 4 digits
    809 %     end
    810 % end
    811 %
    812 % Tabchar=cell2tab(Coord_cell,' | ');
    813 % Tabchar=[Tabchar ;{'......'}];
    814 % set(handles.ListCoord,'String',Tabchar)
    815 %
    816 % %update the plot
    817 % ListCoord_Callback(hObject, eventdata, handles)
    818 % PLOT_Callback(hObject, eventdata, handles)
    819 
    820781%------------------------------------------------------------------------
    821782% --- Executes on selection change in CheckEnableMouse.
     
    836797    set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
    837798end
    838    
    839 % function NEW_Callback(hObject, eventdata, handles)
    840 % %A METTRE SOUS UN BOUTON
    841 % huvmat=findobj(allchild(0),'Name','uvmat');
    842 % hchild=get(huvmat,'children');
    843 % hcoord=findobj(hchild,'Tag','menu_coord');
    844 % coordtype=get(hcoord,'Value');
    845 % haxes=findobj(hchild,'Tag','axes3');
    846 % AxeData=get(haxes,'UserData');
    847 % if ~isequal(hcoord,2)
    848 %     set(hcoord,'Value',2)
    849 %     huvmat=uvmat(AxeData);
    850 %     'relancer uvmat';
    851 % end
    852 % if ~isfield(AxeData,'ZoomAxes')
    853 %     msgbox_uvmat('ERROR','first draw a window around a grid marker')
    854 %     return
    855 % end
    856 % XLim=get(AxeData.ZoomAxes,'XLim');
    857 % YLim=get(AxeData.ZoomAxes,'YLim');
    858 % np=size(AxeData.A);
    859 % ind_sub_x=round(XLim);
    860 % ind_sub_y=np(1)-round(YLim);
    861 % Mfiltre=AxeData.A(ind_sub_y(2):ind_sub_y(1) ,ind_sub_x,:);
    862 % Mfiltre_norm=double(Mfiltre);
    863 % Mfiltre_norm=Mfiltre_norm/sum(sum(Mfiltre_norm));
    864 % Mfiltre_norm=100*(Mfiltre_norm-mean(mean(Mfiltre_norm)));
    865 % Atype=class(AxeData.A);
    866 % Data.NbDim=2;
    867 % Data.A=filter2(Mfiltre_norm,double(AxeData.A));
    868 % Data.A=feval(Atype,Data.A);
    869 % Data.AName='image';
    870 % Data.AX=AxeData.AX;
    871 % Data.AY=AxeData.AY;
    872 % Data.CoordType='px';
    873 % plot_field(Data)
    874799
    875800
     
    887812% --------------------------------------------------------------------
    888813function MenuSetScale_Callback(hObject, eventdata, handles)
    889 % hObject    handle to MenuSetScale (see GCBO)
    890 % eventdata  reserved - to be defined in a future version of MATLAB
    891 % handles    structure with handles and user data (see GUIDATA)
    892  answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','')
     814
     815 answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','');
    893816 %create test points
    894817 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
     
    902825Coord=[x y zeros(4,1) Xima Yima zeros(4,1)];
    903826set(handles.ListCoord,'Data',Coord)
     827set(handles.APPLY,'BackgroundColor',[1 0 1])
    904828
    905829%------------------------------------------------------------------------
     
    918842Coord(1:size(T,1),1:3)=T;%update the existing list of phys coordinates from the GUI create_grid
    919843set(handles.ListCoord,'Data',Coord)
     844set(handles.APPLY,'BackgroundColor',[1 0 1])
    920845
    921846% -----------------------------------------------------------------------
     
    952877[T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
    953878set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use
    954 
    955 
    956879
    957880%% read the current image, displayed in the GUI uvmat
     
    1051974set(handles.ListCoord,'Data',Coord)
    1052975PLOT_Callback(hObject, eventdata, handles)
     976set(handles.APPLY,'BackgroundColor',[1 0 1])
    1053977
    1054978%-----------------------------------------------------------------------
     
    1070994Coord(:,3)=T(3)+Coord(:,3);
    1071995set(handles.ListCoord,'Data',Coord);
     996set(handles.APPLY,'BackgroundColor',[1 0 1])
    1072997
    1073998% --------------------------------------------------------------------
     
    11031028Coord(:,2)=r3*x+r4*y;
    11041029set(handles.ListCoord,'Data',Coord)
     1030set(handles.APPLY,'BackgroundColor',[1 0 1])
    11051031
    11061032% --------------------------------------------------------------------
     
    11161042set(handles.ListCoord,'Data',Coord)
    11171043PLOT_Callback(handles.geometry_calib, [], handles)
     1044set(handles.APPLY,'BackgroundColor',[1 0 1])
    11181045
    11191046% -----------------------------------------------------------------------
     
    11871114    Heading=s.Heading;
    11881115end
    1189    
     1116
    11901117GeometryCalib=s.GeometryCalib;
    11911118fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
     
    11961123    % choose the calibration option
    11971124    if isfield(GeometryCalib,'CalibrationType')
    1198        calib_list=get(handles.calib_type,'String');
    1199        for ilist=1:numel(calib_list)
    1200            if strcmp(calib_list{ilist},GeometryCalib.CalibrationType)
    1201                val_cal=ilist;
    1202                break
    1203            end
    1204        end
     1125        calib_list=get(handles.calib_type,'String');
     1126        for ilist=1:numel(calib_list)
     1127            if strcmp(calib_list{ilist},GeometryCalib.CalibrationType)
     1128                val_cal=ilist;
     1129                break
     1130            end
     1131        end
    12051132    end
    12061133    display_intrinsic(GeometryCalib,handles)%intrinsic param
     
    12181145    end
    12191146    if isfield(GeometryCalib,'SourceCalib')
    1220     calib=GeometryCalib.SourceCalib.PointCoord;
    1221     Coord=[calib zeros(size(calib,1),1)];
    1222     set(handles.ListCoord,'Data',Coord)
    1223     end
    1224 %     CoordCell=reshape(CoordCell,[],5);
    1225 %     Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
     1147        calib=GeometryCalib.SourceCalib.PointCoord;
     1148        Coord=[calib zeros(size(calib,1),1)];
     1149        set(handles.ListCoord,'Data',Coord)
     1150    end
    12261151    PLOT_Callback(handles.geometry_calib, [], handles)
     1152    set(handles.APPLY,'BackgroundColor',[1 0 1])
    12271153end
    12281154set(handles.calib_type,'Value',val_cal)
     
    13471273% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
    13481274%------------------------------------------------------------------------
    1349 function key_press_fcn(hObject,eventdata,handles)
    1350 
     1275function ListCoord_KeyPressFcn(hObject, eventdata, handles)
    13511276xx=double(get(handles.geometry_calib,'CurrentCharacter'));%get the keyboard character
    1352 %if ismember(xx,[8 127])%backspace or delete
    13531277if ismember(xx,[30 31 127])% arrow upward, downward, or delete
    13541278    Coord=get(handles.ListCoord,'Data');
     
    13631287            Coord(ind,:)=[];
    13641288            PLOT_Callback(hObject,eventdata,handles)
     1289            set(handles.APPLY,'BackgroundColor',[1 0 1])
     1290        otherwise
    13651291    end
    13661292    set(handles.ListCoord,'Data',Coord);
    1367 end
    1368 
     1293else
     1294    set(handles.APPLY,'BackgroundColor',[1 0 1])
     1295end
    13691296
    13701297
Note: See TracChangeset for help on using the changeset viewer.