Changeset 84 for trunk/src/geometry_calib.m
- Timestamp:
- Apr 24, 2010, 2:07:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r83 r84 160 160 case 'tsai' 161 161 set(handles.calib_type,'Value',3) 162 case 'tsai_matlab' 163 set(handles.calib_type,'Value',4) 162 164 end 163 165 end … … 255 257 Coord_cell=get(handles.ListCoord,'String'); 256 258 Object=read_geometry_calib(Coord_cell); 257 259 X=Object.Coord(:,1); 260 Y=Object.Coord(:,2); 261 Z=Object.Coord(:,3); 258 262 if isequal(calib_type,'rescale') 259 263 GeometryCalib=calib_rescale(Object.Coord); 264 Z=0;%Z not taken into account 260 265 elseif isequal(calib_type,'linear') 261 266 GeometryCalib=calib_linear(Object.Coord); 267 Z=0; %Z not taken into account 262 268 elseif isequal(calib_type,'tsai_cpp') 263 269 GeometryCalib=calib_tsai(Object.Coord); … … 265 271 GeometryCalib=calib_tsai2(Object.Coord); 266 272 end 273 274 %check error 275 if isfield(GeometryCalib,'dpx_dpy') 276 Calib.dpx=GeometryCalib.dpx_dpy(1); 277 Calib.dpy=GeometryCalib.dpx_dpy(2); 278 end 279 if isfield(GeometryCalib,'sx') 280 Calib.sx=GeometryCalib.sx; 281 end 282 if isfield(GeometryCalib,'Cx_Cy') 283 Calib.Cx=GeometryCalib.Cx_Cy(1); 284 Calib.Cy=GeometryCalib.Cx_Cy(2); 285 end 286 if isfield(GeometryCalib,'kappa1') 287 Calib.kappa1=GeometryCalib.kappa1; 288 end 289 if isfield(GeometryCalib,'focal') 290 Calib.f=GeometryCalib.focal; 291 end 292 if isfield(GeometryCalib,'Tx_Ty_Tz') 293 Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 294 Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 295 Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 296 end 297 if isfield(GeometryCalib,'R') 298 Calib.R=GeometryCalib.R; 299 end 300 x_ima=Object.Coord(:,4); 301 y_ima=Object.Coord(:,5); 302 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 303 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 304 [GeometryCalib.ErrorMax(1),index(1)]=max(abs(Xpoints-x_ima)); 305 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 306 [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima)); 307 [EM,ind_dim]=max(GeometryCalib.ErrorMax); 308 index=index(ind_dim); 309 267 310 unitlist=get(handles.CoordUnit,'String'); 268 311 unit=unitlist{get(handles.CoordUnit,'value')}; … … 286 329 outputfile=answer{1}; 287 330 end 288 update_imadoc(GeometryCalib,outputfile) 289 msgbox_uvmat('CONFIRMATION',{[outputfile ' updated with calibration data'];... 331 answer=msgbox_uvmat('INPUT_Y-N',{[outputfile ' updated with calibration data'];... 290 332 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 291 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']}) 292 293 %display image with new calibration in the currently opened uvmat interface 294 hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers 295 if ~isempty(hhh) 296 delete(hhh); 297 end 298 hhh=findobj(hhuvmat.axes3,'Tag','calib_points'); 299 if ~isempty(hhh) 300 delete(hhh); 301 end 302 set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off' 303 set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 304 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat 305 MenuPlot_Callback(hObject, eventdata, handles) 306 figure(handles.geometry_calib) 333 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']}); 334 if isequal(answer,'Yes') 335 update_imadoc(GeometryCalib,outputfile) 336 %display image with new calibration in the currently opened uvmat interface 337 hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers 338 if ~isempty(hhh) 339 delete(hhh); 340 end 341 hhh=findobj(hhuvmat.axes3,'Tag','calib_points'); 342 if ~isempty(hhh) 343 delete(hhh); 344 end 345 set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off' 346 set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 347 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat 348 MenuPlot_Callback(hObject, eventdata, handles) 349 set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake) 350 ListCoord_Callback(hObject, eventdata, handles) 351 figure(handles.geometry_calib) 352 end 307 353 308 354 %------------------------------------------------------------------ … … 395 441 GeometryCalib.R=[px(1),0,0;0,py(1),0;0,0,1]; 396 442 397 % check error398 Calib.dpx=1;399 Calib.dpy=1;400 Calib.sx=1;401 Calib.Cx=0;402 Calib.Cy=0;403 Calib.Tz=1;404 Calib.kappa1=0;405 Calib.f=GeometryCalib.focal;406 Calib.Tx=T_x;407 Calib.Ty=T_y;408 Calib.R=GeometryCalib.R;409 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,0);410 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));411 GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));412 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));413 GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima));443 % %check error 444 % Calib.dpx=1; 445 % Calib.dpy=1; 446 % Calib.sx=1; 447 % Calib.Cx=0; 448 % Calib.Cy=0; 449 % Calib.Tz=1; 450 % Calib.kappa1=0; 451 % Calib.f=GeometryCalib.focal; 452 % Calib.Tx=T_x; 453 % Calib.Ty=T_y; 454 % Calib.R=GeometryCalib.R; 455 % [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,0); 456 % GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 457 % GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima)); 458 % GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 459 % GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima)); 414 460 415 461 %------------------------------------------------------------------------ … … 436 482 GeometryCalib.R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,1]; 437 483 438 % check error439 GeometryCalib.ErrorRms(1)=sqrt(mean((x1-x_ima).*(x1-x_ima)));440 GeometryCalib.ErrorMax(1)=max(abs(x1-x_ima));441 GeometryCalib.ErrorRms(2)=sqrt(mean((y1-y_ima).*(y1-y_ima)));442 GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima));484 % %check error 485 % GeometryCalib.ErrorRms(1)=sqrt(mean((x1-x_ima).*(x1-x_ima))); 486 % GeometryCalib.ErrorMax(1)=max(abs(x1-x_ima)); 487 % GeometryCalib.ErrorRms(2)=sqrt(mean((y1-y_ima).*(y1-y_ima))); 488 % GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima)); 443 489 444 490 %------------------------------------------------------------------------ … … 463 509 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim')); 464 510 465 GeometryCalib.CalibrationType='tsai ';511 GeometryCalib.CalibrationType='tsai_matlab'; 466 512 GeometryCalib.focal=f(2); 467 513 GeometryCalib.dpx_dpy=[1 1]; … … 472 518 GeometryCalib.Tx_Ty_Tz=Tc_1'; 473 519 GeometryCalib.R=Rc_1; 474 Calib.dpx=GeometryCalib.dpx_dpy(1);475 Calib.dpy=GeometryCalib.dpx_dpy(2);476 Calib.sx=GeometryCalib.sx;477 Calib.Cx=GeometryCalib.Cx_Cy(1);478 Calib.Cy=GeometryCalib.Cx_Cy(2);479 Calib.kappa1=GeometryCalib.kappa1;480 Calib.f=GeometryCalib.focal;481 Calib.Tx=GeometryCalib.Tx_Ty_Tz(1);482 Calib.Ty=GeometryCalib.Tx_Ty_Tz(2);483 Calib.Tz=GeometryCalib.Tx_Ty_Tz(3);484 Calib.R=GeometryCalib.R;485 X=Coord(:,1);486 Y=Coord(:,2);487 Z=Coord(:,3);488 x_ima=Coord(:,4);489 y_ima=Coord(:,5);490 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z);491 492 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));493 GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));494 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));495 GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima));520 % Calib.dpx=GeometryCalib.dpx_dpy(1); 521 % Calib.dpy=GeometryCalib.dpx_dpy(2); 522 % Calib.sx=GeometryCalib.sx; 523 % Calib.Cx=GeometryCalib.Cx_Cy(1); 524 % Calib.Cy=GeometryCalib.Cx_Cy(2); 525 % Calib.kappa1=GeometryCalib.kappa1; 526 % Calib.f=GeometryCalib.focal; 527 % Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 528 % Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 529 % Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 530 % Calib.R=GeometryCalib.R; 531 % X=Coord(:,1); 532 % Y=Coord(:,2); 533 % Z=Coord(:,3); 534 % x_ima=Coord(:,4); 535 % y_ima=Coord(:,5); 536 % [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 537 % 538 % GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 539 % [GeometryCalib.ErrorMax(1),GeometryCalib.IndexMax(1)]=max(abs(Xpoints-x_ima)); 540 % GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 541 % [GeometryCalib.ErrorMax(2),GeometryCalib.IndexMax(2)]=max(abs(Ypoints-y_ima)); 496 542 497 543 function GeometryCalib=calib_tsai(Coord) … … 558 604 GeometryCalib.R=[r1,r2,r3;r4,r5,r6;r7,r8,r9]; 559 605 %erreur a caracteriser? 560 %check error 561 Calib.dpx=GeometryCalib.dpx_dpy(1); 562 Calib.dpy=GeometryCalib.dpx_dpy(2); 563 Calib.sx=GeometryCalib.sx; 564 Calib.Cx=GeometryCalib.Cx_Cy(1); 565 Calib.Cy=GeometryCalib.Cx_Cy(2); 566 Calib.kappa1=GeometryCalib.kappa1; 567 Calib.f=GeometryCalib.focal; 568 Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 569 Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 570 Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 571 Calib.R=GeometryCalib.R; 572 X=Coord(:,1); 573 Y=Coord(:,2); 574 Z=Coord(:,3); 575 x_ima=Coord(:,4); 576 y_ima=Coord(:,5); 577 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 578 579 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 580 GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima)); 581 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 582 GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima)); 583 % Nfx 584 % dx 585 % dy 586 % 5 dpx 587 % 6 dpy 588 % cx 589 % cy 590 % sx 591 % f 592 % kappa1 593 % tx 594 % ty 595 % tz 596 % rx 597 % ry 598 % rz 599 % p1 600 % p2 601 602 %calibcoeff=str2num(calibdat) 606 % %check error 607 % Calib.dpx=GeometryCalib.dpx_dpy(1); 608 % Calib.dpy=GeometryCalib.dpx_dpy(2); 609 % Calib.sx=GeometryCalib.sx; 610 % Calib.Cx=GeometryCalib.Cx_Cy(1); 611 % Calib.Cy=GeometryCalib.Cx_Cy(2); 612 % Calib.kappa1=GeometryCalib.kappa1; 613 % Calib.f=GeometryCalib.focal; 614 % Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 615 % Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 616 % Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 617 % Calib.R=GeometryCalib.R; 618 % X=Coord(:,1); 619 % Y=Coord(:,2); 620 % Z=Coord(:,3); 621 % x_ima=Coord(:,4); 622 % y_ima=Coord(:,5); 623 % [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 624 % 625 % GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 626 % GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima)); 627 % GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 628 % GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima)); 603 629 604 630
Note: See TracChangeset
for help on using the changeset viewer.