OKVIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NoDistortion.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2  * OKVIS - Open Keyframe-based Visual-Inertial SLAM
3  * Copyright (c) 2015, Autonomous Systems Lab / ETH Zurich
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of Autonomous Systems Lab / ETH Zurich nor the names of
14  * its contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Created on: Feb 2, 2015
30  * Author: Stefan Leutenegger (s.leutenegger@imperial.ac.uk)
31  *********************************************************************************/
32 
39 #ifndef INCLUDE_OKVIS_CAMERAS_NODISTORTION_HPP_
40 #define INCLUDE_OKVIS_CAMERAS_NODISTORTION_HPP_
41 
42 #include <memory>
43 #include <Eigen/Core>
45 
47 namespace okvis {
49 namespace cameras {
50 
55 {
56  public:
57  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
58 
60  inline ~NoDistortion()
61  {
62  }
63 
67 
71  bool setParameters(const Eigen::VectorXd & parameters)
72  {
73  (void)parameters;
74  return true;
75  }
76 
78  bool getParameters(Eigen::VectorXd & parameters) const
79  {
80  parameters.resize(0);
81  return true;
82  }
83 
85  std::string type() const
86  {
87  return "NoDistortion";
88  }
89 
92  {
93  return 0;
94  }
95 
96  static const int NumDistortionIntrinsics = 0;
97 
100  static std::shared_ptr<DistortionBase> createTestObject() {
101  return std::shared_ptr<DistortionBase>(new NoDistortion());
102  }
105  return NoDistortion();
106  }
107 
111 
116  bool distort(const Eigen::Vector2d & pointUndistorted,
117  Eigen::Vector2d * pointDistorted) const
118  {
119  *pointDistorted = pointUndistorted;
120  return true;
121  }
122 
129  bool distort(const Eigen::Vector2d & pointUndistorted,
130  Eigen::Vector2d * pointDistorted,
131  Eigen::Matrix2d * pointJacobian,
132  Eigen::Matrix2Xd * parameterJacobian = NULL) const
133  {
134  *pointDistorted = pointUndistorted;
135  *pointJacobian = Eigen::Matrix2d::Identity();
136  if (parameterJacobian) {
137  parameterJacobian->resize(2, 0);
138  }
139  return true;
140  }
141 
150  const Eigen::Vector2d & pointUndistorted,
151  const Eigen::VectorXd & parameters, Eigen::Vector2d * pointDistorted,
152  Eigen::Matrix2d * pointJacobian = NULL,
153  Eigen::Matrix2Xd * parameterJacobian = NULL) const
154  {
155  (void)parameters;
156  *pointDistorted = pointUndistorted;
157  if (pointJacobian) {
158  *pointJacobian = Eigen::Matrix2d::Identity();
159  }
160  if (parameterJacobian) {
161  parameterJacobian->resize(2, 0);
162  }
163  return true;
164  }
166 
170 
175  bool undistort(const Eigen::Vector2d & pointDistorted,
176  Eigen::Vector2d * pointUndistorted) const
177  {
178  *pointUndistorted = pointDistorted;
179  return true;
180  }
181 
187  bool undistort(const Eigen::Vector2d & pointDistorted,
188  Eigen::Vector2d * pointUndistorted,
189  Eigen::Matrix2d * pointJacobian) const
190  {
191  *pointUndistorted = pointDistorted;
192  *pointJacobian = Eigen::Matrix2d::Identity();
193  return true;
194  }
196 };
197 
198 } // namespace cameras
199 } // namespace okvis
200 
201 #endif /* INCLUDE_OKVIS_CAMERAS_NODISTORTION_HPP_ */
static std::shared_ptr< DistortionBase > createTestObject()
Unit test support – create a test distortion object.
Definition: NoDistortion.hpp:100
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ~NoDistortion()
Destructor, not doing anything.
Definition: NoDistortion.hpp:60
This trivially doesn't do anything in terms of distortion. This is useful for testing, or working with pre-undistorted images.
Definition: NoDistortion.hpp:54
bool undistort(const Eigen::Vector2d &pointDistorted, Eigen::Vector2d *pointUndistorted) const
Undistortion only.
Definition: NoDistortion.hpp:175
bool distort(const Eigen::Vector2d &pointUndistorted, Eigen::Vector2d *pointDistorted) const
Distortion only.
Definition: NoDistortion.hpp:116
Header file for the DistortionBase class.
bool distortWithExternalParameters(const Eigen::Vector2d &pointUndistorted, const Eigen::VectorXd &parameters, Eigen::Vector2d *pointDistorted, Eigen::Matrix2d *pointJacobian=NULL, Eigen::Matrix2Xd *parameterJacobian=NULL) const
Distortion and Jacobians using external distortion intrinsics parameters.
Definition: NoDistortion.hpp:149
std::string type() const
The class type.
Definition: NoDistortion.hpp:85
bool distort(const Eigen::Vector2d &pointUndistorted, Eigen::Vector2d *pointDistorted, Eigen::Matrix2d *pointJacobian, Eigen::Matrix2Xd *parameterJacobian=NULL) const
Distortion and Jacobians.
Definition: NoDistortion.hpp:129
static NoDistortion testObject()
Unit test support – create a test distortion object.
Definition: NoDistortion.hpp:104
bool undistort(const Eigen::Vector2d &pointDistorted, Eigen::Vector2d *pointUndistorted, Eigen::Matrix2d *pointJacobian) const
Undistortion only.
Definition: NoDistortion.hpp:187
Base class for all distortion models.
Definition: DistortionBase.hpp:52
static const int NumDistortionIntrinsics
Definition: NoDistortion.hpp:96
int numDistortionIntrinsics() const
Number of derived class distortion parameters.
Definition: NoDistortion.hpp:91
bool getParameters(Eigen::VectorXd &parameters) const
Obtain the generic parameters.
Definition: NoDistortion.hpp:78
bool setParameters(const Eigen::VectorXd &parameters)
set the generic parameters
Definition: NoDistortion.hpp:71