Camera.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 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 SDF_CAMERA_HH_
18 #define SDF_CAMERA_HH_
19 
20 #include <string>
21 #include <ignition/math/Pose3.hh>
22 #include <ignition/utils/ImplPtr.hh>
23 
24 #include <sdf/Error.hh>
25 #include <sdf/Element.hh>
26 #include <sdf/Noise.hh>
27 #include <sdf/sdf_config.h>
28 
29 namespace sdf
30 {
31  // Inline bracket to help doxygen filtering.
32  inline namespace SDF_VERSION_NAMESPACE {
36  enum class PixelFormatType
37  {
39  L_INT8,
40  L_INT16,
41  RGB_INT8,
42  RGBA_INT8,
43  BGRA_INT8,
44  RGB_INT16,
45  RGB_INT32,
46  BGR_INT8,
47  BGR_INT16,
48  BGR_INT32,
49  R_FLOAT16,
51  R_FLOAT32,
57  };
58 
61  {
63  public: Camera();
64 
68  public: bool operator==(const Camera &_alt) const;
69 
74  public: bool operator!=(const Camera &_alt) const;
75 
82  public: Errors Load(ElementPtr _sdf);
83 
88  public: sdf::ElementPtr Element() const;
89 
92  public: std::string Name() const;
93 
96  public: void SetName(const std::string &_name);
97 
100  public: bool Triggered() const;
101 
104  public: void SetTriggered(bool _triggered);
105 
108  public: std::string TriggerTopic() const;
109 
112  public: void SetTriggerTopic(const std::string &_triggerTopic);
113 
116  public: ignition::math::Angle HorizontalFov() const;
117 
120  public: void SetHorizontalFov(const ignition::math::Angle &_hfov);
121 
124  public: uint32_t ImageWidth() const;
125 
128  public: void SetImageWidth(uint32_t _width);
129 
132  public: uint32_t ImageHeight() const;
133 
136  public: void SetImageHeight(uint32_t _height);
137 
141  public: PixelFormatType PixelFormat() const;
142 
145  public: void SetPixelFormat(PixelFormatType _format);
146 
149  public: std::string PixelFormatStr() const;
150 
153  public: void SetPixelFormatStr(const std::string &_fmt);
154 
157  public: uint32_t AntiAliasingValue() const;
158 
161  public: void SetAntiAliasingValue(uint32_t _antiAliasingValue);
162 
165  public: double DepthNearClip() const;
166 
169  public: void SetDepthNearClip(double _near);
170 
173  public: double DepthFarClip() const;
174 
177  public: void SetDepthFarClip(double _far);
178 
181  public: double NearClip() const;
182 
185  public: void SetNearClip(double _near);
186 
189  public: void SetHasDepthCamera(bool _camera);
190 
193  public: bool HasDepthCamera() const;
194 
199  public: void SetHasDepthNearClip(bool _near);
200 
203  public: bool HasDepthNearClip() const;
204 
209  public: void SetHasDepthFarClip(bool _far);
210 
213  public: bool HasDepthFarClip() const;
214 
217  public: double FarClip() const;
218 
221  public: void SetFarClip(double _far);
222 
226  public: void SetHasSegmentationType(bool _type);
227 
230  public: bool HasSegmentationType() const;
231 
234  public: const std::string &SegmentationType() const;
235 
238  public: void SetSegmentationType(const std::string &_type);
239 
243  public: void SetHasBoundingBoxType(bool _type);
244 
247  public: bool HasBoundingBoxType() const;
248 
251  public: const std::string &BoundingBoxType() const;
252 
255  public: void SetBoundingBoxType(const std::string &_type);
256 
259  public: bool SaveFrames() const;
260 
263  public: void SetSaveFrames(bool _save);
264 
267  public: const std::string &SaveFramesPath() const;
268 
271  public: void SetSaveFramesPath(const std::string &_path);
272 
275  public: const Noise &ImageNoise() const;
276 
279  public: void SetImageNoise(const Noise &_noise);
280 
283  public: double DistortionK1() const;
284 
287  public: void SetDistortionK1(double _k1);
288 
291  public: double DistortionK2() const;
292 
295  public: void SetDistortionK2(double _k2);
296 
299  public: double DistortionK3() const;
300 
303  public: void SetDistortionK3(double _k3);
304 
307  public: double DistortionP1() const;
308 
311  public: void SetDistortionP1(double _p1);
312 
315  public: double DistortionP2() const;
316 
319  public: void SetDistortionP2(double _p2);
320 
323  public: const ignition::math::Vector2d &DistortionCenter() const;
324 
327  public: void SetDistortionCenter(const ignition::math::Vector2d &_center);
328 
332  public: const ignition::math::Pose3d &RawPose() const;
333 
337  public: void SetRawPose(const ignition::math::Pose3d &_pose);
338 
343  public: const std::string &PoseRelativeTo() const;
344 
349  public: void SetPoseRelativeTo(const std::string &_frame);
350 
357  public: std::string LensType() const;
358 
362  public: void SetLensType(const std::string &_type);
363 
367  public: bool LensScaleToHfov() const;
368 
372  public: void SetLensScaleToHfov(bool _scale);
373 
376  public: double LensC1() const;
377 
380  public: void SetLensC1(double _c1);
381 
384  public: double LensC2() const;
385 
388  public: void SetLensC2(double _c2);
389 
392  public: double LensC3() const;
393 
396  public: void SetLensC3(double _c3);
397 
400  public: double LensFocalLength() const;
401 
404  public: void SetLensFocalLength(double _f);
405 
409  public: const std::string &LensFunction() const;
410 
414  public: void SetLensFunction(const std::string &_fun);
415 
419  public: ignition::math::Angle LensCutoffAngle() const;
420 
424  public: void SetLensCutoffAngle(const ignition::math::Angle &_angle);
425 
429  public: int LensEnvironmentTextureSize() const;
430 
434  public: void SetLensEnvironmentTextureSize(int _size);
435 
438  public: double LensIntrinsicsFx() const;
439 
442  public: void SetLensIntrinsicsFx(double _fx);
443 
446  public: double LensIntrinsicsFy() const;
447 
450  public: void SetLensIntrinsicsFy(double _fy);
451 
454  public: double LensIntrinsicsCx() const;
455 
458  public: void SetLensIntrinsicsCx(double _cx);
459 
462  public: double LensIntrinsicsCy() const;
463 
466  public: void SetLensIntrinsicsCy(double _cy);
467 
470  public: double LensIntrinsicsSkew() const;
471 
474  public: void SetLensIntrinsicsSkew(double _s);
475 
480  const std::string &_format);
481 
485  public: static std::string ConvertPixelFormat(PixelFormatType _type);
486 
489  public: uint32_t VisibilityMask() const;
490 
493  public: void SetVisibilityMask(uint32_t _mask);
494 
497  public: bool HasLensIntrinsics() const;
498 
504  public: sdf::ElementPtr ToElement() const;
505 
507  IGN_UTILS_IMPL_PTR(dataPtr)
508  };
509  }
510 }
511 
512 #endif
Information about a monocular camera sensor.
Definition: Camera.hh:61
bool HasDepthFarClip() const
Get whether the depth camera far clip distance was set.
const ignition::math::Vector2d & DistortionCenter() const
Get the distortion center or principal point.
double DistortionK1() const
Get the radial distortion coefficient k1.
double LensC1() const
Get lens custom function linear scaling constant.
double DepthFarClip() const
Get the far clip distance for the depth camera.
void SetDistortionCenter(const ignition::math::Vector2d &_center)
Set the distortion center or principal point.
void SetTriggered(bool _triggered)
Set whether the camera should be triggered by a topic.
void SetBoundingBoxType(const std::string &_type)
Set the boundingbox type.
void SetHasDepthCamera(bool _camera)
Set whether the depth camera has been specified.
uint32_t VisibilityMask() const
Get the visibility mask of a camera.
uint32_t ImageHeight() const
Get the image height in pixels.
void SetDistortionP1(double _p1)
Set the tangential distortion coefficient p1.
void SetSaveFrames(bool _save)
Set whether frames should be saved.
void SetHasDepthFarClip(bool _far)
Set whether the depth camera far clip distance has been specified.
static std::string ConvertPixelFormat(PixelFormatType _type)
Convert a PixelFormatType to a string.
void SetLensC3(double _c3)
Set lens custom function angle offset constant.
void SetLensCutoffAngle(const ignition::math::Angle &_angle)
Set lens cutoff angle.
void SetFarClip(double _far)
Set the far clip distance.
bool SaveFrames() const
Get whether frames should be saved.
void SetDepthNearClip(double _near)
Set the near clip distance for the depth camera.
void SetImageWidth(uint32_t _width)
Set the image width in pixels.
void SetLensFocalLength(double _f)
Set lens custom function focal length.
void SetDepthFarClip(double _far)
Set the far clip distance for the depth camera.
PixelFormatType PixelFormat() const
Get the pixel format.
void SetLensEnvironmentTextureSize(int _size)
Set environment texture size.
void SetAntiAliasingValue(uint32_t _antiAliasingValue)
Set the anti-aliasing value.
double DistortionP2() const
Get the tangential distortion coefficient p2.
void SetHasSegmentationType(bool _type)
Set whether the segmentation type has been specified.
void SetRawPose(const ignition::math::Pose3d &_pose)
Set the pose of the camera.
double LensFocalLength() const
Get lens custom function focal length.
void SetSegmentationType(const std::string &_type)
Set the segmentation type.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
void SetName(const std::string &_name)
Set the name of the camera.
static PixelFormatType ConvertPixelFormat(const std::string &_format)
Convert a string to a PixelFormatType.
const std::string & BoundingBoxType() const
Get the boundingbox type.
void SetDistortionK1(double _k1)
Set the radial distortion coefficient k1.
double DistortionK3() const
Get the radial distortion coefficient k3.
std::string PixelFormatStr() const
Get the pixel format as a string.
bool HasDepthCamera() const
Get whether the depth camera was set.
void SetLensIntrinsicsFx(double _fx)
Set the lens X focal length in pixels.
void SetLensIntrinsicsSkew(double _s)
Set the lens XY axis skew.
int LensEnvironmentTextureSize() const
Get environment texture size.
double DistortionK2() const
Get the radial distortion coefficient k2.
void SetLensScaleToHfov(bool _scale)
Set lens scale to horizontal field of field.
void SetPixelFormat(PixelFormatType _format)
Set the pixel format type.
void SetSaveFramesPath(const std::string &_path)
Set the path in which to save frames.
void SetDistortionP2(double _p2)
Set the tangential distortion coefficient p2.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
double LensIntrinsicsFy() const
Get the lens Y focal length in pixels.
void SetImageNoise(const Noise &_noise)
Set the noise values related to the image.
double FarClip() const
Get the far clip distance.
void SetImageHeight(uint32_t _height)
Set the image height in pixels.
bool Triggered() const
Get whether the camera is triggered by a topic.
double LensIntrinsicsFx() const
Get the lens X focal length in pixels.
bool HasBoundingBoxType() const
Get whether the boundingbox type was set.
double NearClip() const
Get the near clip distance.
void SetDistortionK2(double _k2)
Set the radial distortion coefficient k2.
uint32_t ImageWidth() const
Get the image width in pixels.
void SetPixelFormatStr(const std::string &_fmt)
Set the pixel format from a string.
bool LensScaleToHfov() const
Get lens scale to horizontal field of field.
double LensIntrinsicsCx() const
Get the lens X principal point in pixels.
double LensC3() const
Get lens custom function angle offset constant.
double DepthNearClip() const
Get the near clip distance for the depth camera.
std::string Name() const
Get the name of the camera.
bool HasLensIntrinsics() const
Get whether or not the camera has instrinsics values set.
bool HasDepthNearClip() const
Get whether the depth camera near clip distance was set.
std::string TriggerTopic() const
Get the topic that will trigger the camera.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
void SetLensIntrinsicsFy(double _fy)
Set the lens Y focal length in pixels.
ignition::math::Angle LensCutoffAngle() const
Get lens cutoff angle.
const ignition::math::Pose3d & RawPose() const
Get the pose of the camer.
bool operator!=(const Camera &_alt) const
Return true this Camera object does not contain the same values as the passed in parameter.
uint32_t AntiAliasingValue() const
Get the anti-aliasing value.
void SetLensIntrinsicsCy(double _cy)
Set the lens Y principal point in pixels.
void SetLensC1(double _c1)
Set lens custom function linear scaling constant.
Errors Load(ElementPtr _sdf)
Load the camera sensor based on an element pointer.
void SetLensIntrinsicsCx(double _cx)
Set the lens X principal point in pixels.
void SetLensType(const std::string &_type)
Set the lens type.
double LensIntrinsicsCy() const
Get the lens Y principal point in pixels.
const std::string & SegmentationType() const
Get the segmentation type.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this camera.
ignition::math::Angle HorizontalFov() const
Get the horizontal field of view in radians.
double LensIntrinsicsSkew() const
Get the lens XY axis skew.
void SetDistortionK3(double _k3)
Set the radial distortion coefficient k3.
std::string LensType() const
Get the lens type.
void SetHasDepthNearClip(bool _near)
Set whether the depth camera near clip distance has been specified.
void SetNearClip(double _near)
Set the near clip distance.
const Noise & ImageNoise() const
Get the image noise values.
void SetLensC2(double _c2)
Set lens custom function angular scaling constant.
void SetHorizontalFov(const ignition::math::Angle &_hfov)
Set the horizontal field of view in radians.
bool HasSegmentationType() const
Get whether the segmentation type was set.
double LensC2() const
Get lens custom function angular scaling constant.
void SetLensFunction(const std::string &_fun)
Set lens custom function.
void SetHasBoundingBoxType(bool _type)
Set whether the boundingbox type has been specified.
double DistortionP1() const
Get the tangential distortion coefficient p1.
const std::string & SaveFramesPath() const
Get the path in which to save frames.
void SetVisibilityMask(uint32_t _mask)
Set the visibility mask of a camera.
const std::string & LensFunction() const
Get lens custom function.
bool operator==(const Camera &_alt) const
Return true if both Camera objects contain the same values.
void SetTriggerTopic(const std::string &_triggerTopic)
Set the topic that will trigger the camera.
The Noise class contains information about a noise model, such as a Gaussian distribution.
Definition: Noise.hh:48
PixelFormatType
The set of pixel formats.
Definition: Camera.hh:37
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
namespace for Simulation Description Format parser
Definition: Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25