Class representing object "labels" for rendering.
In a "label image" (see RenderEngine::RenderLabelImage() for details) each pixel value indicates the classification of the object that rendered into that pixel. The RenderLabel class provides that value and one label is associated with each rendered geometry.
The labels could be unique for each geometry, or multiple geometries could all share the same label (becoming indistinguishable in the label image). Ultimately, it is the user's responsibility to assign labels in a manner that is meaningful for their application.
There are several RenderLabels that are reserved. They have specific meaning in the context of the rendering ecosystem and are globally available to all applications. They are:
empty
: a pixel with the empty
RenderLabel value indicates that no geometry rendered to that pixel. Implemented as RenderLabel::kEmpty.do not render
: any geometry assigned the do not render
tag will not be rendered into a label image. This is a clear declaration that a geometry should be omitted. Useful for marking, e.g., glass windows so that the visible geometry behind the glass is what is included in the label image. Implemented as RenderLabel::kDoNotRender.don't care
: the don't care
label is intended as a convenient dumping ground. This would be for geometry that should render into the label image, but whose class is irrelevant (e.g., the walls of a room a robot is working in or the background terrain in driving simulation). Implemented as RenderLabel::kDontCare.unspecified
: a default-constructed RenderLabel has an unspecified
value. Implemented as RenderLabel::kUnspecified.Generally, there is no good reason to assign empty
or unspecified
labels to a geometry. A RenderEngine implementation is entitled to throw an exception if you attempt to do so.
An application can simply instantiate RenderLabel with an arbitrary value. This allows the application to define a particular mapping from render label class to a preferred RenderLabel value. For a label image to be meaningful, every pixel value should admit an unambiguous interpretation. The application bears full responsibility in making sure that a single value is not inadvertently associated with multiple render classes. Finally, a RenderLabel cannot be explicitly constructed with a reserved value – those can only be accessed through the static methods provided.
#include <drake/geometry/render/render_label.h>
Public Types | |
using | ValueType = systems::sensors::ImageTraits< systems::sensors::PixelType::kLabel16I >::ChannelType |
Public Member Functions | |
RenderLabel ()=default | |
Constructs a label with the reserved unspecified value. More... | |
RenderLabel (int value) | |
Constructs a label with the given value . More... | |
bool | operator== (const RenderLabel &other) const |
Compares this label with the other label. More... | |
bool | operator!= (const RenderLabel &other) const |
Compares this label with the other label. More... | |
bool | operator< (const RenderLabel &other) const |
Allows the labels to be compared to imply a total ordering – facilitates use in data structures which require ordering (e.g., std::set). More... | |
bool | is_reserved () const |
Reports if the label is a reserved label. More... | |
operator ValueType () const | |
Implicit conversion to its underlying integer representation. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
RenderLabel (const RenderLabel &)=default | |
RenderLabel & | operator= (const RenderLabel &)=default |
RenderLabel (RenderLabel &&)=default | |
RenderLabel & | operator= (RenderLabel &&)=default |
Static Public Attributes | |
The reserved render labels | |
See class documentation on reserved labels for details. | |
static const RenderLabel | kEmpty |
See Reserved labels. More... | |
static const RenderLabel | kDoNotRender |
See Reserved labels. More... | |
static const RenderLabel | kDontCare |
See Reserved labels. More... | |
static const RenderLabel | kUnspecified |
See Reserved labels. More... | |
static const ValueType | kMaxUnreserved |
The largest value that a RenderLabel can be instantiated on. More... | |
Friends | |
class | RenderEngine |
template<class HashAlgorithm > | |
void | hash_append (HashAlgorithm &hasher, const RenderLabel &item) noexcept |
Implements the hash_append generic hashing concept. More... | |
std::ostream & | operator<< (std::ostream &out, const RenderLabel &label) |
Enables use of labels with the streaming operator. More... | |
std::string | to_string (const RenderLabel &label) |
Converts the RenderLabel value to a string representation. More... | |
using ValueType = systems::sensors::ImageTraits< systems::sensors::PixelType::kLabel16I>::ChannelType |
|
default |
|
default |
|
default |
Constructs a label with the reserved unspecified
value.
|
explicit |
Constructs a label with the given value
.
std::exception | if a) is negative, or b) the value is one of the reserved values. |
bool is_reserved | ( | ) | const |
Reports if the label is a reserved label.
operator ValueType | ( | ) | const |
Implicit conversion to its underlying integer representation.
bool operator!= | ( | const RenderLabel & | other | ) | const |
Compares this label with the other
label.
Reports true if they have different values.
bool operator< | ( | const RenderLabel & | other | ) | const |
Allows the labels to be compared to imply a total ordering – facilitates use in data structures which require ordering (e.g., std::set).
The ordering has no particular meaning for applications.
|
default |
|
default |
bool operator== | ( | const RenderLabel & | other | ) | const |
Compares this label with the other
label.
Reports true if they have the same value.
|
friend |
Implements the hash_append generic hashing concept.
|
friend |
Enables use of labels with the streaming operator.
|
friend |
|
friend |
Converts the RenderLabel value to a string representation.
|
static |
See Reserved labels.
|
static |
See Reserved labels.
|
static |
See Reserved labels.
|
static |
The largest value that a RenderLabel can be instantiated on.
|
static |
See Reserved labels.