Gazebo Rendering

API Reference

7.4.2
gz/rendering/base/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 GZ_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_
18 #define GZ_RENDERING_BASE_BASESEGMENTATIONCAMERA_HH_
19 
20 #include <string>
21 
22 #include <gz/common/Event.hh>
23 
26 
27 namespace gz
28 {
29  namespace rendering
30  {
31  inline namespace GZ_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 gz::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