OKVIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EquidistantDistortion.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_EQUIDISTANTDISTORTION_HPP_
40 #define INCLUDE_OKVIS_CAMERAS_EQUIDISTANTDISTORTION_HPP_
41 
42 #include <memory>
43 #include <Eigen/Core>
45 
47 namespace okvis {
49 namespace cameras {
50 
54 {
55  public:
56  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
57 
59  inline EquidistantDistortion();
60 
66  inline EquidistantDistortion(double k1, double k2, double k3, double k4);
70 
74  inline bool setParameters(const Eigen::VectorXd & parameters);
75 
77  inline bool getParameters(Eigen::VectorXd & parameters) const
78  {
79  parameters = parameters_;
80  return true;
81  }
83  inline std::string type() const
84  {
85  return "EquidistantDistortion";
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 EquidistantDistortion(-0.21, 0.14, 0.0006, 0.0003));
102  }
104  static EquidistantDistortion testObject()
105  {
106  return EquidistantDistortion(-0.21, 0.14, 0.0006, 0.0003);
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 k3_;
172  double k4_;
173 };
174 
175 } // namespace cameras
176 } // namespace okvis
177 
179 
180 #endif /* INCLUDE_OKVIS_CAMERAS_EQUIDISTANTDISTORTION_HPP_ */
Implements equidistant distortion.
Definition: EquidistantDistortion.hpp:53
int numDistortionIntrinsics() const
Number of distortion parameters.
Definition: EquidistantDistortion.hpp:89
Eigen::Matrix< double, NumDistortionIntrinsics, 1 > parameters_
all distortion parameters
Definition: EquidistantDistortion.hpp:167
Header implementation file for the EquidistantDistortion class.
static EquidistantDistortion testObject()
Unit test support – create a test distortion object.
Definition: EquidistantDistortion.hpp:104
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EquidistantDistortion()
The default constructor with all zero ki.
Definition: EquidistantDistortion.hpp:49
double k2_
radial parameter 2
Definition: EquidistantDistortion.hpp:170
bool setParameters(const Eigen::VectorXd &parameters)
set the generic parameters
Definition: EquidistantDistortion.hpp:72
Header file for the DistortionBase class.
static std::shared_ptr< DistortionBase > createTestObject()
Unit test support – create a test distortion object.
Definition: EquidistantDistortion.hpp:98
double k1_
radial parameter 1
Definition: EquidistantDistortion.hpp:169
std::string type() const
The class type.
Definition: EquidistantDistortion.hpp:83
bool getParameters(Eigen::VectorXd &parameters) const
Obtain the generic parameters.
Definition: EquidistantDistortion.hpp:77
static const int NumDistortionIntrinsics
Definition: EquidistantDistortion.hpp:94
bool distort(const Eigen::Vector2d &pointUndistorted, Eigen::Vector2d *pointDistorted) const
Distortion only.
Definition: EquidistantDistortion.hpp:85
Base class for all distortion models.
Definition: DistortionBase.hpp:52
double k4_
tangential parameter 2
Definition: EquidistantDistortion.hpp:172
double k3_
tangential parameter 1
Definition: EquidistantDistortion.hpp:171
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: EquidistantDistortion.hpp:208
bool undistort(const Eigen::Vector2d &pointDistorted, Eigen::Vector2d *pointUndistorted) const
Undistortion only.
Definition: EquidistantDistortion.hpp:316