Ignore:
Timestamp:
Jul 19, 2012, 11:50:39 AM (12 years ago)
Author:
sommeria
Message:

various bugs corrected after testing in Windows OS. Introduction
of filter tps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r444 r494  
    9191%set the position of the interface
    9292if exist('pos','var')&& length(pos)>=4
    93 %     %pos_gui=get(hObject,'Position');
    94 %     pos_gui(1)=pos(1);
    95 %     pos_gui(2)=pos(2);
    9693    set(hObject,'Position',pos);
    9794end
     
    9996%set menu of calibration options
    10097set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'})
    101 % inputxml='';
    10298if exist('inputfile','var')&& ~isempty(inputfile)
    10399    struct.XmlInputFile=inputfile;
    104 %     [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile);
    105     [RootPath,~,RootFile,~,~,~,~,FileExt]=fileparts_uvmat(inputfile);
     100    [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(inputfile);
    106101    if ~strcmp(FileExt,'.xml')
    107         inputfile=[fullfile(RootPath,RootFile) '.xml'];%xml file corresponding to the input file
     102        inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file
     103        if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir
     104            inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
     105            if ~exist(inputfile,'file')
     106                inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention
     107                if ~exist(inputfile,'file')
     108                    inputfile='';
     109                end
     110            end
     111        end
    108112    end
    109113    set(handles.ListCoord,'String',{'......'})
    110114    if exist(inputfile,'file')
    111         Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
     115        Heading=loadfile(handles,inputfile);% load the point coordinates existing in the xml file
    112116        if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
    113117            struct.Campaign=Heading.Campaign;
     
    190194    GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
    191195    [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima));
    192     [~,ind_dim]=max(GeometryCalib.ErrorMax);
     196    [tild,ind_dim]=max(GeometryCalib.ErrorMax);
    193197    index=index(ind_dim);
    194198    %set the Z position of the reference plane used for calibration
     
    12571261set(handles.ListCoord,'String',Tabchar)
    12581262
    1259 
    1260 % %------------------------------------------------------------------------
    1261 % % --- Executes on button press in rotation.
    1262 % function rotation_Callback(hObject, eventdata, handles)
    1263 % %------------------------------------------------------------------------
    1264 % angle_rot=(pi/180)*str2num(get(handles.Phi,'String'));
    1265 % Coord_cell=get(handles.ListCoord,'String');
    1266 % data=read_geometry_calib(Coord_cell);
    1267 % data.Coord(:,1)=cos(angle_rot)*data.Coord(:,1)+sin(angle_rot)*data.Coord(:,2);
    1268 % data.Coord(:,1)=-sin(angle_rot)*data.Coord(:,1)+cos(angle_rot)*data.Coord(:,2);
    1269 % set(handles.XObject,'String',num2str(data.Coord(:,1),4));
    1270 % set(handles.YObject,'String',num2str(data.Coord(:,2),4));
    1271 
    1272 
    1273 %------------------------------------------------------------------------
    1274 % image transform from px to phys
    1275 %INPUT:
    1276 %Zindex: index of plane
    1277 % function [A_out,Rangx,Rangy]=phys_Ima(A,Calib,ZIndex)
    1278 % %------------------------------------------------------------------------
    1279 % xcorner=[];
    1280 % ycorner=[];
    1281 % npx=[];
    1282 % npy=[];
    1283 % siz=size(A)
    1284 % npx=[npx siz(2)];
    1285 % npy=[npy siz(1)]
    1286 % xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners
    1287 % yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
    1288 % [xcorner,ycorner]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates
    1289 % Rangx(1)=min(xcorner);
    1290 % Rangx(2)=max(xcorner);
    1291 % Rangy(2)=min(ycorner);
    1292 % Rangy(1)=max(ycorner);
    1293 % test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy));
    1294 % npx=max(npx);
    1295 % npy=max(npy);
    1296 % x=linspace(Rangx(1),Rangx(2),npx);
    1297 % y=linspace(Rangy(1),Rangy(2),npy);
    1298 % [X,Y]=meshgrid(x,y);%grid in physical coordiantes
    1299 % vec_B=[];
    1300 %
    1301 % zphys=0; %default
    1302 % if isfield(Calib,'SliceCoord') %.Z= index of plane
    1303 %    SliceCoord=Calib.SliceCoord(ZIndex,:);
    1304 %    zphys=SliceCoord(3); %to generalize for non-parallel planes
    1305 % end
    1306 % [XIMA,YIMA]=px_XYZ(Calib,X,Y,zphys);%corresponding image indices for each point in the real space grid
    1307 % XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
    1308 % YIMA=reshape(round(YIMA),1,npx*npy);
    1309 % flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
    1310 % testuint8=isa(A,'uint8');
    1311 % testuint16=isa(A,'uint16');
    1312 % if numel(siz)==2 %(B/W images)
    1313 %     vec_A=reshape(A,1,npx*npy);%put the original image in line
    1314 %     ind_in=find(flagin);
    1315 %     ind_out=find(~flagin);
    1316 %     ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
    1317 %     ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
    1318 %     vec_B(ind_in)=vec_A(ICOMB);
    1319 %     vec_B(ind_out)=zeros(size(ind_out));
    1320 %     A_out=reshape(vec_B,npy,npx);%new image in real coordinates
    1321 % elseif numel(siz)==3     
    1322 %     for icolor=1:siz(3)
    1323 %         vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line
    1324 %         ind_in=find(flagin);
    1325 %         ind_out=find(~flagin);
    1326 %         ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
    1327 %         ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
    1328 %         vec_B(ind_in)=vec_A(ICOMB);
    1329 %         vec_B(ind_out)=zeros(size(ind_out));
    1330 %         A_out(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates
    1331 %     end
    1332 % end
    1333 % if testuint8
    1334 %     A_out=uint8(A_out);
    1335 % end
    1336 % if testuint16
    1337 %     A_out=uint16(A_out);
    1338 % end
    1339 
    1340 %------------------------------------------------------------------------
    1341 % pointwise transform from px to phys
    1342 %INPUT:
    1343 %Z: index of plane
    1344 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)
    1345 % %------------------------------------------------------------------------
    1346 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'SliceCoord')&length(Calib.SliceCoord)>=Z
    1347 %     Zindex=Z;
    1348 %     Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE
    1349 % else
    1350 %     Zphys=0;
    1351 % end
    1352 % if ~exist('X','var')||~exist('Y','var')
    1353 %     Xphys=[];
    1354 %     Yphys=[];%default
    1355 %     return
    1356 % end
    1357 % Xphys=X;%default
    1358 % Yphys=Y;
    1359 % %image transform
    1360 % if isfield(Calib,'R')
    1361 %     R=(Calib.R)';
    1362 %     Dx=R(5)*R(7)-R(4)*R(8);
    1363 %     Dy=R(1)*R(8)-R(2)*R(7);
    1364 %     D0=Calib.f*(R(2)*R(4)-R(1)*R(5));
    1365 %     Z11=R(6)*R(8)-R(5)*R(9);
    1366 %     Z12=R(2)*R(9)-R(3)*R(8); 
    1367 %     Z21=R(4)*R(9)-R(6)*R(7);
    1368 %     Z22=R(3)*R(7)-R(1)*R(9);
    1369 %     Zx0=R(3)*R(5)-R(2)*R(6);
    1370 %     Zy0=R(1)*R(6)-R(3)*R(4);
    1371 %     A11=R(8)*Calib.Ty-R(5)*Calib.Tz+Z11*Zphys;
    1372 %     A12=R(2)*Calib.Tz-R(8)*Calib.Tx+Z12*Zphys;
    1373 %     A21=-R(7)*Calib.Ty+R(4)*Calib.Tz+Z21*Zphys;
    1374 %     A22=-R(1)*Calib.Tz+R(7)*Calib.Tx+Z11*Zphys;
    1375 %     X0=Calib.f*(R(5)*Calib.Tx-R(2)*Calib.Ty+Zx0*Zphys);
    1376 %     Y0=Calib.f*(-R(4)*Calib.Tx+R(1)*Calib.Ty+Zy0*Zphys);
    1377 %         %px to camera:
    1378 %     Xd=(Calib.dpx/Calib.sx)*(X-Calib.Cx); % sensor coordinates
    1379 %     Yd=Calib.dpy*(Y-Calib.Cy);
    1380 %     dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor
    1381 %     Xu=dist_fact.*Xd;%undistorted sensor coordinates
    1382 %     Yu=dist_fact.*Yd;
    1383 %     denom=Dx*Xu+Dy*Yu+D0;
    1384 %     % denom2=denom.*denom;
    1385 %     Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates
    1386 %     Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;
    1387 % end
    1388 
    1389 
    13901263% --------------------------------------------------------------------
    13911264function MenuImportPoints_Callback(hObject, eventdata, handles)
Note: See TracChangeset for help on using the changeset viewer.