- Timestamp:
- Apr 27, 2014, 11:58:49 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r745 r755 506 506 coord_files={}; 507 507 end 508 %retrieve the calibration points stored in the files listed in the popup list ListCoordFiles 509 x_1=Coord(:,4:5)';%px coordinates of the ref points 510 if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on') 511 msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration') 512 return 513 end 514 nx=str2num(get(hhuvmat.num_Npx,'String')); 515 ny=str2num(get(hhuvmat.num_Npy,'String')); 516 x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates 517 X_1=Coord(:,1:3)';%phys coordinates of the ref points 518 n_ima=numel(coord_files)+1; 519 if ~isempty(coord_files) 520 msgbox_uvmat('CONFIRMATION',['The xy coordinates of the calibration points in ' num2str(n_ima) ' planes will be used']) 521 for ifile=1:numel(coord_files) 522 t=xmltree(coord_files{ifile}); 523 s=convert(t);%convert to matlab structure 524 if isfield(s,'GeometryCalib') 525 if isfield(s.GeometryCalib,'SourceCalib') 526 if isfield(s.GeometryCalib.SourceCalib,'PointCoord') 527 PointCoord=s.GeometryCalib.SourceCalib.PointCoord; 528 Coord_file=zeros(length(PointCoord),5);%default 529 for i=1:length(PointCoord) 530 line=str2num(PointCoord{i}); 531 Coord_file(i,4:5)=line(4:5);%px x 532 Coord_file(i,1:3)=line(1:3);%phys x 533 end 534 eval(['x_' num2str(ifile+1) '=Coord_file(:,4:5)'';']); 535 eval(['x_' num2str(ifile+1) '(2,:)=ny-x_' num2str(ifile+1) '(2,:);' ]); 536 eval(['X_' num2str(ifile+1) '=Coord_file(:,1:3)'';']); 537 end 538 end 539 end 540 end 541 end 542 n_ima=numel(coord_files)+1; 543 est_dist=[0;0;0;0;0]; 544 est_aspect_ratio=0; 545 est_fc=[1;1]; 546 center_optim=0; 547 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim' 548 if exist('Rc_1','var') 549 GeometryCalib.CalibrationType='3D_linear'; 550 GeometryCalib.fx_fy=fc'; 551 GeometryCalib.Cx_Cy=cc'; 552 GeometryCalib.kc=kc(1); 553 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function 554 GeometryCalib.Tx_Ty_Tz=Tc_1'; 555 GeometryCalib.R=Rc_1; 556 GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate 557 GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate 558 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate 559 GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees 560 GeometryCalib.ErrorRMS=[]; 561 GeometryCalib.ErrorMax=[]; 562 else 563 msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic']) 564 GeometryCalib=[]; 565 end 566 567 %------------------------------------------------------------------------ 568 function GeometryCalib=calib_3D_quadr(Coord,handles) 569 %------------------------------------------------------------------ 570 571 path_uvmat=which('uvmat');% check the path detected for source file uvmat 572 path_UVMAT=fileparts(path_uvmat); %path to UVMAT 573 huvmat=findobj(allchild(0),'Tag','uvmat'); 574 hhuvmat=guidata(huvmat); 575 if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on') 576 msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration') 577 return 578 end 579 % check_cond=0; 580 coord_files=get(handles.ListCoordFiles,'String'); 581 if ischar(coord_files) 582 coord_files={coord_files}; 583 end 584 if isempty(coord_files{1}) || isequal(coord_files,{''}) 585 coord_files={}; 586 end 587 508 588 %retrieve the calibration points stored in the files listed in the popup list ListCoordFiles 509 589 x_1=Coord(:,4:5)';%px coordinates of the ref points … … 537 617 end 538 618 n_ima=numel(coord_files)+1; 539 est_dist=[0;0;0;0;0];540 est_aspect_ratio=0;541 est_fc=[1;1];542 center_optim=0;543 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'544 if exist('Rc_1','var')545 GeometryCalib.CalibrationType='3D_linear';546 GeometryCalib.fx_fy=fc';547 GeometryCalib.Cx_Cy=cc';548 GeometryCalib.kc=kc(1);549 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function550 GeometryCalib.Tx_Ty_Tz=Tc_1';551 GeometryCalib.R=Rc_1;552 GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate553 GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate554 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate555 GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees556 GeometryCalib.ErrorRMS=[];557 GeometryCalib.ErrorMax=[];558 else559 msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic'])560 GeometryCalib=[];561 end562 563 %------------------------------------------------------------------------564 function GeometryCalib=calib_3D_quadr(Coord,handles)565 %------------------------------------------------------------------566 567 path_uvmat=which('uvmat');% check the path detected for source file uvmat568 path_UVMAT=fileparts(path_uvmat); %path to UVMAT569 huvmat=findobj(allchild(0),'Tag','uvmat');570 hhuvmat=guidata(huvmat);571 % check_cond=0;572 coord_files=get(handles.ListCoordFiles,'String');573 if ischar(coord_files)574 coord_files={coord_files};575 end576 if isempty(coord_files{1}) || isequal(coord_files,{''})577 coord_files={};578 end579 580 %retrieve the calibration points stored in the files listed in the popup list ListCoordFiles581 x_1=Coord(:,4:5)';%px coordinates of the ref points582 nx=str2num(get(hhuvmat.num_Npx,'String'));583 ny=str2num(get(hhuvmat.num_Npy,'String'));584 x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates585 X_1=Coord(:,1:3)';%phys coordinates of the ref points586 n_ima=numel(coord_files)+1;587 if ~isempty(coord_files)588 msgbox_uvmat('CONFIRMATION',['The xy coordinates of the calibration points in ' num2str(n_ima) ' planes will be used'])589 for ifile=1:numel(coord_files)590 t=xmltree(coord_files{ifile});591 s=convert(t);%convert to matlab structure592 if isfield(s,'GeometryCalib')593 if isfield(s.GeometryCalib,'SourceCalib')594 if isfield(s.GeometryCalib.SourceCalib,'PointCoord')595 PointCoord=s.GeometryCalib.SourceCalib.PointCoord;596 Coord_file=zeros(length(PointCoord),5);%default597 for i=1:length(PointCoord)598 line=str2num(PointCoord{i});599 Coord_file(i,4:5)=line(4:5);%px x600 Coord_file(i,1:3)=line(1:3);%phys x601 end602 eval(['x_' num2str(ifile+1) '=Coord_file(:,4:5)'';']);603 eval(['x_' num2str(ifile+1) '(2,:)=ny-x_' num2str(ifile+1) '(2,:);' ]);604 eval(['X_' num2str(ifile+1) '=Coord_file(:,1:3)'';']);605 end606 end607 end608 end609 end610 n_ima=numel(coord_files)+1;611 619 est_dist=[1;0;0;0;0]; 612 620 est_aspect_ratio=1; … … 642 650 huvmat=findobj(allchild(0),'Tag','uvmat'); 643 651 hhuvmat=guidata(huvmat); 652 if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on') 653 msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration') 654 return 655 end 644 656 ny=str2double(get(hhuvmat.num_Npy,'String')); 645 657 x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates -
trunk/src/nc2struct.m
r748 r755 3 3 % The corresponding dimensions and variable attributes are then extracted 4 4 %---------------------------------------------------------------------- 5 % function [Data,var_detect,ichoice ]=nc2struct(nc,varargin)5 % function [Data,var_detect,ichoice,errormsg]=nc2struct(nc,varargin) 6 6 % 7 7 % OUTPUT:
Note: See TracChangeset
for help on using the changeset viewer.