Distortion.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_RENDERING_DISTORTION_HH_
18 #define GAZEBO_RENDERING_DISTORTION_HH_
19 
20 #include <memory>
21 #include <ignition/math/Vector2.hh>
22 
24 #include "gazebo/util/system.hh"
25 
26 namespace gazebo
27 {
30  namespace rendering
31  {
32  class DistortionPrivate;
33 
36 
39  class GZ_RENDERING_VISIBLE Distortion
40  {
42  public: Distortion();
43 
45  public: virtual ~Distortion();
46 
49  public: virtual void Load(sdf::ElementPtr _sdf);
50 
53  public: void SetCamera(CameraPtr _camera);
54 
59  public: void SetCrop(const bool _crop);
60 
65  public: bool Crop() const;
66 
69  public: double K1() const;
70 
73  public: double K2() const;
74 
77  public: double K3() const;
78 
81  public: double P1() const;
82 
85  public: double P2() const;
86 
89  public: ignition::math::Vector2d Center() const;
90 
100  public: static ignition::math::Vector2d Distort(
101  const ignition::math::Vector2d &_in,
102  const ignition::math::Vector2d &_center,
103  double _k1, double _k2, double _k3,
104  double _p1, double _p2);
105 
110  protected: ignition::math::Vector2d
111  DistortionMapValueClamped(const int x, const int y) const;
112 
116  protected: void CalculateAndApplyDistortionScale();
117 
120  private: std::unique_ptr<DistortionPrivate> dataPtr;
121  };
123  }
124 }
125 #endif
Camera distortion based on the Brown-Conrady model.
Definition: Distortion.hh:39
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90