Skip to content

Commit ecddd5e

Browse files
committed
allow the focal length to be different for unrecognized camera type
1 parent 12630f1 commit ecddd5e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

glomap/estimators/relpose_estimation.cc

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,29 @@ void EstimateRelativePoses(ViewGraph& view_graph,
6363
// Undistort points
6464
// Note that here, we still rescale by the focal length (to avoid
6565
// change the RANSAC threshold)
66+
Eigen::Matrix2d K1_new = Eigen::Matrix2d::Zero();
67+
Eigen::Matrix2d K2_new = Eigen::Matrix2d::Zero();
68+
K1_new(0, 0) = camera1.FocalLengthX();
69+
K1_new(1, 1) = camera1.FocalLengthY();
70+
K2_new(0, 0) = camera2.FocalLengthX();
71+
K2_new(1, 1) = camera2.FocalLengthY();
6672
for (size_t idx = 0; idx < matches.rows(); idx++) {
67-
points2D_1[idx] =
68-
camera1.Focal() * camera1.CamFromImg(points2D_1[idx]);
69-
points2D_2[idx] =
70-
camera2.Focal() * camera2.CamFromImg(points2D_2[idx]);
73+
points2D_1[idx] = K1_new * camera1.CamFromImg(points2D_1[idx]);
74+
points2D_2[idx] = K2_new * camera2.CamFromImg(points2D_2[idx]);
7175
}
76+
7277
// Reset the camera to be the pinhole camera with original focal
7378
// length and zero principal point
74-
camera_poselib1 = poselib::Camera("SIMPLE_PINHOLE",
75-
{camera1.Focal(), 0., 0.},
76-
camera1.width,
77-
camera1.height);
78-
camera_poselib2 = poselib::Camera("SIMPLE_PINHOLE",
79-
{camera2.Focal(), 0., 0.},
80-
camera2.width,
81-
camera2.height);
79+
camera_poselib1 = poselib::Camera(
80+
"PINHOLE",
81+
{camera1.FocalLengthX(), camera1.FocalLengthY(), 0., 0.},
82+
camera1.width,
83+
camera1.height);
84+
camera_poselib2 = poselib::Camera(
85+
"PINHOLE",
86+
{camera2.FocalLengthX(), camera2.FocalLengthY(), 0., 0.},
87+
camera2.width,
88+
camera2.height);
8289
}
8390
inliers.clear();
8491
poselib::CameraPose pose_rel_calc;

0 commit comments

Comments
 (0)