Go to the documentation of this file.
23 #ifndef ba_internals_H
24 #define ba_internals_H
46 #define VERBOSE_COUT \
51 template <
int FrameDof,
int Po
intDof,
int ObsDim>
80 template <
bool POSES_ARE_INVERSE>
90 if (POSES_ARE_INVERSE)
92 landmark_global.
x, landmark_global.
y, landmark_global.
z,
x,
y,
z);
95 landmark_global.
x, landmark_global.
y, landmark_global.
z,
x,
y,
z);
98 const double _z = 1.0 /
z;
99 const double fx_z = camera_params.
fx() * _z;
100 const double fy_z = camera_params.
fy() * _z;
101 const double _z2 =
square(_z);
102 const double fx_z2 = camera_params.
fx() * _z2;
103 const double fy_z2 = camera_params.
fy() * _z2;
105 if (POSES_ARE_INVERSE)
107 const double xy =
x *
y;
109 const double J_vals[] = {fx_z,
113 camera_params.
fx() * (1 +
square(
x * _z)),
118 -camera_params.
fy() * (1 +
square(
y * _z)),
127 const double jac_proj_vals[] = {fx_z, 0, -fx_z2 *
x,
128 0, fy_z, -fy_z2 *
y};
132 const double p_x = cam_pose.
x();
133 const double p_y = cam_pose.
y();
134 const double p_z = cam_pose.z();
135 const double tx = landmark_global.
x - p_x;
136 const double ty = landmark_global.
y - p_y;
137 const double tz = landmark_global.
z - p_z;
139 const double aux_vals[] = {
143 tz *
R(1, 0) -
ty *
R(2, 0) +
R(1, 0) * p_z -
R(2, 0) * p_y,
144 tx *
R(2, 0) -
tz *
R(0, 0) -
R(0, 0) * p_z +
R(2, 0) * p_x,
145 ty *
R(0, 0) - tx *
R(1, 0) +
R(0, 0) * p_y -
R(1, 0) * p_x,
149 tz *
R(1, 1) -
ty *
R(2, 1) +
R(1, 1) * p_z -
R(2, 1) * p_y,
150 tx *
R(2, 1) -
tz *
R(0, 1) -
R(0, 1) * p_z +
R(2, 1) * p_x,
151 ty *
R(0, 1) - tx *
R(1, 1) +
R(0, 1) * p_y -
R(1, 1) * p_x,
155 tz *
R(1, 2) -
ty *
R(2, 2) +
R(1, 2) * p_z -
R(2, 2) * p_y,
156 tx *
R(2, 2) -
tz *
R(0, 2) -
R(0, 2) * p_z +
R(2, 2) * p_x,
157 ty *
R(0, 2) - tx *
R(1, 2) +
R(0, 2) * p_y -
R(1, 2) * p_x};
159 out_J.multiply_AB(jac_proj, vals);
168 template <
bool POSES_ARE_INVERSE>
181 if (POSES_ARE_INVERSE)
183 landmark_global.
x, landmark_global.
y, landmark_global.
z, l.
x, l.
y,
187 landmark_global.
x, landmark_global.
y, landmark_global.
z, l.
x, l.
y,
191 const double _z = 1.0 / l.
z;
192 const double _z2 =
square(_z);
194 const double tmp_vals[] = {
195 camera_params.
fx() * _z, 0,
196 -camera_params.
fx() * l.
x * _z2, 0,
197 camera_params.
fy() * _z, -camera_params.
fy() * l.
y * _z2};
200 out_J.multiply_AB(tmp, dp_point);
208 template <
bool POSES_ARE_INVERSE>
214 const size_t num_fix_frames,
const size_t num_fix_points)
220 ASSERT_(!frame_poses.empty() && !landmark_points.empty());
221 const size_t N = jac_data_vec.size();
223 for (
size_t i = 0; i < N; i++)
233 if (i_f >= num_fix_frames)
235 frameJac<POSES_ARE_INVERSE>(
236 camera_params, frame_poses[i_f], landmark_points[i_p],
241 if (i_p >= num_fix_points)
243 pointJac<POSES_ARE_INVERSE>(
244 camera_params, frame_poses[i_f], landmark_points[i_p],
257 const std::vector<std::array<double, 2>>& residual_vec,
263 const size_t num_fix_frames,
const size_t num_fix_points,
264 const vector<double>* kernel_1st_deriv);
mrpt::aligned_std_vector< mrpt::poses::CPose3D > TFramePosesVec
A list of camera frames (6D poses), which assumes indexes are unique, consecutive IDs.
double fx() const
Get the value of the focal length x-value (in pixels).
std::vector< mrpt::math::TPoint3D > TLandmarkLocationsVec
A list of landmarks (3D points), which assumes indexes are unique, consecutive IDs.
uint64_t TLandmarkID
Unique IDs for landmarks.
A complete sequence of observations of features from different camera frames (poses).
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define ASSERT_(f)
Defines an assertion mechanism.
T square(const T x)
Inline function for the square of a number.
void pointJac(const mrpt::img::TCamera &camera_params, const mrpt::poses::CPose3D &cam_pose, const mrpt::math::TPoint3D &landmark_global, mrpt::math::CMatrixFixedNumeric< double, 2, 3 > &out_J)
Jacobians wrt the point.
double fy() const
Get the value of the focal length y-value (in pixels).
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
uint64_t TCameraPoseID
Unique IDs for camera frames (poses)
void loadFromArray(const T *vals)
double x() const
Common members of all points & poses classes.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
double x
X,Y,Z coordinates.
Structure to hold the parameters of a pinhole camera model.
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
void frameJac(const mrpt::img::TCamera &camera_params, const mrpt::poses::CPose3D &cam_pose, const mrpt::math::TPoint3D &landmark_global, mrpt::math::CMatrixFixedNumeric< double, 2, 6 > &out_J)
The projective camera 2x6 Jacobian (wrt the 6D camera pose)
A numeric matrix of compile-time fixed size.
mrpt::math::CMatrixFixedNumeric< double, ObsDim, FrameDof > J_frame
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
mrpt::math::CMatrixFixedNumeric< double, ObsDim, PointDof > J_point
void ba_compute_Jacobians(const TFramePosesVec &frame_poses, const TLandmarkLocationsVec &landmark_points, const mrpt::img::TCamera &camera_params, mrpt::aligned_std_vector< JacData< 6, 3, 2 >> &jac_data_vec, const size_t num_fix_frames, const size_t num_fix_points)
This base provides a set of functions for maths stuff.
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Put this macro inside any class with members that require {16,32,64}-byte memory alignment (e....
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr) const
Computes the 3D point L such as .
CArrayNumeric< double, N > CArrayDouble
A partial specialization of CArrayNumeric for double numbers.
void ba_build_gradient_Hessians(const TSequenceFeatureObservations &observations, const std::vector< std::array< double, 2 >> &residual_vec, const mrpt::aligned_std_vector< JacData< 6, 3, 2 >> &jac_data_vec, mrpt::aligned_std_vector< mrpt::math::CMatrixFixedNumeric< double, 6, 6 >> &U, mrpt::aligned_std_vector< CArrayDouble< 6 >> &eps_frame, mrpt::aligned_std_vector< mrpt::math::CMatrixFixedNumeric< double, 3, 3 >> &V, mrpt::aligned_std_vector< CArrayDouble< 3 >> &eps_point, const size_t num_fix_frames, const size_t num_fix_points, const vector< double > *kernel_1st_deriv)
Construct the BA linear system.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at mié 12 jul 2023 10:03:34 CEST | |