Gazebo Rendering

API Reference

7.4.2
gz/rendering/ogre2/Ogre2SegmentationCamera.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 
18 #ifndef GZ_RENDERING_OGRE2_OGRE2SEGMENTATIONCAMERA_HH_
19 #define GZ_RENDERING_OGRE2_OGRE2SEGMENTATIONCAMERA_HH_
20 
21 #ifdef _WIN32
22  // Ensure that Winsock2.h is included before Windows.h, which can get
23  // pulled in by anybody (e.g., Boost).
24  #include <Winsock2.h>
25 #endif
26 
27 #include <memory>
28 #include <string>
29 
30 #include <gz/common/Console.hh>
31 #include <gz/common/Event.hh>
32 
37 
38 namespace gz
39 {
40  namespace rendering
41  {
42  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
43  //
44  // Forward declaration
45  class Ogre2SegmentationCameraPrivate;
46 
49  class GZ_RENDERING_OGRE2_VISIBLE Ogre2SegmentationCamera :
50  public virtual BaseSegmentationCamera<Ogre2Sensor>,
51  public virtual Ogre2ObjectInterface
52  {
54  protected: Ogre2SegmentationCamera();
55 
57  public: virtual ~Ogre2SegmentationCamera();
58 
59  // Documentation inherited
60  public: virtual void Init() override;
61 
62  // Documentation inherited
63  public: virtual void Destroy() override;
64 
65  // Documentation inherited
66  public: virtual void PreRender() override;
67 
68  // Documentation inherited
69  public: virtual void PostRender() override;
70 
71  // Documentation inherited
72  public: virtual gz::common::ConnectionPtr
73  ConnectNewSegmentationFrame(
74  std::function<void(const uint8_t *, unsigned int, unsigned int,
75  unsigned int, const std::string &)> _subscriber) override;
76 
77  // Documentation inherited
78  public: virtual void Render() override;
79 
82  protected: virtual RenderTargetPtr RenderTarget() const override;
83 
84  // Documentation inherited
85  public: void SetBackgroundLabel(int _label) override;
86 
87  // Documentation inherited
88  public: void LabelMapFromColoredBuffer(
89  uint8_t * _labelBuffer) const override;
90 
91  // Documentation inherited.
92  public: virtual Ogre::Camera *OgreCamera() const override;
93 
95  protected: void CreateCamera();
96 
98  protected: virtual void CreateRenderTexture();
99 
100  // Documentation inherited
101  protected: virtual void CreateSegmentationTexture() override;
102 
104  protected: Ogre::Camera *ogreCamera = nullptr;
105 
109 
111  private: friend class Ogre2Scene;
112  };
113  }
114  }
115 }
116 #endif