Changeset 494 for trunk/src/geometry_calib.m
- Timestamp:
- Jul 19, 2012, 11:50:39 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r444 r494 91 91 %set the position of the interface 92 92 if exist('pos','var')&& length(pos)>=4 93 % %pos_gui=get(hObject,'Position');94 % pos_gui(1)=pos(1);95 % pos_gui(2)=pos(2);96 93 set(hObject,'Position',pos); 97 94 end … … 99 96 %set menu of calibration options 100 97 set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'}) 101 % inputxml='';102 98 if exist('inputfile','var')&& ~isempty(inputfile) 103 99 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); 106 101 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 108 112 end 109 113 set(handles.ListCoord,'String',{'......'}) 110 114 if exist(inputfile,'file') 111 Heading=loadfile(handles,inputfile);% load the point coordi antes existing in the xml file115 Heading=loadfile(handles,inputfile);% load the point coordinates existing in the xml file 112 116 if isfield(Heading,'Campaign')&& ischar(Heading.Campaign) 113 117 struct.Campaign=Heading.Campaign; … … 190 194 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 191 195 [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima)); 192 [ ~,ind_dim]=max(GeometryCalib.ErrorMax);196 [tild,ind_dim]=max(GeometryCalib.ErrorMax); 193 197 index=index(ind_dim); 194 198 %set the Z position of the reference plane used for calibration … … 1257 1261 set(handles.ListCoord,'String',Tabchar) 1258 1262 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 phys1275 %INPUT:1276 %Zindex: index of plane1277 % 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 corners1287 % yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];1288 % [xcorner,ycorner]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates1289 % 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 coordiantes1299 % vec_B=[];1300 %1301 % zphys=0; %default1302 % if isfield(Calib,'SliceCoord') %.Z= index of plane1303 % SliceCoord=Calib.SliceCoord(ZIndex,:);1304 % zphys=SliceCoord(3); %to generalize for non-parallel planes1305 % end1306 % [XIMA,YIMA]=px_XYZ(Calib,X,Y,zphys);%corresponding image indices for each point in the real space grid1307 % 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 image1310 % 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 line1314 % 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_A1318 % 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 coordinates1321 % elseif numel(siz)==31322 % for icolor=1:siz(3)1323 % vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line1324 % 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_A1328 % 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 coordinates1331 % end1332 % end1333 % if testuint81334 % A_out=uint8(A_out);1335 % end1336 % if testuint161337 % A_out=uint16(A_out);1338 % end1339 1340 %------------------------------------------------------------------------1341 % pointwise transform from px to phys1342 %INPUT:1343 %Z: index of plane1344 % 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)>=Z1347 % Zindex=Z;1348 % Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE1349 % else1350 % Zphys=0;1351 % end1352 % if ~exist('X','var')||~exist('Y','var')1353 % Xphys=[];1354 % Yphys=[];%default1355 % return1356 % end1357 % Xphys=X;%default1358 % Yphys=Y;1359 % %image transform1360 % 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 coordinates1379 % Yd=Calib.dpy*(Y-Calib.Cy);1380 % dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor1381 % Xu=dist_fact.*Xd;%undistorted sensor coordinates1382 % Yu=dist_fact.*Yd;1383 % denom=Dx*Xu+Dy*Yu+D0;1384 % % denom2=denom.*denom;1385 % Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates1386 % Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;1387 % end1388 1389 1390 1263 % -------------------------------------------------------------------- 1391 1264 function MenuImportPoints_Callback(hObject, eventdata, handles)
Note: See TracChangeset
for help on using the changeset viewer.