Drake
ColorPalette< IdType > Class Template Reference

Creates and holds a palette of colors for visualizing different objects in a scene (the intent is for a different color to be applied to each identified object). More...

#include <drake/systems/sensors/color_palette.h>

Public Member Functions

 ColorPalette (int num_colors, IdType terrain_id, IdType no_body_id)
 A constructor for ColorPalette. More...
 
const ColorIget_color (IdType index) const
 Returns a color of type ColorI which corresponds to given index. More...
 
ColorD get_normalized_color (IdType index) const
 Returns a color of type ColorD which corresponds to given index. More...
 
const ColorIget_sky_color () const
 Returns the color of type ColorI which corresponds to sky. More...
 
const ColorIget_terrain_color () const
 Returns the color of type ColorI which corresponds to flat terrain. More...
 
IdType LookUpId (const ColorI &color) const
 Looks up the ID which corresponds to the given color. More...
 
Does not allow copy, move, or assignment
 ColorPalette (const ColorPalette &)=delete
 
ColorPaletteoperator= (const ColorPalette &)=delete
 
 ColorPalette (ColorPalette &&)=delete
 
ColorPaletteoperator= (ColorPalette &&)=delete
 

Static Public Member Functions

static ColorD Normalize (const ColorI &color)
 Takes ColorI whose pixel range is [0, 255] and returns ColorD whose pixel range is [0, 1]. More...
 

Detailed Description

template<typename IdType>
class drake::systems::sensors::ColorPalette< IdType >

Creates and holds a palette of colors for visualizing different objects in a scene (the intent is for a different color to be applied to each identified object).

The colors are chosen so as to be easily distinguishable. In other words, the intensities are spaced as widely as possible given the number of required colors. Black, white and gray, which has the same value for all the three color channels, are not part of this color palette. This color palette can hold up to 1535 colors.

Template Parameters
IdTypeThe type of value used for label values.

Constructor & Destructor Documentation

◆ ColorPalette() [1/3]

ColorPalette ( const ColorPalette< IdType > &  )
delete

◆ ColorPalette() [2/3]

ColorPalette ( ColorPalette< IdType > &&  )
delete

◆ ColorPalette() [3/3]

ColorPalette ( int  num_colors,
IdType  terrain_id,
IdType  no_body_id 
)
inline

A constructor for ColorPalette.

Parameters
num_colorsThe number of colors that you want ColorPalette to hold. We assume this will be the number of rigid bodies in rendering scene.
terrain_idThe id to express pixels which correspond to flat terrain. This will be used in the label image.
no_body_idThe id to express pixels that have no body. This will be used in the label image.
Exceptions
std::logic_errorWhen num_colors exceeds the maximum limit, which is 1535.

Member Function Documentation

◆ get_color()

const ColorI& get_color ( IdType  index) const
inline

Returns a color of type ColorI which corresponds to given index.

The pixel range of returned color is [0, 255].

Parameters
indexAn index that corresponds to the color to be returned.

◆ get_normalized_color()

ColorD get_normalized_color ( IdType  index) const
inline

Returns a color of type ColorD which corresponds to given index.

The pixel range of returned color is [0, 1].

Parameters
indexAn index that corresponds to the color to be returned.

◆ get_sky_color()

const ColorI& get_sky_color ( ) const
inline

Returns the color of type ColorI which corresponds to sky.

The pixel range of returned color is [0, 255].

◆ get_terrain_color()

const ColorI& get_terrain_color ( ) const
inline

Returns the color of type ColorI which corresponds to flat terrain.

The pixel range of returned color is [0, 255].

◆ LookUpId()

IdType LookUpId ( const ColorI color) const
inline

Looks up the ID which corresponds to the given color.

Parameters
colorThe color you want to know the corresponding ID.

◆ Normalize()

static ColorD Normalize ( const ColorI color)
inlinestatic

Takes ColorI whose pixel range is [0, 255] and returns ColorD whose pixel range is [0, 1].

Parameters
colorAn input color to be normalized.

◆ operator=() [1/2]

ColorPalette& operator= ( const ColorPalette< IdType > &  )
delete

◆ operator=() [2/2]

ColorPalette& operator= ( ColorPalette< IdType > &&  )
delete

The documentation for this class was generated from the following file: