18 Eigen::Vector3d hcol1 = hmtx.col(0);
19 Eigen::Vector3d hcol2 = hmtx.col(1);
20 Eigen::Vector3d hcol3 = hmtx.col(2);
22 double s = std::sqrt(hcol1.norm() * hcol2.norm());
26 Eigen::Vector3d rcol1 = hcol1 / s;
27 Eigen::Vector3d rcol2 = hcol2 / s;
28 Eigen::Vector3d rcol3 = rcol1.cross(rcol2);
30 Eigen::Matrix3d r_init;
31 r_init.col(0) = rcol1;
32 r_init.col(1) = rcol2;
33 r_init.col(2) = rcol3;
35 Eigen::JacobiSVD<Eigen::Matrix3d> svd(r_init, Eigen::ComputeFullU | Eigen::ComputeFullV);
36 Eigen::Matrix3d rotation = svd.matrixU() * svd.matrixV().transpose();
37 if (rotation.determinant() < 0) {
38 Eigen::Matrix3d vmtx = svd.matrixV();
40 rotation = svd.matrixU() * vmtx.transpose();
42 Eigen::Vector3d translation = hcol3 / s;
43 if (rotation(2, 2) < 0) {
45 translation = -translation;
48 Eigen::Isometry3d pose = Eigen::Isometry3d::Identity();
49 pose.linear() = rotation;
50 pose.translation() = translation;
55 if (view.size() < 4) {
56 return Eigen::Isometry3d::Identity();
60 obs.image_uv = normalize(intrinsics, obs.image_uv);
63 std::vector<int> sample(view.size());
64 std::iota(sample.begin(), sample.end(), 0);
66 if (!h_opt.has_value()) {
67 std::cerr <<
"Failed to estimate homography using DLT" << std::endl;
68 return Eigen::Isometry3d::Identity();
71 Eigen::Matrix3d hmtx = h_opt.value();
72 if (std::abs(hmtx(2, 2)) > 1e-15) {