Changeset 1113
- Timestamp:
- Feb 8, 2022, 1:58:47 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r1112 r1113 52 52 % Edit the above text to modify the response to help geometry_calib 53 53 54 % Last Modified by GUIDE v2.5 20-Sep-2018 19:04:3054 % Last Modified by GUIDE v2.5 05-Feb-2022 22:24:55 55 55 56 56 % Begin initialization code - DO NOT edit … … 232 232 233 233 %% Apply calibration 234 [GeometryCalib,index,ind_removed ,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration234 [GeometryCalib,index,ind_removed]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration 235 235 if isempty(GeometryCalib) 236 236 return … … 245 245 GeometryCalib.SourceCalib.PointCoord=Coord; 246 246 247 %% display calibration results on the GUI geometry_calib248 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters249 display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters250 % (rotation and translation of camera with respect to the phys coordinates)251 252 247 %% set the default plane and display the calibration data errors for validation 253 248 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';... 254 249 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 255 250 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']; 256 [num2str(numel(ind_removed)) ' points removed']}); 257 % SliceCoord_ref=[0 0 0]; %default reference plane 251 [num2str(numel(ind_removed)) ' points removed with ErrorMax > 3 rms']}); 258 252 checkslice=0; 259 253 if strcmp(answer,'Yes') %store the calibration data 254 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters on the GUI geometry_calib 255 display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters on the GUI geometry_calib 260 256 Z=Coord(:,3); 261 257 if strcmp(calib_cell{val}(1:2),'3D') && isequal(max(Z),min(Z))%set the plane position for 3D (projection) calibration … … 348 344 errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file 349 345 if checkslice 350 346 errormsg=update_imadoc(Slice,outputfile,'Slice');% introduce the slice position in the xml file 351 347 end 352 348 if ~strcmp(errormsg,'') 353 349 msgbox_uvmat('ERROR',errormsg); 354 350 end 355 351 356 352 %% display image with new calibration in the currently opened uvmat GUI 357 353 FieldList=get(hhuvmat.FieldName,'String'); … … 397 393 %------------------------------------------------------------------------ 398 394 % --- activate calibration and store parameters in ouputfile . 399 function [GeometryCalib,ind_max,ind_removed ,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic)395 function [GeometryCalib,ind_max,ind_removed]=calibrate(Coord,CalibFcn,Intrinsic) 400 396 %------------------------------------------------------------------------ 401 397 402 398 index=[]; 403 399 GeometryCalib=[]; 404 ind_max=[];ind_removed=[]; Z_plane=[];400 ind_max=[];ind_removed=[]; 405 401 % apply the calibration, whose type is selected in handles.calib_type 406 402 CoordFlip=Coord; 407 CoordFlip(:,3)= -Coord(:,3);403 CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours 408 404 if ~isempty(Coord) 409 405 GeometryCalib=feval(CalibFcn,CoordFlip,Intrinsic); … … 414 410 return 415 411 end 416 Z_plane=[];417 412 418 413 % estimate calibration error rms and max 419 % X=Coord(:,1);420 % Y=Coord(:,2);421 Z=Coord(:,3);422 414 x_ima=Coord(:,4); 423 415 y_ima=Coord(:,5); 424 [Xpoints,Ypoints]=px_XYZ(GeometryCalib,[],Coord(:,1),Coord(:,2),Coord(:,3)); % convention of downward z coordinate (facing the camera)416 [Xpoints,Ypoints]=px_XYZ(GeometryCalib,[],Coord(:,1),Coord(:,2),Coord(:,3)); 425 417 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 426 418 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); … … 430 422 ind_max=index(ind_dim); % mark the index with maximum deviation 431 423 432 % detect bad calibration points, marked by indices ind_ bad, if the424 % detect bad calibration points, marked by indices ind_removed, if the 433 425 % difference of actual image coordinates and those given by calibration is 434 % greater than 2 pixels and greater than 4rms.426 % greater than 2 pixels and greater than 3 rms. 435 427 check_x=abs(Xpoints-x_ima)>max(2,3*GeometryCalib.ErrorRms(1)); 436 428 check_y=abs(Ypoints-y_ima)>max(2,3*GeometryCalib.ErrorRms(2)); 437 ind_removed=find(check_x | check_y) 429 ind_removed=find(check_x | check_y); 438 430 % repeat calibration without the excluded points: 439 431 if ~isempty(ind_removed) 440 432 Coord(ind_removed,:)=[]; 441 GeometryCalib=feval(CalibFcn,Coord,Intrinsic); 433 CoordFlip=Coord; 434 CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours 435 GeometryCalib=feval(CalibFcn,CoordFlip,Intrinsic); 442 436 X=Coord(:,1); 443 437 Y=Coord(:,2); … … 450 444 end 451 445 GeometryCalib.ErrorMax=ErrorMax; 452 % %set the Z position of the reference plane used for calibration453 % if isequal(max(Z),min(Z))%Z constant454 % Z_plane=Z(1);455 % GeometryCalib.NbSlice=1;456 % GeometryCalib.SliceCoord=[0 0 Z_plane];457 % end458 446 459 447 … … 468 456 [px]=polyfit(X,x_ima,1); 469 457 [py]=polyfit(Y,y_ima,1); 470 % T_x=px(2);471 % T_y=py(2);472 458 GeometryCalib.CalibrationType='rescale'; 473 459 GeometryCalib.fx_fy=[px(1) py(1)];%.fx_fy corresponds to pxcm along x and y … … 620 606 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim' 621 607 if exist('Rc_1','var') 622 GeometryCalib.CalibrationType='3D_ linear';608 GeometryCalib.CalibrationType='3D_extrinsic'; 623 609 GeometryCalib.fx_fy=fc'; 624 610 GeometryCalib.Cx_Cy=cc'; … … 698 684 699 685 if exist('Rc_1','var') 700 GeometryCalib.CalibrationType='3D_ quadr';686 GeometryCalib.CalibrationType='3D_extrinsic'; 701 687 GeometryCalib.fx_fy=fc'; 702 688 GeometryCalib.Cx_Cy=cc'; … … 1163 1149 1164 1150 % -------------------------------------------------------------------- 1165 function MenuFlip_x _Callback(hObject, eventdata, handles)1151 function MenuFlip_xy_Callback(hObject, eventdata, handles) 1166 1152 Coord=get(handles.ListCoord,'Data'); 1167 1153 Coord(:,1)=-Coord(:,1); 1154 Coord(:,2)=-Coord(:,2); 1168 1155 set(handles.ListCoord,'Data',Coord) 1169 1156 1170 1157 % -------------------------------------------------------------------- 1171 function MenuFlip_ y_Callback(hObject, eventdata, handles)1158 function MenuFlip_xz_Callback(hObject, eventdata, handles) 1172 1159 Coord=get(handles.ListCoord,'Data'); 1173 Coord(:,2)=-Coord(:,2); 1160 Coord(:,1)=-Coord(:,1); 1161 Coord(:,3)=-Coord(:,3); 1174 1162 set(handles.ListCoord,'Data',Coord) 1175 1163 -
trunk/src/phys_XYZ.m
r1112 r1113 79 79 if isfield(Calib,'R') 80 80 R=(Calib.R)'; 81 R(3)=-R(3);82 R(6)=-R(6);83 R(9)=-R(9);81 % R(3)=-R(3); 82 % R(6)=-R(6); 83 % R(9)=-R(9); 84 84 c=Z0virt; 85 85 cvirt=Z0virt; -
trunk/src/px_XYZ.m
r1112 r1113 57 57 58 58 %camera coordinates 59 Zphys= -Zphys;%flip z coordinates59 Zphys=Zphys;%flip z coordinates 60 60 xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1); 61 61 yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2); -
trunk/src/series.m
r1108 r1113 3143 3143 if get(handles.CheckObject,'Value') 3144 3144 SeriesData=get(handles.series,'UserData'); 3145 if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject) 3145 if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)% a projection object is already loaded in the GUI series 3146 3146 set(handles.ViewObject,'Value',1) 3147 3147 ViewObject_Callback(hObject, eventdata, handles) 3148 3148 else 3149 if ishandle(hset_object) 3149 if ishandle(hset_object)% a projection object is already displayed in a GUI set_object 3150 3150 uistack(hset_object,'top')% show the GUI set_object if opened 3151 3151 else … … 3215 3215 set(handles.ViewObject,'Value',0) 3216 3216 UserData=get(handles.series,'UserData'); 3217 if isfield(UserData,'ProjObject') 3217 3218 hset_object=set_object(UserData.ProjObject); 3218 3219 set(hset_object,'Name','edit_object_series') 3219 3220 set(get(hset_object,'Children'),'Enable','on') 3221 else 3222 msgbox_uvmat('ERROR','no projection object available'); 3223 end 3220 3224 else 3221 3225 hset_object=findobj(allchild(0),'Tag','set_object'); -
trunk/src/series/extract_rdvision.m
r1112 r1113 206 206 logdir=[Param.OutputSubDir Param.OutputDirExt]; 207 207 [success,errormsg] = copyfile(filename_seq,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.seq']); %copy the seq file in the upper folder 208 if ~success 209 disp(errormsg) 210 end 208 211 [success,errormsg] = copyfile(filename_sqb,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.sqb']); %copy the sqb file in the upper folder 212 if ~success 213 disp(errormsg) 214 end 209 215 if check_xml 210 216 [success,errormsg] = copyfile(filexml,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.xml']); %copy the original xml file in the upper folder 217 if ~success 218 disp(errormsg) 219 end 211 220 else 212 errormsg=[filexml ' missing'];221 disp(['error:' filexml ' missing']); 213 222 return 214 223 end -
trunk/src/transform_field/FFT2_detrend.m
r1107 r1113 85 85 DataOut.ListVarName=[CoordName {VarName}];%list of variables 86 86 DataOut.VarDimName=[CoordName {CoordName}];%list of dimensions for variables 87 DataOut.VarAttribute{1}.Role='coord_y'; 88 DataOut.VarAttribute{2}.Role='coord_x'; 89 DataOut.VarAttribute{3}.Role='scalar'; 87 90 break 88 91 end -
trunk/src/xml2struct.m
r1107 r1113 84 84 case 'char' 85 85 % try to convert to number if the char does not correspond to a function (otherwise str2num calls this function as it uses 'eval') 86 if exist(ss,'builtin')||exist(ss,'file')% ss corresponds to the name of a builtin Matlab function or a file87 out=ss; %reproduce the input string88 else86 % if exist(ss,'builtin')||exist(ss,'file')% ss corresponds to the name of a builtin Matlab function or a file 87 % out=ss; %reproduce the input string 88 % else 89 89 out=str2num(ss);% convert to number or vector (str2num applied to a fct name executes this fct by 'eval', thus this possibility had to be ruled out above 90 90 if isempty(out) … … 100 100 end 101 101 end 102 end102 % end 103 103 case 'cell' 104 104 out={};%default
Note: See TracChangeset
for help on using the changeset viewer.