Ignore:
Timestamp:
Jan 26, 2022, 9:31:42 AM (3 years ago)
Author:
sommeria
Message:

3D calibration corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r1107 r1111  
    255255    ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels'];
    256256    [num2str(numel(ind_removed)) ' points removed']});
    257 SliceCoord_ref=[0 0 0]; %default reference plane
     257% SliceCoord_ref=[0 0 0]; %default reference plane
    258258if strcmp(answer,'Yes') %store the calibration data
    259     if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration
    260         answer=msgbox_uvmat('INPUT_Y-N',{['Assume that the current image is in the plane of the calib points z=' num2str(Z_plane) ] ; 'can be later modified by MenuSetSlice in the upper bar menu of uvmat'});
    261         SliceCoord_ref=Z_plane'*[0 0 1];
     259    Z=Coord(:,3);
     260    if strcmp(calib_cell{val}(1:2),'3D') && isequal(max(Z),min(Z))%set the plane position for 3D (projection) calibration
     261        %set the Z position of the reference plane used for calibration
     262        answer=msgbox_uvmat('INPUT_Y-N',{['Assume that the illuminated plane is at z=' num2str(Z(1)) ] ; 'can be later modified by MenuSetSlice in the upper bar menu of uvmat'});
     263        if strcmp(answer,'Yes')
     264            GeometryCalib.NbSlice=1;
     265            GeometryCalib.SliceCoord=[0 0 Z(1)];
     266        end
    262267    end
    263268else
     
    390395ind_max=[];ind_removed=[];Z_plane=[];
    391396% apply the calibration, whose type is selected in  handles.calib_type
     397CoordFlip=Coord;
     398CoordFlip(:,3)=-Coord(:,3);
    392399if ~isempty(Coord)
    393     GeometryCalib=feval(CalibFcn,Coord,Intrinsic);
     400    GeometryCalib=feval(CalibFcn,CoordFlip,Intrinsic);
    394401else
    395402    msgbox_uvmat('ERROR','No calibration points, abort')
     
    401408
    402409% estimate calibration error rms and max
    403 X=Coord(:,1);
    404 Y=Coord(:,2);
     410% X=Coord(:,1);
     411% Y=Coord(:,2);
    405412Z=Coord(:,3);
    406413x_ima=Coord(:,4);
    407414y_ima=Coord(:,5);
    408 [Xpoints,Ypoints]=px_XYZ(GeometryCalib,X,Y,Z);
     415[Xpoints,Ypoints]=px_XYZ(GeometryCalib,Coord(:,1),Coord(:,2),Coord(:,3));% convention of downward z coordinate (facing the camera)
    409416GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
    410417GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
     
    434441end
    435442GeometryCalib.ErrorMax=ErrorMax;
    436 %set the Z position of the reference plane used for calibration
    437 if isequal(max(Z),min(Z))%Z constant
    438     Z_plane=Z(1);
    439     GeometryCalib.NbSlice=1;
    440     GeometryCalib.SliceCoord=[0 0 Z_plane];
    441 end
     443% %set the Z position of the reference plane used for calibration
     444% if isequal(max(Z),min(Z))%Z constant
     445%     Z_plane=Z(1);
     446%     GeometryCalib.NbSlice=1;
     447%     GeometryCalib.SliceCoord=[0 0 Z_plane];
     448% end
    442449
    443450
Note: See TracChangeset for help on using the changeset viewer.