Fawkes API  Fawkes Development Version
firevision::YuvColormap Class Reference

YUV Colormap. More...

#include <>>

Inheritance diagram for firevision::YuvColormap:

Public Member Functions

 YuvColormap (unsigned int depth=1, unsigned int width=256, unsigned int height=256)
 Constructor. More...
 
 YuvColormap (const char *shmem_lut_id, unsigned int depth=1, unsigned int width=256, unsigned int height=256)
 Constructor. More...
 
 YuvColormap (const char *shmem_lut_id, bool destroy_on_free, unsigned int depth=1, unsigned int width=256, unsigned int height=256)
 Constructor. More...
 
 YuvColormap (YuvColormap *cm, const char *shmem_lut_id, bool destroy_on_free=false)
 Constructor. More...
 
 YuvColormap (const YuvColormap &cm)
 Copy constructor. More...
 
virtual ~YuvColormap ()
 Destructor. More...
 
virtual color_t determine (unsigned int y, unsigned int u, unsigned int v) const
 Determine color class for given YUV value. More...
 
virtual void set (unsigned int y, unsigned int u, unsigned int v, color_t c)
 Set color class for given YUV value. More...
 
virtual void reset ()
 Reset colormap. More...
 
virtual void set (unsigned char *buffer)
 Set to the given raw buffer. More...
 
virtual size_t size ()
 Size in bytes of buffer returned by get_buffer(). More...
 
virtual unsigned char * get_buffer () const
 Get the raw buffer of this colormap. More...
 
virtual Colormapoperator+= (const Colormap &cmlt)
 Adds the given colormap to this colormap. More...
 
virtual Colormapoperator+= (const char *filename)
 Convenience method for the method above. More...
 
virtual Colormapoperator= (const YuvColormap &yuvcm)
 Assign operation. More...
 
virtual unsigned int width () const
 Get width of colormap. More...
 
virtual unsigned int height () const
 Get height of colormap. More...
 
virtual unsigned int depth () const
 Get depth of colormap. More...
 
virtual unsigned int deepness () const
 Get deepness of colormap. More...
 
unsigned int plane_size () const
 Get U/V plane size. More...
 
virtual std::list< ColormapFileBlock * > get_blocks ()
 Get file blocks for this colormap. More...
 
void copy_uvplane (unsigned char *uvplane, unsigned int level)
 Copy single U/V plane. More...
 
void replace_color (color_t from, color_t to)
 Replace a given color with another one. More...
 
- Public Member Functions inherited from firevision::Colormap
virtual ~Colormap ()
 Virtual empty destructor. More...
 
virtual void to_image (unsigned char *yuv422_planar_buffer, unsigned int level=0)
 Create image from LUT. More...
 
virtual unsigned int image_height () const
 Height of conversion image. More...
 
virtual unsigned int image_width () const
 Width of conversion image. More...
 

Detailed Description

YUV Colormap.

This class is the implementation of a 3D YUV colormap. The U/V planes are always sampled in full. In general for colormaps we assume that in many cases the luminance can be ignored completely. This allows for small datasets with speedy access and sufficient discriminatory power. However, in some situations this is not enough. In that case you can give a depth for the Y value. The Y axis is then separated in the given number of ranges, each range is a stacked complete U/V plane. Note, only depth values where depth = 2^n, n from natural numbers holds will provide with equal ranges. Other values will lead to one bigger range, being the one with the highest Y values which will be filled with the whole rest.

You can see such a colormap as a colormap that consists of UV planes that represent a certain Y range stacked on top of each other.

Author
Tim Niemueller

Definition at line 35 of file yuvcm.h.

Constructor & Destructor Documentation

◆ YuvColormap() [1/5]

firevision::YuvColormap::YuvColormap ( unsigned int  depth = 1,
unsigned int  width = 256,
unsigned int  height = 256 
)

Constructor.

Parameters
depthY resolution depth
widthU depth
heightV depth

Definition at line 60 of file yuvcm.cpp.

◆ YuvColormap() [2/5]

firevision::YuvColormap::YuvColormap ( const char *  shmem_lut_id,
unsigned int  depth = 1,
unsigned int  width = 256,
unsigned int  height = 256 
)

Constructor.

Creates a colormap in shared memory for the given LUT ID.

Parameters
shmem_lut_idshared memory LUT ID
depthY depth
widthU depth
heightV depth

Definition at line 72 of file yuvcm.cpp.

◆ YuvColormap() [3/5]

firevision::YuvColormap::YuvColormap ( const char *  shmem_lut_id,
bool  destroy_on_free,
unsigned int  depth = 1,
unsigned int  width = 256,
unsigned int  height = 256 
)

Constructor.

Creates a colormap in shared memory for the given LUT ID.

Parameters
shmem_lut_idshared memory LUT ID
destroy_on_freetrue to delete the shared memory segment to delete, false to keep the segment
depthY depth
widthU depth
heightV depth

Definition at line 88 of file yuvcm.cpp.

◆ YuvColormap() [4/5]

firevision::YuvColormap::YuvColormap ( YuvColormap cm,
const char *  shmem_lut_id,
bool  destroy_on_free = false 
)

Constructor.

Creates a colormap in shared memory for the given LUT ID and copies the data of the given existing colormap.

Parameters
cmexisting colormap to copy data from
shmem_lut_idshared memory LUT ID
destroy_on_freetrue to delete the shared memory segment to delete, false to keep the segment

Definition at line 104 of file yuvcm.cpp.

References depth(), height(), and width().

◆ YuvColormap() [5/5]

firevision::YuvColormap::YuvColormap ( const YuvColormap cm)

Copy constructor.

Creates a colormap in shared memory for the given LUT ID and copies the data of the given existing colormap.

Parameters
cmcolor mape to copy from

Definition at line 115 of file yuvcm.cpp.

References depth(), height(), and width().

◆ ~YuvColormap()

firevision::YuvColormap::~YuvColormap ( )
virtual

Destructor.

Definition at line 182 of file yuvcm.cpp.

Member Function Documentation

◆ copy_uvplane()

void firevision::YuvColormap::copy_uvplane ( unsigned char *  uvplane,
unsigned int  level 
)

Copy single U/V plane.

This will copy the given U/V plane to the given level in this colormap.

Parameters
uvplanebuffer of U/V plane to copy
levellevel to copy the plane to
Exceptions
OutOfBoundsExceptionthrown if level > depth()

Definition at line 243 of file yuvcm.cpp.

Referenced by firevision::ColormapFile::get_colormap().

◆ deepness()

unsigned int firevision::YuvColormap::deepness ( ) const
virtual

Get deepness of colormap.

The deepness is the maximum value of depth().

Returns
colormap deepness, meaning depends on actual colormap implementation

Implements firevision::Colormap.

Definition at line 342 of file yuvcm.cpp.

Referenced by firevision::BayesHistosToLut::calculateLutAllColors(), firevision::BayesHistosToLut::calculateLutValues(), and firevision::ColormapFileYuvBlock::ColormapFileYuvBlock().

◆ depth()

unsigned int firevision::YuvColormap::depth ( ) const
virtual

◆ determine()

color_t firevision::YuvColormap::determine ( unsigned int  y,
unsigned int  u,
unsigned int  v 
) const
inlinevirtual

Determine color class for given YUV value.

Parameters
yY value from YUV colorspace
uU value from YUV colorspace
vV value from YUV colorspace
Returns
color class for the given YUV color

Implements firevision::Colormap.

Definition at line 99 of file yuvcm.h.

Referenced by ColorTrainWidget::draw_segmentation_result().

◆ get_blocks()

std::list< ColormapFileBlock * > firevision::YuvColormap::get_blocks ( )
virtual

Get file blocks for this colormap.

Returns
list of colormap blocks for this colormap.

Implements firevision::Colormap.

Definition at line 218 of file yuvcm.cpp.

◆ get_buffer()

unsigned char * firevision::YuvColormap::get_buffer ( ) const
virtual

Get the raw buffer of this colormap.

Returns
raw buffer

Implements firevision::Colormap.

Definition at line 231 of file yuvcm.cpp.

Referenced by firevision::ColormapFileYuvBlock::ColormapFileYuvBlock().

◆ height()

unsigned int firevision::YuvColormap::height ( ) const
virtual

Get height of colormap.

Returns
colormap height, meaning depends on actual colormap implementation

Implements firevision::Colormap.

Definition at line 330 of file yuvcm.cpp.

Referenced by firevision::BayesHistosToLut::calculateLutValues(), ColorTrainWidget::load_histograms(), ColorTrainWidget::save_colormap(), FuseTransferWidget::set_current_colormap(), and YuvColormap().

◆ operator+=() [1/2]

Colormap & firevision::YuvColormap::operator+= ( const char *  filename)
virtual

Convenience method for the method above.

This adds the colormap as in the above method but instead of an instantiated colormap it takes the path to a colormap file which is loaded and added.

Parameters
filenamefile name of colormap to add
Returns
reference to this

Implements firevision::Colormap.

Definition at line 308 of file yuvcm.cpp.

References firevision::ColormapFile::get_colormap(), and firevision::FireVisionDataFile::read().

◆ operator+=() [2/2]

Colormap & firevision::YuvColormap::operator+= ( const Colormap cmlt)
virtual

Adds the given colormap to this colormap.

This operator takes the given colormap and compares it to this colormap. If this colormap has C_OTHER or C_BACKGROUND the value is compied from the other LUT, otherwise the value is kept as is.

Parameters
cmltother colormap to add
Returns
reference to this

Implements firevision::Colormap.

Definition at line 260 of file yuvcm.cpp.

◆ operator=()

Colormap & firevision::YuvColormap::operator= ( const YuvColormap yuvcm)
virtual

Assign operation.

Copies all values from the given colormap.

Parameters
yuvcmcolormap which's data to copy to this instance
Exceptions
TypeMismatchExceptionthrown if depth of colormaps does not match.
Returns
reference to this

Definition at line 296 of file yuvcm.cpp.

◆ plane_size()

unsigned int firevision::YuvColormap::plane_size ( ) const

Get U/V plane size.

Returns
size of a single U/V plane

Definition at line 351 of file yuvcm.cpp.

Referenced by firevision::ColormapFileYuvBlock::ColormapFileYuvBlock(), and firevision::ColormapFile::get_colormap().

◆ replace_color()

void firevision::YuvColormap::replace_color ( color_t  from,
color_t  to 
)

Replace a given color with another one.

Parameters
fromcolor to replace
tocolor to replace from with

Definition at line 361 of file yuvcm.cpp.

◆ reset()

void firevision::YuvColormap::reset ( void  )
virtual

Reset colormap.

Resets all values to return C_UNKNOWN for every query with determine().

Implements firevision::Colormap.

Definition at line 200 of file yuvcm.cpp.

Referenced by firevision::BayesHistosToLut::calculateLutValues().

◆ set() [1/2]

void firevision::YuvColormap::set ( unsigned char *  buffer)
virtual

Set to the given raw buffer.

Parameters
bufferbuffer to copy data from

Implements firevision::Colormap.

Definition at line 206 of file yuvcm.cpp.

◆ set() [2/2]

void firevision::YuvColormap::set ( unsigned int  y,
unsigned int  u,
unsigned int  v,
color_t  c 
)
virtual

Set color class for given YUV value.

Parameters
yY value from YUV colorspace
uU value from YUV colorspace
vV value from YUV colorspace
cclass for the given YUV color

Implements firevision::Colormap.

Definition at line 194 of file yuvcm.cpp.

Referenced by firevision::BayesHistosToLut::calculateLutAllColors(), firevision::BayesHistosToLut::calculateLutValues(), FireVisionNetworkTool::fuse_inbound_received(), and FvRetrieverThread::init().

◆ size()

size_t firevision::YuvColormap::size ( )
virtual

Size in bytes of buffer returned by get_buffer().

Returns
size in bytes of buffer returned by get_buffer()

Implements firevision::Colormap.

Definition at line 212 of file yuvcm.cpp.

◆ width()

unsigned int firevision::YuvColormap::width ( ) const
virtual

Get width of colormap.

Returns
colormap width, meaning depends on actual colormap implementation

Implements firevision::Colormap.

Definition at line 324 of file yuvcm.cpp.

Referenced by firevision::BayesHistosToLut::calculateLutValues(), ColorTrainWidget::load_histograms(), ColorTrainWidget::save_colormap(), FuseTransferWidget::set_current_colormap(), and YuvColormap().


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