Ignition Rendering

API Reference

6.3.1
BaseSegmentationCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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 IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_
18 #define IGNITION_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_
19 
20 #include <string>
21 
22 #include <ignition/common/Event.hh>
23 
26 
27 namespace ignition
28 {
29  namespace rendering
30  {
31  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
32 
33  template <class T>
35  public virtual SegmentationCamera,
36  public virtual BaseCamera<T>,
37  public virtual T
38  {
40  protected: BaseSegmentationCamera();
41 
43  public: virtual ~BaseSegmentationCamera();
44 
45  // Documentation inherited
46  public: virtual void CreateSegmentationTexture() override = 0;
47 
48  // Documentation inherited
49  public: virtual uint8_t *SegmentationData() const override;
50 
51  // Documentation inherited
52  public: virtual ignition::common::ConnectionPtr
53  ConnectNewSegmentationFrame(
54  std::function<void(const uint8_t *, unsigned int, unsigned int,
55  unsigned int, const std::string &)> _subscriber) override;
56 
57  // Documentation inherited
58  public: virtual void SetSegmentationType(
59  SegmentationType _type) override;
60 
61  // Documentation inherited
62  public: virtual SegmentationType Type() const override;
63 
64  // Documentation inherited
65  public: virtual void EnableColoredMap(bool _enable) override;
66 
67  // Documentation inherited
68  public: virtual bool IsColoredMap() const override;
69 
70  // Documentation inherited
71  public: virtual void SetBackgroundColor(
72  const math::Color &_color) override;
73 
74  // Documentation inherited
75  public: virtual void SetBackgroundLabel(int _label) override;
76 
77  // Documentation inherited
78  public: virtual const math::Color &BackgroundColor() const override;
79 
80  // Documentation inherited
81  public: virtual int BackgroundLabel() const override;
82 
83  // Documentation inherited
84  public: void LabelMapFromColoredBuffer(
85  uint8_t *_labelBuffer) const override = 0;
86 
88  protected: uint8_t *segmentationData {nullptr};
89 
92 
95  protected: bool isColoredMap {false};
96 
99  protected: math::Color backgroundColor {0, 0, 0};
100 
102  protected: int backgroundLabel {0};
103  };
104 
106  template <class T>
108  {
109  }
110 
112  template <class T>
114  {
115  if (this->segmentationData)
116  {
117  delete [] this->segmentationData;
118  this->segmentationData = nullptr;
119  }
120  }
121 
123  template <class T>
125  {
126  return this->segmentationData;
127  }
128 
130  template <class T>
133  std::function<void(const uint8_t *, unsigned int, unsigned int,
134  unsigned int, const std::string &)>)
135  {
136  return nullptr;
137  }
138 
140  template <class T>
142  {
143  this->type = _type;
144  }
145 
147  template <class T>
149  {
150  this->isColoredMap = _enable;
151  }
152 
154  template <class T>
156  {
157  return this->type;
158  }
159 
161  template <class T>
163  {
164  return this->isColoredMap;
165  }
166 
168  template <class T>
170  const math::Color &_color)
171  {
172  this->backgroundColor = _color;
173  }
174 
176  template <class T>
178  {
179  this->backgroundLabel = _label;
180  }
181 
183  template <class T>
185  {
186  return this->backgroundColor;
187  }
188 
190  template <class T>
192  {
193  return this->backgroundLabel;
194  }
195  }
196  }
197 }
198 #endif
virtual void EnableColoredMap(bool _enable) override
Enable Color map mode to generate colored semantics.
Definition: BaseSegmentationCamera.hh:148
Pixels of same label from different items have the same color & id.
SegmentationType
Segmentation types for Semantic / Panpoptic segmentation.
Definition: SegmentationCamera.hh:34
Definition: BaseCamera.hh:44
virtual int BackgroundLabel() const override
Get label for background & unlabeled items in the semantic map.
Definition: BaseSegmentationCamera.hh:191
virtual void SetBackgroundLabel(int _label) override
Set label for background & unlabeled items in the semantic map.
Definition: BaseSegmentationCamera.hh:177
Definition: BaseSegmentationCamera.hh:34
virtual ignition::common::ConnectionPtr ConnectNewSegmentationFrame(std::function< void(const uint8_t *, unsigned int, unsigned int, unsigned int, const std::string &)> _subscriber) override
Connect to the new Segmentation image event.
Definition: BaseSegmentationCamera.hh:132
Poseable Segmentation camera used for rendering the scene graph. This camera is designed to produce s...
Definition: SegmentationCamera.hh:51
STL class.
virtual void SetSegmentationType(SegmentationType _type) override
Set Segmentation Type.
Definition: BaseSegmentationCamera.hh:141
virtual bool IsColoredMap() const override
Check if color map mode is enabled.
Definition: BaseSegmentationCamera.hh:162
BaseSegmentationCamera()
Constructor.
Definition: BaseSegmentationCamera.hh:107
virtual ~BaseSegmentationCamera()
Destructor.
Definition: BaseSegmentationCamera.hh:113
virtual const math::Color & BackgroundColor() const override
Get color for background & unlabeled items in the colored map.
Definition: BaseSegmentationCamera.hh:184
virtual uint8_t * SegmentationData() const override
Get the segmentation image data. If the segmentation type is panoptic, the first two channels are the...
Definition: BaseSegmentationCamera.hh:124
virtual SegmentationType Type() const override
Get Segmentation Type.
Definition: BaseSegmentationCamera.hh:155
virtual void SetBackgroundColor(const math::Color &_color) override
Set color for background & unlabeled items in the colored map.
Definition: BaseSegmentationCamera.hh:169