Gazebo Sensors

API Reference

6.9.0
gz/sensors/SegmentationCameraSensor.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 IGNITION_SENSORS_SEGMENTATIONCAMERASENSOR_HH_
19 #define IGNITION_SENSORS_SEGMENTATIONCAMERASENSOR_HH_
20 
21 #include <memory>
22 #include <string>
23 
24 #include <ignition/common/Event.hh>
25 #include <ignition/common/PluginMacros.hh>
26 #include <ignition/common/SuppressWarning.hh>
27 #include <ignition/common/Time.hh>
28 #include <ignition/msgs.hh>
29 #include <ignition/transport/Node.hh>
30 #include <ignition/transport/Publisher.hh>
31 #include <sdf/sdf.hh>
32 
36 
38 
39 namespace ignition
40 {
41  namespace sensors
42  {
43  // Inline bracket to help doxygen filtering.
44  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
45  // forward declarations
46  class SegmentationCameraSensorPrivate;
47 
55  class IGNITION_SENSORS_SEGMENTATION_CAMERA_VISIBLE
57  {
60 
62  public: virtual ~SegmentationCameraSensor();
63 
67  public: virtual bool Load(const sdf::Sensor &_sdf) override;
68 
72  public: virtual bool Load(sdf::ElementPtr _sdf) override;
73 
76  public: virtual bool Init() override;
77 
81  public: virtual bool Update(
82  const std::chrono::steady_clock::duration &_now) override;
83 
86  public: rendering::SegmentationCameraPtr SegmentationCamera() const;
87 
94  public: void OnNewSegmentationFrame(const uint8_t * _data,
95  unsigned int _width, unsigned int _height, unsigned int _channels,
96  const std::string &_format);
97 
106  public: ignition::common::ConnectionPtr ConnectImageCallback(
107  std::function<void(const ignition::msgs::Image &)> _callback);
108 
111  public: virtual void SetScene(
112  ignition::rendering::ScenePtr _scene) override;
113 
116  public: virtual unsigned int ImageWidth() const override;
117 
120  public: virtual unsigned int ImageHeight() const override;
121 
125  public: bool HasConnections() const;
126 
129  private: bool CreateCamera();
130 
131  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
135  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
136  };
137  }
138  }
139 }
140 
141 #endif
Camera Sensor Class.
Definition: gz/sensors/CameraSensor.hh:72
Segmentation camera sensor class.
Definition: gz/sensors/SegmentationCameraSensor.hh:57
virtual void SetScene(ignition::rendering::ScenePtr _scene) override
Set the rendering scene.
void OnNewSegmentationFrame(const uint8_t *_data, unsigned int _width, unsigned int _height, unsigned int _channels, const std::string &_format)
Segmentation data callback used to get the data from the sensor.
ignition::common::ConnectionPtr ConnectImageCallback(std::function< void(const ignition::msgs::Image &)> _callback)
Set a callback to be called when image frame data is generated.
virtual bool Load(sdf::ElementPtr _sdf) override
Load the sensor with SDF parameters.
virtual bool Load(const sdf::Sensor &_sdf) override
Load the sensor based on data from an sdf::Sensor object.
virtual unsigned int ImageHeight() const override
Get image height.
virtual bool Update(const std::chrono::steady_clock::duration &_now) override
Force the sensor to generate data.
rendering::SegmentationCameraPtr SegmentationCamera() const
Get the rendering segmentation camera.
virtual bool Init() override
Initialize values in the sensor.
bool HasConnections() const
Check if there are any subscribers.
virtual unsigned int ImageWidth() const override
Get image width.
Definition: gz/sensors/AirPressureSensor.hh:32