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 #include <sdf/Element.hh>
23 
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
31  namespace rendering
32  {
33  class DistortionPrivate;
34 
37 
40  class GZ_RENDERING_VISIBLE Distortion
41  {
43  public: Distortion();
44 
46  public: virtual ~Distortion();
47 
50  public: virtual void Load(sdf::ElementPtr _sdf);
51 
54  public: void SetCamera(CameraPtr _camera);
55 
59  public: void RefreshCompositor(CameraPtr _camera);
60 
66  public: void SetCrop(const bool _crop);
67 
72  public: bool Crop() const;
73 
76  public: double K1() const;
77 
80  public: double K2() const;
81 
84  public: double K3() const;
85 
88  public: double P1() const;
89 
92  public: double P2() const;
93 
96  public: ignition::math::Vector2d Center() const;
97 
107  public: static ignition::math::Vector2d Distort(
108  const ignition::math::Vector2d &_in,
109  const ignition::math::Vector2d &_center,
110  double _k1, double _k2, double _k3,
111  double _p1, double _p2);
112 
124  public: static ignition::math::Vector2d Distort(
125  const ignition::math::Vector2d &_in,
126  const ignition::math::Vector2d &_center,
127  double _k1, double _k2, double _k3,
128  double _p1, double _p2,
129  unsigned int _width, double _f);
130 
135  protected: ignition::math::Vector2d
136  DistortionMapValueClamped(const int x, const int y) const;
137 
142 
145  private: std::unique_ptr<DistortionPrivate> dataPtr;
146  };
148  }
149 }
150 #endif
rendering
Definition: RenderEngine.hh:31
Camera distortion based on the Brown-Conrady model.
Definition: Distortion.hh:41
static ignition::math::Vector2d Distort(const ignition::math::Vector2d &_in, const ignition::math::Vector2d &_center, double _k1, double _k2, double _k3, double _p1, double _p2)
Apply distortion model.
ignition::math::Vector2d DistortionMapValueClamped(const int x, const int y) const
get the distortion map value.
ignition::math::Vector2d Center() const
Get the distortion center.
void SetCrop(const bool _crop)
Set whether to crop the black border around the distorted image points.
void RefreshCompositor(CameraPtr _camera)
Add the distortion compositor to a camera.
virtual ~Distortion()
Destructor.
void CalculateAndApplyDistortionScale()
calculate the correct scale factor to "zoom" the render, cutting off black borders caused by distorti...
double K2() const
Get the radial distortion coefficient k2.
bool Crop() const
Get whether or not the camera is being cropped to account for black borders created by barrel distort...
void SetCamera(CameraPtr _camera)
Set the camera which distortion will be applied to.
double P1() const
Get the tangential distortion coefficient p1.
virtual void Load(sdf::ElementPtr _sdf)
Load the camera with a set of parmeters.
double K1() const
Get the radial distortion coefficient k1.
double K3() const
Get the radial distortion coefficient k3.
double P2() const
Get the tangential distortion coefficient p2.
static ignition::math::Vector2d Distort(const ignition::math::Vector2d &_in, const ignition::math::Vector2d &_center, double _k1, double _k2, double _k3, double _p1, double _p2, unsigned int _width, double _f)
Apply distortion model using camera coordinates projection.
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90
Forward declarations for the common classes.
Definition: Animation.hh:27