Changeset 1111


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

3D calibration corrected

Location:
trunk/src
Files:
3 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
  • trunk/src/phys_XYZ.m

    r1110 r1111  
    7676if isfield(Calib,'R')
    7777    R=(Calib.R)';
     78    R(3)=-R(3);
     79    R(6)=-R(6);
     80    R(9)=-R(9);
    7881    c=Z0virt;
    7982    cvirt=Z0virt;
     
    9194        cvirt=Z0virt-avirt*Calib.SliceCoord(Zindex,1)-bvirt*Calib.SliceCoord(Zindex,2);% Z0 = (virtual) z coordinate on the rotation axis (assumed horizontal)
    9295                               % c=z coordinate at (x,y)=(0,0)
    93         c=Z0virt-a*Calib.SliceCoord(Zindex,1)-b*Calib.SliceCoord(Zindex,2);
     96        c=Z0-a*Calib.SliceCoord(Zindex,1)-b*Calib.SliceCoord(Zindex,2);
    9497        R(1)=R(1)+avirt*R(3);
    9598        R(2)=R(2)+bvirt*R(3);
  • trunk/src/px_XYZ.m

    r1107 r1111  
    4747        H=Calib.InterfaceCoord(3);
    4848        if H>Zphys
    49             Zphys=H-(H-Zphys)/Calib.RefractionIndex; %corrected z (virtual object)
     49            Zphys=H-(H-Zphys)/Calib.RefractionIndex; %corrected z (virtual object)Calib
     50           
    5051          %  test_refraction=1;
    5152        end
     
    5354   
    5455    %camera coordinates
     56    Zphys=-Zphys;%flip z coordinates
    5557    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);
    5658    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);
Note: See TracChangeset for help on using the changeset viewer.