Skip to content

Commit

Permalink
add/improve EP line implementations. re #375
Browse files Browse the repository at this point in the history
to CalRigMLStro, CalRig2CamCaltech. add option to use compute_epipole2 to both CalRigs.

In current testing (with user-supplied stereo-calibrated camera pair), all implementations agree. CalRigMLStro+zray is more difficult to use, as it requires choosing a z-range (either manually, or automatically given calibration pattern information). compute_epipole2 has built-in sampling via a geometric construction. Zray does have the benefit that "unphysical" or "wrong-sided" z-values are not drawn; eg, for two cameras positioned side-by-side and pointing in the same direction, negative z-values would not be visible in either camera yet are drawn by compute_epipole2.
  • Loading branch information
allenleetc committed Apr 29, 2022
1 parent 2e6be10 commit 73b7ac2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
4 changes: 3 additions & 1 deletion external/CameraCalibrationToolbox/compute_epipole2.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function [epipole] = compute_epipole2(xLp,R,T,...
fc_right,cc_right,kc_right,alpha_c_right,...
fc_left,cc_left,kc_left,alpha_c_left,varargin)
% xLp: 0b per caltech toolbox conventions
% xLp, cc_right, cc_left: 0b per caltech toolbox conventions
%
% epipole: 0b etc

[roi,roifac,roiradius,N_line] = myparse(varargin,...
'roi',[], ... % (opt) [xlo xhi ylo yhi] ROI (in right cam) in which to compute EP line (approx)
Expand Down
30 changes: 25 additions & 5 deletions matlab/user/CalRig2CamCaltech.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
% When X_L=0, X_R=T_RL => T_RL is position of left cam wrt right
omRL;
TRL;

useEP2 = false;
end
properties (Dependent,Hidden)
% extrinsic props all derived from .om_RL, .T_RL
Expand Down Expand Up @@ -124,6 +126,9 @@
assert(numel(xy1)==2);
%fprintf(1,'Cam %d: croppedcoords: %s\n',iAx,mat2str(round(pos(:)')));

% "view"/"target" nomenclature here a little confusing
% "view": where the EP line will be drawn; corresponds to iViewEpi
% "target": origin of click/xy1; corresponds to iView1
if iView1 == 1
view_R = rodrigues(obj.omRL);
view_T = obj.TRL;
Expand Down Expand Up @@ -154,15 +159,30 @@
xLp = [xy1(1), xy1(2)] - 1;
xLp = xLp';

% hack... we'll add 1000 to the last argument of compute_epipole
% what this does is to compute 1000 points on the epipolar line. This
% isn't great, the correct solution would probably to figure out the
% the bounds of the image space before computing points.
epipole = compute_epipole(xLp, view_R, view_T, view_fc, view_cc, view_kc, view_alpha_c, target_fc, target_cc, target_kc, target_alpha_c, 1000);
if obj.useEP2
epipole = compute_epipole2(xLp, view_R, view_T, view_fc, view_cc, ...
view_kc, view_alpha_c, target_fc, target_cc, target_kc, ...
target_alpha_c,'roi',roiEpi);
else
% hack... we'll add 1000 to the last argument of compute_epipole
% what this does is to compute 1000 points on the epipolar line. This
% isn't great, the correct solution would probably to figure out the
% the bounds of the image space before computing points.
%
% AL 20220428: Think the 1e3 is a 'diameter of interest' (in px)
% for the EP line rather than a number of points; for the latter
% see N_line parameter in compute_epipole. See also
% compute_epipole2 for slightly improved range-of-interest
% estimation
epipole = compute_epipole(xLp, view_R, view_T, view_fc, view_cc, ...
view_kc, view_alpha_c, target_fc, target_cc, target_kc, ...
target_alpha_c,1000);
end
xEPL = epipole(1, :) + 1;
yEPL = epipole(2, :) + 1;

% next lets limit the extents of the epipolar line.

yEPL(xEPL < 1) = [];
xEPL(xEPL < 1) = [];

Expand Down

0 comments on commit 73b7ac2

Please sign in to comment.