OKVIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RadialTangentialDistortion.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 3, 2015
30  * Author: Stefan Leutenegger (s.leutenegger@imperial.ac.uk)
31  *********************************************************************************/
32 
39 #ifndef INCLUDE_OKVIS_CAMERAS_RADIALTANGENTIALDISTORTION_HPP_
40 #define INCLUDE_OKVIS_CAMERAS_RADIALTANGENTIALDISTORTION_HPP_
41 
42 #include <memory>
43 #include <Eigen/Core>
45 
47 namespace okvis {
49 namespace cameras {
50 
52 {
53  public:
54  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
55 
58 
64  inline RadialTangentialDistortion(double k1, double k2, double p1, double p2);
65 
69 
73  inline bool setParameters(const Eigen::VectorXd & parameters);
74 
76  inline bool getParameters(Eigen::VectorXd & parameters) const
77  {
78  parameters = parameters_;
79  return true;
80  }
81 
83  inline std::string type() const
84  {
85  return "RadialTangentialDistortion";
86  }
87 
89  inline int numDistortionIntrinsics() const
90  {
92  }
93 
94  static const int NumDistortionIntrinsics = 4;
95 
98  static std::shared_ptr<DistortionBase> createTestObject()
99  {
100  return std::shared_ptr<DistortionBase>(
101  new RadialTangentialDistortion(-0.16, 0.15, 0.0003, 0.0002));
102  }
104  static RadialTangentialDistortion testObject()
105  {
106  return RadialTangentialDistortion(-0.16, 0.15, 0.0003, 0.0002);
107  }
108 
112 
117  inline bool distort(const Eigen::Vector2d & pointUndistorted,
118  Eigen::Vector2d * pointDistorted) const;
119 
126  inline bool distort(const Eigen::Vector2d & pointUndistorted,
127  Eigen::Vector2d * pointDistorted,
128  Eigen::Matrix2d * pointJacobian,
129  Eigen::Matrix2Xd * parameterJacobian = NULL) const;
130 
138  inline bool distortWithExternalParameters(
139  const Eigen::Vector2d & pointUndistorted,
140  const Eigen::VectorXd & parameters, Eigen::Vector2d * pointDistorted,
141  Eigen::Matrix2d * pointJacobian = NULL,
142  Eigen::Matrix2Xd * parameterJacobian = NULL) const;
144 
148 
153  inline bool undistort(const Eigen::Vector2d & pointDistorted,
154  Eigen::Vector2d * pointUndistorted) const;
155 
161  inline bool undistort(const Eigen::Vector2d & pointDistorted,
162  Eigen::Vector2d * pointUndistorted,
163  Eigen::Matrix2d * pointJacobian) const;
165 
166  protected:
167  Eigen::Matrix<double, NumDistortionIntrinsics, 1> parameters_;
168 
169  double k1_;
170  double k2_;
171  double p1_;
172  double p2_;
173 };
174 
175 } // namespace cameras
176 } // namespace okvis
177 
179 
180 #endif /* INCLUDE_OKVIS_CAMERAS_RADIALTANGENTIALDISTORTION_HPP_ */
Eigen::Matrix< double, NumDistortionIntrinsics, 1 > parameters_
all distortion parameters
Definition: RadialTangentialDistortion.hpp:167
std::string type() const
The class type.
Definition: RadialTangentialDistortion.hpp:83
static std::shared_ptr< DistortionBase > createTestObject()
Unit test support – create a test distortion object.
Definition: RadialTangentialDistortion.hpp:98
double k1_
radial parameter 1
Definition: RadialTangentialDistortion.hpp:169
bool distort(const Eigen::Vector2d &pointUndistorted, Eigen::Vector2d *pointDistorted) const
Distortion only.
Definition: RadialTangentialDistortion.hpp:86
static RadialTangentialDistortion testObject()
Unit test support – create a test distortion object.
Definition: RadialTangentialDistortion.hpp:104
double p1_
tangential parameter 1
Definition: RadialTangentialDistortion.hpp:171
double p2_
tangential parameter 2
Definition: RadialTangentialDistortion.hpp:172
Header implementation file for the RadialTangentialDistortion 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: RadialTangentialDistortion.hpp:155
Header file for the DistortionBase class.
int numDistortionIntrinsics() const
Number of distortion parameters.
Definition: RadialTangentialDistortion.hpp:89
bool setParameters(const Eigen::VectorXd &parameters)
set the generic parameters
Definition: RadialTangentialDistortion.hpp:72
bool getParameters(Eigen::VectorXd &parameters) const
Obtain the generic parameters.
Definition: RadialTangentialDistortion.hpp:76
Definition: RadialTangentialDistortion.hpp:51
Base class for all distortion models.
Definition: DistortionBase.hpp:52
bool undistort(const Eigen::Vector2d &pointDistorted, Eigen::Vector2d *pointUndistorted) const
Undistortion only.
Definition: RadialTangentialDistortion.hpp:210
double k2_
radial parameter 2
Definition: RadialTangentialDistortion.hpp:170
static const int NumDistortionIntrinsics
Definition: RadialTangentialDistortion.hpp:94
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RadialTangentialDistortion()
The default constructor with all zero ki.
Definition: RadialTangentialDistortion.hpp:49