XMM - Probabilistic Models for Motion Recognition and Mapping

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
xmm::Phrase Class Reference

Data phrase. More...

#include <xmmPhrase.hpp>

Inheritance diagram for xmm::Phrase:
[legend]
Collaboration diagram for xmm::Phrase:
[legend]

Public Member Functions

 Phrase (MemoryMode memoryMode=MemoryMode::OwnMemory, Multimodality multimodality=Multimodality::Unimodal)
 Constructor. More...
 
 Phrase (Phrase const &src)
 Copy Constructor. More...
 
 Phrase (Json::Value const &root)
 Constructor from Json Structure. More...
 
Phraseoperator= (Phrase const &src)
 Assignment. More...
 
virtual ~Phrase ()
 Destructor. More...
 
Accessors
bool ownMemory () const
 checks if the training set is owns the data More...
 
bool bimodal () const
 checks if the training set is bimodal More...
 
Access Data
unsigned int size () const
 get the number of frames in the phrase More...
 
unsigned int inputSize () const
 get the number of frames in the input array of the phrase More...
 
unsigned int outputSize () const
 get the number of frames in the output array of the phrase More...
 
bool empty () const
 check if the phrase is empty More...
 
float getValue (unsigned int index, unsigned int dim) const
 Access data at a given time index and dimension. More...
 
float * getPointer (unsigned int index) const
 Get pointer to the data at a given time index. More...
 
float * getPointer_input (unsigned int index) const
 Get pointer to the data at a given time index for the input modality. More...
 
float * getPointer_output (unsigned int index) const
 Get pointer to the data at a given time index for the output modality. More...
 
Connect (MemoryMode = SharedData)
void connect (float *pointer_to_data, unsigned int length)
 Connect a unimodal phrase to a shared container. More...
 
void connect (float *pointer_to_data_input, float *pointer_to_data_output, unsigned int length)
 Connect a Bimodal phrase to a shared container. More...
 
void connect_input (float *pointer_to_data, unsigned int length)
 Connect a Bimodal phrase to a shared container for the input modality. More...
 
void connect_output (float *pointer_to_data, unsigned int length)
 Connect a Bimodal phrase to a shared container for the output modality. More...
 
void disconnect ()
 Disconnect a phrase from a shared container. More...
 
Record (MemoryMode = OwnData)
void record (std::vector< float > const &observation)
 Record observation. More...
 
void record_input (std::vector< float > const &observation)
 Record observation on input modality Appends the observation vector observation to the data array
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory) More...
 
void record_output (std::vector< float > const &observation)
 Record observation on output modality Appends the observation vector observation to the data array
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory) More...
 
void clear ()
 Reset length of the phrase to 0 ==> empty phrase
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory) More...
 
void clearInput ()
 
void clearOutput ()
 
JSON I/O
Json::Value toJson () const
 Write the object to a JSON Structure. More...
 
void fromJson (Json::Value const &root)
 Read the object from a JSON Structure. More...
 
Utilities
std::vector< float > mean () const
 Compute the mean of the data phrase along the time axis. More...
 
std::vector< float > standardDeviation () const
 Compute the standard deviation of the data phrase along the time axis. More...
 
std::vector< std::pair< float, float > > minmax () const
 Compute the global min/max of the data phrase along the time axis. More...
 
void rescale (std::vector< float > offset, std::vector< float > gain)
 rescale a phrase given an offset and gain More...
 
Python File I/O
void writeFile (char *fileName) const
 write method for python wrapping ('write' keyword forbidden, name has to be different) More...
 
void readFile (char *fileName)
 read method for python wrapping ('read' keyword forbidden, name has to be different) More...
 
std::string __str__ () const
 "print" method for python => returns the results of write method More...
 

Public Attributes

Attribute< unsigned int > dimension
 Total dimension of the phrase. More...
 
Attribute< unsigned int > dimension_input
 Used in bimodal mode: dimension of the input modality. More...
 
Attribute< std::string > label
 Main label of the phrase. More...
 
std::vector< std::string > column_names
 labels of the columns of the phrase (e.g. descriptor names) More...
 

Protected Member Functions

void trim ()
 trim phrase to minimal length of modalities More...
 
void reallocateLength ()
 Memory Allocation. More...
 
virtual void onAttributeChange (AttributeBase *attr_pointer)
 notification function called when a member attribute is changed More...
 

Protected Attributes

bool own_memory_
 Defines if the phrase stores the data itself. More...
 
bool bimodal_
 Defines if the phrase is bimodal (true) or unimodal (false) More...
 
bool empty_
 true if the phrase does not contain any data More...
 
unsigned int length_
 Length of the phrase. If bimodal, it is the minimal length between modalities. More...
 
unsigned int input_length_
 Length of the array of the input modality. More...
 
unsigned int output_length_
 Length of the array of the output modality. More...
 
unsigned int max_length_
 Allocated length (only used in own memory mode) More...
 
float ** data_
 Pointer to the Data arrays. More...
 
EventGenerator< PhraseEventevents
 

Static Protected Attributes

static const unsigned int AllocationBlockSize = 256
 

Friends

class TrainingSet
 

Detailed Description

Data phrase.

The Phrase class can be used to store unimodal and Bimodal data phrases. It can have an autonomous memory, or this memory can be shared with another data container. These attributes are specified at construction.

Constructor & Destructor Documentation

xmm::Phrase::Phrase ( MemoryMode  memoryMode = MemoryMode::OwnMemory,
Multimodality  multimodality = Multimodality::Unimodal 
)

Constructor.

Parameters
memoryModeMemory mode (owned vs shared)
multimodalityNumber of modalities
xmm::Phrase::Phrase ( Phrase const &  src)

Copy Constructor.

Parameters
srcsource Phrase
xmm::Phrase::Phrase ( Json::Value const &  root)
explicit

Constructor from Json Structure.

Parameters
rootJson Value
xmm::Phrase::~Phrase ( )
virtual

Destructor.

Data is only deleted if the memory is owned (construction with MemoryMode::OwnMemory)

Member Function Documentation

std::string xmm::Writable::__str__ ( ) const
inlineinherited

"print" method for python => returns the results of write method

Warning
only defined if SWIGPYTHON is defined
bool xmm::Phrase::bimodal ( ) const

checks if the training set is bimodal

Returns
true if the training set is bimodal (construction with Multimodality::Bimodal)
void xmm::Phrase::clear ( )

Reset length of the phrase to 0 ==> empty phrase
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)

Exceptions
runtime_errorif data is shared (construction with MemoryMode::SharedMemory flag)
Warning
the memory is not released (only done in destructor).
void xmm::Phrase::clearInput ( )
void xmm::Phrase::clearOutput ( )
void xmm::Phrase::connect ( float *  pointer_to_data,
unsigned int  length 
)

Connect a unimodal phrase to a shared container.

Warning
This method is only usable in Shared Memory (construction with MemoryMode::SharedMemory)
Parameters
pointer_to_datapointer to the data array
lengthlength of the data array
Exceptions
runtime_errorif data is owned (construction with MemoryMode::OwnMemory flag)
void xmm::Phrase::connect ( float *  pointer_to_data_input,
float *  pointer_to_data_output,
unsigned int  length 
)

Connect a Bimodal phrase to a shared container.

Warning
This method is only usable in Shared Memory (construction with MemoryMode::SharedMemory)
Parameters
pointer_to_data_inputpointer to the data array of the input modality
pointer_to_data_outputpointer to the data array of the output modality
lengthlength of the data array
Exceptions
runtime_errorif data is owned (construction with MemoryMode::OwnMemory flag)
void xmm::Phrase::connect_input ( float *  pointer_to_data,
unsigned int  length 
)

Connect a Bimodal phrase to a shared container for the input modality.

Warning
This method is only usable in Shared Memory (construction with MemoryMode::SharedMemory)
Parameters
pointer_to_datapointer to the data array of the input modality
lengthlength of the data array
Exceptions
runtime_errorif data is owned (construction with MemoryMode::OwnMemory flag)
void xmm::Phrase::connect_output ( float *  pointer_to_data,
unsigned int  length 
)

Connect a Bimodal phrase to a shared container for the output modality.

Warning
This method is only usable in Shared Memory (construction with MemoryMode::SharedMemory)
Parameters
pointer_to_datapointer to the data array of the output modality
lengthlength of the data array
Exceptions
runtime_errorif data is owned (construction with MemoryMode::OwnMemory flag)
void xmm::Phrase::disconnect ( )

Disconnect a phrase from a shared container.

Warning
This method is only usable in Shared Memory (construction with MemoryMode::SharedMemory)
Exceptions
runtime_errorif data is owned (construction with MemoryMode::OwnMemory flag)
bool xmm::Phrase::empty ( ) const

check if the phrase is empty

Returns
true if the phrase is empty (length 0)
void xmm::Phrase::fromJson ( Json::Value const &  root)
virtual

Read the object from a JSON Structure.

Parameters
rootJSON value containing the object's information
Exceptions
JsonExceptionif the JSON value has a wrong format

Implements xmm::Writable.

float * xmm::Phrase::getPointer ( unsigned int  index) const

Get pointer to the data at a given time index.

Parameters
indextime index
Warning
this method can be used only for unimodal phrases (construction with Multimodality::Unimodal)
Exceptions
out_of_rangeif time index is out of bounds
runtime_errorif the phrase is bimodal (construction with Multimodality::Bimodal)
Returns
pointer to the data array of the modality, for the given time index
float * xmm::Phrase::getPointer_input ( unsigned int  index) const

Get pointer to the data at a given time index for the input modality.

Warning
this method can be used only for bimodal phrases (construction with Multimodality::Bimodal)
Parameters
indextime index
Exceptions
out_of_rangeif time index is out of bounds
runtime_errorif the phrase is unimodal (construction with Multimodality::Unimodal)
Returns
pointer to the data array of the modality, for the given time index
float * xmm::Phrase::getPointer_output ( unsigned int  index) const

Get pointer to the data at a given time index for the output modality.

Warning
this method can be used only for bimodal phrases (construction with Multimodality::Bimodal)
Parameters
indextime index
Exceptions
out_of_rangeif time index is out of bounds
runtime_errorif the phrase is unimodal (construction with Multimodality::Unimodal)
Returns
pointer to the data array of the modality, for the given time index
float xmm::Phrase::getValue ( unsigned int  index,
unsigned int  dim 
) const

Access data at a given time index and dimension.

Parameters
indextime index
dimdimension considered, indexed from 0 to the total dimension of the data across modalities
Exceptions
out_of_rangeif time index or dimension are out of bounds
unsigned int xmm::Phrase::inputSize ( ) const

get the number of frames in the input array of the phrase

Returns
the number of frames in the input array of the phrase
std::vector< float > xmm::Phrase::mean ( ) const

Compute the mean of the data phrase along the time axis.

Returns
mean of the phrase (along time axis, full-size)
std::vector< std::pair< float, float > > xmm::Phrase::minmax ( ) const

Compute the global min/max of the data phrase along the time axis.

Returns
vector of min/max pairs ofthe phrases (along time axis, full-size)
void xmm::Phrase::onAttributeChange ( xmm::AttributeBase attr_pointer)
protectedvirtual

notification function called when a member attribute is changed

xmm::Phrase & xmm::Phrase::operator= ( Phrase const &  src)

Assignment.

Parameters
srcsource Phrase
unsigned int xmm::Phrase::outputSize ( ) const

get the number of frames in the output array of the phrase

Returns
the number of frames in the output array of the phrase
bool xmm::Phrase::ownMemory ( ) const

checks if the training set is owns the data

Returns
true if the training set owns data (construction with MemoryMode::OwnMemory)
void xmm::Writable::readFile ( char *  fileName)
inlineinherited

read method for python wrapping ('read' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined
void xmm::Phrase::reallocateLength ( )
protected

Memory Allocation.

used record mode (no SHARED_MEMORY flag), the data vector is reallocated with a block size ALLOC_BLOCKSIZE

void xmm::Phrase::record ( std::vector< float > const &  observation)

Record observation.

Appends the observation vector observation to the data array.
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)

Parameters
observationobservation vector (C-like array which must have the size of the total dimension of the data across all modalities)
Exceptions
runtime_errorif data is shared (construction with MemoryMode::SharedMemory flag)
void xmm::Phrase::record_input ( std::vector< float > const &  observation)

Record observation on input modality Appends the observation vector observation to the data array
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)

Parameters
observationobservation vector (C-like array which must have the size of the total dimension of the data across all modalities)
Exceptions
runtime_errorif data is shared (construction with MemoryMode::SharedMemory flag)
void xmm::Phrase::record_output ( std::vector< float > const &  observation)

Record observation on output modality Appends the observation vector observation to the data array
This method is only usable in Own Memory (construction with MemoryMode::OwnMemory)

Parameters
observationobservation vector (C-like array which must have the size of the total dimension of the data across all modalities)
Exceptions
runtime_errorif data is shared (construction with MemoryMode::SharedMemory flag)
void xmm::Phrase::rescale ( std::vector< float >  offset,
std::vector< float >  gain 
)

rescale a phrase given an offset and gain

Parameters
offsetconstant offset to be subtracted
gaingain to be applied
unsigned int xmm::Phrase::size ( ) const

get the number of frames in the phrase

Returns
the number of frames in the phrase
std::vector< float > xmm::Phrase::standardDeviation ( ) const

Compute the standard deviation of the data phrase along the time axis.

Returns
standard deviation of the phrase (along time axis, full-size)
Json::Value xmm::Phrase::toJson ( ) const
virtual

Write the object to a JSON Structure.

Returns
Json value containing the object's information

Implements xmm::Writable.

void xmm::Phrase::trim ( )
protected

trim phrase to minimal length of modalities

void xmm::Writable::writeFile ( char *  fileName) const
inlineinherited

write method for python wrapping ('write' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined

Friends And Related Function Documentation

friend class TrainingSet
friend

Member Data Documentation

const unsigned int xmm::Phrase::AllocationBlockSize = 256
staticprotected
bool xmm::Phrase::bimodal_
protected

Defines if the phrase is bimodal (true) or unimodal (false)

std::vector<std::string> xmm::Phrase::column_names

labels of the columns of the phrase (e.g. descriptor names)

float** xmm::Phrase::data_
protected

Pointer to the Data arrays.

data has a size 1 in unimodal mode, 2 in bimodal mode.

Attribute<unsigned int> xmm::Phrase::dimension

Total dimension of the phrase.

Attribute<unsigned int> xmm::Phrase::dimension_input

Used in bimodal mode: dimension of the input modality.

bool xmm::Phrase::empty_
protected

true if the phrase does not contain any data

EventGenerator<PhraseEvent> xmm::Phrase::events
protected
unsigned int xmm::Phrase::input_length_
protected

Length of the array of the input modality.

Attribute<std::string> xmm::Phrase::label

Main label of the phrase.

unsigned int xmm::Phrase::length_
protected

Length of the phrase. If bimodal, it is the minimal length between modalities.

unsigned int xmm::Phrase::max_length_
protected

Allocated length (only used in own memory mode)

unsigned int xmm::Phrase::output_length_
protected

Length of the array of the output modality.

bool xmm::Phrase::own_memory_
protected

Defines if the phrase stores the data itself.


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