Skip to content

Commit

Permalink
Merge branch 'develop_use_eigen_in_the_ceres_functor' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoulon committed Nov 23, 2017
2 parents 0ec6d15 + 72380b5 commit 3c75123
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/openMVG/sfm/sfm_data_BA_ceres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,18 @@ struct PoseCenterConstraintCostFunction
)
const
{
const T * cam_R = &cam_extrinsics[0];
const T * cam_t = &cam_extrinsics[3];
const T cam_R_transpose[3] = {-cam_R[0], -cam_R[1], -cam_R[2]};
using Vec3T = Eigen::Matrix<T,3,1>;
Eigen::Map<const Vec3T> cam_R(&cam_extrinsics[0]);
Eigen::Map<const Vec3T> cam_t(&cam_extrinsics[3]);
const Vec3T cam_R_transpose(-cam_R);

T pose_center[3];
Vec3T pose_center;
// Rotate the point according the camera rotation
ceres::AngleAxisRotatePoint(cam_R_transpose, cam_t, pose_center);
pose_center[0] *= T(-1);
pose_center[1] *= T(-1);
pose_center[2] *= T(-1);

residuals[0] = T(weight_[0]) * (pose_center[0] - T(pose_center_constraint_[0]));
residuals[1] = T(weight_[1]) * (pose_center[1] - T(pose_center_constraint_[1]));
residuals[2] = T(weight_[2]) * (pose_center[2] - T(pose_center_constraint_[2]));
ceres::AngleAxisRotatePoint(cam_R_transpose.data(), cam_t.data(), pose_center.data());
pose_center = pose_center * T(-1);

Eigen::Map<Vec3T> residuals_eigen(residuals);
residuals_eigen = weight_.cast<T>().cwiseProduct(pose_center - pose_center_constraint_.cast<T>());

return true;
}
Expand Down

0 comments on commit 3c75123

Please sign in to comment.