farm-ng-core
projection_ortho.h
Go to the documentation of this file.
1 // Copyright (c) 2011, Hauke Strasdat
2 // Copyright (c) 2012, Steven Lovegrove
3 // Copyright (c) 2021, farm-ng, inc.
4 //
5 // Use of this source code is governed by an MIT-style
6 // license that can be found in the LICENSE file or at
7 // https://opensource.org/licenses/MIT.
8 
9 #pragma once
10 
11 #include <Eigen/Core>
12 
13 namespace sophus {
14 
16  template <class TPoints, int kRows>
17  using WithRows = Eigen::
18  Matrix<typename TPoints::Scalar, kRows, TPoints::ColsAtCompileTime>;
19 
20  // Project one or more 3-points from the camera frame into the canonical z=0
21  // plane through orthographic projection. For N points, a 3xN matrix must be
22  // provided where each column is a point to be transformed. The result will be
23  // a 2xN matrix. N may be dynamically sized, but the input columns must be
24  // statically determined as 3 at compile time.
25  template <class TDerived>
26  static auto proj(Eigen::DenseBase<TDerived> const& points_in_camera)
28  static_assert(TDerived::RowsAtCompileTime == 3);
29  return points_in_camera.template topRows<2>();
30  }
31 
32  template <class TDerived>
33  static auto unproj(
34  Eigen::DenseBase<TDerived> const& points_in_cam_canonical,
35  typename TDerived::Scalar extension =
36  static_cast<typename TDerived::Scalar>(0.0))
38  static_assert(TDerived::RowsAtCompileTime == 2);
40  unprojected.template topRows<2>() = points_in_cam_canonical;
41  unprojected.template bottomRows<1>() =
43  points_in_cam_canonical.cols(), extension);
44  return unprojected;
45  }
46 
47  /// Returns point derivative of inverse depth point projection:
48  ///
49  /// Dx proj(x) with x = (a,b,psi) being an inverse depth point.
50  template <class TScalar>
51  static auto dxProjX(Eigen::Matrix<TScalar, 3, 1> const& /*unused*/)
52  -> Eigen::Matrix<TScalar, 2, 3> {
54  }
55 };
56 
57 } // namespace sophus
sophus::ProjectionOrtho::WithRows
Eigen::Matrix< typename TPoints::Scalar, kRows, TPoints::ColsAtCompileTime > WithRows
Definition: projection_ortho.h:18
sophus
Image MutImage, owning images types.
Definition: num_diff.h:20
sophus::ProjectionOrtho::proj
static auto proj(Eigen::DenseBase< TDerived > const &points_in_camera) -> WithRows< Eigen::DenseBase< TDerived >, 2 >
Definition: projection_ortho.h:26
SOPHUS_UNIMPLEMENTED
#define SOPHUS_UNIMPLEMENTED(...)
Definition: common.h:51
sophus::ProjectionOrtho::unproj
static auto unproj(Eigen::DenseBase< TDerived > const &points_in_cam_canonical, typename TDerived::Scalar extension=static_cast< typename TDerived::Scalar >(0.0)) -> WithRows< Eigen::DenseBase< TDerived >, 3 >
Definition: projection_ortho.h:33
sophus::ProjectionOrtho::dxProjX
static auto dxProjX(Eigen::Matrix< TScalar, 3, 1 > const &) -> Eigen::Matrix< TScalar, 2, 3 >
Returns point derivative of inverse depth point projection:
Definition: projection_ortho.h:51
sophus::ProjectionOrtho
Definition: projection_ortho.h:15