Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bounding box sensor API stubs #420

Merged
merged 10 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ci/packages.apt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ libglew-dev
libignition-cmake2-dev
libignition-common4-dev
libignition-math6-dev
libignition-math6-eigen3-dev
libignition-plugin-dev
libogre-1.9-dev
libogre-2.2-dev
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ option(USE_UNOFFICAL_OGRE_VERSIONS "Accept unsupported Ogre versions in the buil

#--------------------------------------
# Find ignition-math
ign_find_package(ignition-math6 REQUIRED VERSION 6.6)
ign_find_package(ignition-math6 REQUIRED COMPONENTS eigen3 VERSION 6.9)
set(IGN_MATH_VER ${ignition-math6_VERSION_MAJOR})

#--------------------------------------
Expand Down
47 changes: 47 additions & 0 deletions include/ignition/rendering/BoundingBox.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_RENDERING_BOUNDINGBOX_HH_
#define IGNITION_RENDERING_BOUNDINGBOX_HH_

#include <memory>

#include <ignition/common/SuppressWarning.hh>

#include "ignition/rendering/config.hh"
#include "ignition/rendering/Export.hh"

namespace ignition
{
namespace rendering
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
class BoundingBoxPrivate;

/// \brief 2D or 3D Bounding box. It stores the
/// position / orientation / size info of the box and its label
class IGNITION_RENDERING_VISIBLE BoundingBox
{
/// \internal
/// \brief Private data
IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
private: std::unique_ptr<BoundingBoxPrivate> dataPtr;
IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
};
}
}
}
#endif
89 changes: 89 additions & 0 deletions include/ignition/rendering/BoundingBoxCamera.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_
#define IGNITION_RENDERING_BOUNDINGBOXCAMERA_HH_

#include <cstdint>
#include <vector>

#include <ignition/common/Event.hh>
#include <ignition/math/Color.hh>
#include <ignition/math/Vector3.hh>

#include "ignition/rendering/BoundingBox.hh"
#include "ignition/rendering/Camera.hh"

namespace ignition
{
namespace rendering
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
/// \brief BoundingBox types for Visible / Full 2D Boxes / 3D Boxes
enum class BoundingBoxType
{
/// 2D box that shows the full box of occluded objects
BBT_FULLBOX2D = 0,

/// 2D box that shows the visible part of the
/// occluded object
BBT_VISIBLEBOX2D = 1,

/// 3D oriented box
BBT_BOX3D = 2
};

/// \class BoundingBoxCamera BoundingBoxCamera.hh
/// ignition/rendering/BoundingBoxCamera.hh
/// \brief Poseable BoundingBox camera used for rendering bounding boxes of
/// objects in the scene.
class IGNITION_RENDERING_VISIBLE BoundingBoxCamera :
public virtual Camera
{
/// \brief Destructor
public: virtual ~BoundingBoxCamera() { }

/// \brief Get the BoundingBox data
/// \return Buffer of bounding boxes info (label, minX, minY, maxX, maxY)
public: virtual const std::vector<BoundingBox> &BoundingBoxData()
const = 0;
adlarkin marked this conversation as resolved.
Show resolved Hide resolved

/// \brief Connect to the new BoundingBox info
/// \param[in] _subscriber Subscriber callback function
/// \return Pointer to the new Connection. This must be kept in scope
public: virtual ignition::common::ConnectionPtr ConnectNewBoundingBoxes(
std::function<void(const std::vector<BoundingBox> &)> _subscriber) = 0;

/// \brief Set BoundingBox Type (Visible / Full)
/// \param[in] _type BoundingBox Type (Visible / Full)
public: virtual void SetBoundingBoxType(BoundingBoxType _type) = 0;

/// \brief Get the BoundingBox Type (Visible / Full)
/// \return BoundingBox Type (Visible / Full)
public: virtual BoundingBoxType Type() const = 0;

/// \brief Draw a bounding box on the given image
/// \param[in] _data buffer containing the image data
/// \param[in] _color Color of the bounding box to be drawn
/// \param[in] _box bounding box to be drawn
public: virtual void DrawBoundingBox(unsigned char *_data,
const math::Color &_color, const BoundingBox &_box) const = 0;
};
}
}
}
#endif
4 changes: 3 additions & 1 deletion include/ignition/rendering/PixelFormat.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ namespace ignition
PF_FLOAT32_RGB = 10,
// 16 bit single channel
PF_L16 = 11,
/// < RGBA, 1-byte per channel
PF_R8G8B8A8 = 12,
/// < Number of pixel format types
PF_COUNT = 12
PF_COUNT = 13
};

/// \class PixelUtil PixelFormat.hh ignition/rendering/PixelFormat.hh
Expand Down
9 changes: 9 additions & 0 deletions include/ignition/rendering/RenderTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace ignition

class ArrowVisual;
class AxisVisual;
class BoundingBoxCamera;
class Camera;
class Capsule;
class COMVisual;
Expand Down Expand Up @@ -112,6 +113,10 @@ namespace ignition
/// \brief Shared pointer to ThermalCamera
typedef shared_ptr<ThermalCamera> ThermalCameraPtr;

/// \typedef BoundingBoxCameraPtr
/// \brief Shared pointer to BoundingBoxCamera
typedef shared_ptr<BoundingBoxCamera> BoundingBoxCameraPtr;

/// \typedef SegmentationCameraPtr
/// \brief Shared pointer to Segmentation Camera
typedef shared_ptr<SegmentationCamera> SegmentationCameraPtr;
Expand Down Expand Up @@ -282,6 +287,10 @@ namespace ignition
/// \brief Shared pointer to const ThermalCamera
typedef shared_ptr<const ThermalCamera> ConstThermalCameraPtr;

/// \typedef const BoundingBoxCameraPtr
/// \brief Shared pointer to const BoundingBox Camera
typedef shared_ptr<const BoundingBoxCamera> ConstBoundingBoxCameraPtr;

/// \typedef const SegmentationCameraPtr
/// \brief Shared pointer to const Segmentation Camera
typedef shared_ptr<const SegmentationCamera> ConstSegmentationCameraPtr;
Expand Down
29 changes: 29 additions & 0 deletions include/ignition/rendering/Scene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,35 @@ namespace ignition
public: virtual ThermalCameraPtr CreateThermalCamera(
unsigned int _id, const std::string &_name) = 0;

/// \brief Create new BoundingBox camera. A unique ID and name will
/// automatically be assigned to the camera.
/// \return The created camera
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera() = 0;

/// \brief Create new BoundingBox camera with the given ID.
/// A unique name will automatically be assigned to the camera.
/// If the given ID is already in use, NULL will be returned.
/// \param[in] _id ID of the new camera
/// \return The created camera
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
unsigned int _id) = 0;

/// \brief Create new BoundingBox camera with the given name.
/// A unique ID will automatically be assigned to the camera.
/// If the given name is already in use, NULL will be returned.
/// \param[in] _name Name of the new camera
/// \return The created camera
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
const std::string &_name) = 0;

/// \brief Create new BoundingBox camera with the given ID & name. If
/// either the given ID or name is already in use, will return NULL.
/// \param[in] _id ID of the new camera
/// \param[in] _name Name of the new camera
/// \return The created camera
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
unsigned int _id, const std::string &_name) = 0;

/// \brief Create new segmentation camera. A unique ID and name will
/// automatically be assigned to the camera.
/// \return The created camera
Expand Down
105 changes: 105 additions & 0 deletions include/ignition/rendering/base/BaseBoundingBoxCamera.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_
#define IGNITION_RENDERING_BASE_BASEBOUNDINGBOXCAMERA_HH_

#include <vector>

#include <ignition/common/Event.hh>
#include <ignition/math/Color.hh>

#include "ignition/rendering/base/BaseCamera.hh"
#include "ignition/rendering/BoundingBoxCamera.hh"

namespace ignition
{
namespace rendering
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {

template <class T>
class BaseBoundingBoxCamera:
public virtual BoundingBoxCamera,
public virtual BaseCamera<T>,
public virtual T
{
/// \brief Constructor
protected: BaseBoundingBoxCamera();

/// \brief Destructor
public: virtual ~BaseBoundingBoxCamera();

// Documentation inherited
public: virtual const std::vector<BoundingBox> &BoundingBoxData() const;

// Documentation inherited
public: virtual ignition::common::ConnectionPtr ConnectNewBoundingBoxes(
std::function<void(const std::vector<BoundingBox> &)> _subscriber) = 0;

// Documentation inherited
public: virtual void SetBoundingBoxType(BoundingBoxType _type);

// Documentation inherited
public: virtual BoundingBoxType Type() const;

// Documentation inherited
public: virtual void DrawBoundingBox(unsigned char *_data,
const math::Color &_color, const BoundingBox &_box) const = 0;

/// \brief The bounding box type
protected: BoundingBoxType type = BoundingBoxType::BBT_FULLBOX2D;

/// \brief The bounding box data
protected: std::vector<BoundingBox> boundingBoxes;
};

//////////////////////////////////////////////////
template <class T>
BaseBoundingBoxCamera<T>::BaseBoundingBoxCamera()
{
}

//////////////////////////////////////////////////
template <class T>
BaseBoundingBoxCamera<T>::~BaseBoundingBoxCamera()
{
}

//////////////////////////////////////////////////
template <class T>
const std::vector<BoundingBox> &
BaseBoundingBoxCamera<T>::BoundingBoxData() const
{
return this->boundingBoxes;
}

//////////////////////////////////////////////////
template <class T>
void BaseBoundingBoxCamera<T>::SetBoundingBoxType(BoundingBoxType _type)
{
this->type = _type;
}

//////////////////////////////////////////////////
template <class T>
BoundingBoxType BaseBoundingBoxCamera<T>::Type() const
{
return this->type;
}
}
}
}
30 changes: 30 additions & 0 deletions include/ignition/rendering/base/BaseScene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,21 @@ namespace ignition
public: virtual ThermalCameraPtr CreateThermalCamera(
const unsigned int _id, const std::string &_name) override;

// Documentation inherited.
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera() override;

// Documentation inherited.
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
const unsigned int _id) override;

// Documentation inherited.
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
const std::string &_name) override;

// Documentation inherited.
public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
const unsigned int _id, const std::string &_name) override;

// Documentation inherited.
public: virtual SegmentationCameraPtr CreateSegmentationCamera() override;

Expand Down Expand Up @@ -615,6 +630,21 @@ namespace ignition
return ThermalCameraPtr();
}

/// \brief Implementation for creating a BoundingBox camera.
/// \param[in] _id Unique id
/// \param[in] _name Name of BoundingBox camera
/// \return Pointer to BoundingBox camera
protected: virtual BoundingBoxCameraPtr CreateBoundingBoxCameraImpl(
unsigned int _id, const std::string &_name)
{
// The following two lines will avoid doxygen warnings
(void)_id;
(void)_name;
ignerr << "BoundingBox camera not supported by: "
<< this->Engine()->Name() << std::endl;
return BoundingBoxCameraPtr();
}

/// \brief Implementation for creating a segmentation camera.
/// \param[in] _id Unique id
/// \param[in] _name Name of segmentation camera
Expand Down
Loading