39 #ifndef INCLUDE_OKVIS_OPENGV_FRAMERELATIVEPOSESACPROBLEM_HPP_
40 #define INCLUDE_OKVIS_OPENGV_FRAMERELATIVEPOSESACPROBLEM_HPP_
43 #include <opengv/types.hpp>
44 #include <opengv/triangulation/methods.hpp>
45 #include <opengv/relative_pose/methods.hpp>
46 #include <opengv/sac_problems/relative_pose/CentralRelativePoseSacProblem.hpp>
56 namespace sac_problems {
60 namespace relative_pose {
72 typedef CentralRelativePoseSacProblem
base_t;
75 using base_t::adapter_t;
77 using base_t::algorithm_t;
79 using base_t::model_t;
88 : base_t(adapter, algorithm),
90 *static_cast<opengv::relative_pose::FrameRelativeAdapter*>(&_adapter)) {
93 dynamic_cast<opengv::relative_pose::FrameRelativeAdapter*>(&_adapter),
94 "only opengv::absolute_pose::FrameRelativeAdapter supported");
106 const std::vector<int> & indices)
107 :
base_t(adapter, algorithm, indices),
109 *static_cast<opengv::relative_pose::FrameRelativeAdapter*>(&_adapter)) {
112 dynamic_cast<opengv::relative_pose::FrameRelativeAdapter*>(&_adapter),
113 "only opengv::absolute_pose::FrameRelativeAdapter supported");
127 const std::vector<int> & indices,
128 std::vector<double> & scores)
const {
129 translation_t translation = model.col(3);
130 rotation_t rotation = model.block<3, 3>(0, 0);
134 model_t inverseSolution;
135 inverseSolution.block<3, 3>(0, 0) = rotation.transpose();
136 inverseSolution.col(3) = -inverseSolution.block<3, 3>(0, 0) * translation;
138 Eigen::Matrix<double, 4, 1> p_hom;
141 for (
size_t i = 0; i < indices.size(); i++) {
142 p_hom.block<3, 1>(0, 0) = opengv::triangulation::triangulate2(
144 bearingVector_t reprojection1 = p_hom.block<3, 1>(0, 0);
145 bearingVector_t reprojection2 = inverseSolution * p_hom;
146 reprojection1 = reprojection1 / reprojection1.norm();
147 reprojection2 = reprojection2 / reprojection2.norm();
152 point_t error1 = (reprojection1 - f1);
153 point_t error2 = (reprojection2 - f2);
154 double error_squared1 = error1.transpose() * error1;
155 double error_squared2 = error2.transpose() * error2;
158 + error_squared2 * 0.5
virtual opengv::bearingVector_t getBearingVector2(size_t index) const
Retrieve the bearing vector of a correspondence in viewpoint 2.
Definition: FrameRelativeAdapter.cpp:254
Header file for the FrameRelativeAdapter class.
opengv::relative_pose::FrameRelativeAdapter & adapterDerived_
The adapter holding the bearing, correspondences etc.
Definition: FrameRelativePoseSacProblem.hpp:165
virtual void getSelectedDistancesToModel(const model_t &model, const std::vector< int > &indices, std::vector< double > &scores) const
Compute the distances of all samples whith respect to given model coefficients.
Definition: FrameRelativePoseSacProblem.hpp:126
Adapter for relative pose RANSAC (2D2D)
Definition: FrameRelativeAdapter.hpp:60
#define OKVIS_DEFINE_EXCEPTION(exceptionName, exceptionParent)
Macro for defining an exception with a given parent.
Definition: assert_macros.hpp:52
This file contains some useful assert macros.
CentralRelativePoseSacProblem base_t
Definition: FrameRelativePoseSacProblem.hpp:72
virtual ~FrameRelativePoseSacProblem()
Definition: FrameRelativePoseSacProblem.hpp:115
double getSigmaAngle2(size_t index)
Obtain the angular standard deviation of the correspondence in frame 2 in [rad].
Definition: FrameRelativeAdapter.cpp:303
Provides functions for fitting a relative-pose model to a set of bearing-vector to point corresponden...
Definition: FrameRelativePoseSacProblem.hpp:68
virtual opengv::bearingVector_t getBearingVector1(size_t index) const
Retrieve the bearing vector of a correspondence in viewpoint 1.
Definition: FrameRelativeAdapter.cpp:248
double getSigmaAngle1(size_t index)
Obtain the angular standard deviation of the correspondence in frame 1 in [rad].
Definition: FrameRelativeAdapter.cpp:297
#define OKVIS_ASSERT_TRUE(exceptionType, condition, message)
Definition: assert_macros.hpp:111
FrameRelativePoseSacProblem(adapter_t &adapter, algorithm_t algorithm, const std::vector< int > &indices)
FrameRelativePoseSacProblem.
Definition: FrameRelativePoseSacProblem.hpp:105