Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ImageStreamDriver Class Reference

#include <ImageStreamDriver.h>

Inheritance diagram for ImageStreamDriver:

List of all members.


Detailed Description

description of ImageStreamDriver

Definition at line 12 of file ImageStreamDriver.h.


Public Types

enum  format_t { FORMAT_YUV = 0, FORMAT_PNG, FORMAT_JPEG, FORMAT_TEKKOTSU }

Public Member Functions

 ImageStreamDriver (const std::string &name)
virtual ~ImageStreamDriver ()
virtual std::string getClassName () const
 Returns the name of the class (aka its type).
virtual void getSensorSources (std::map< std::string, DataSource * > &sources)
virtual void getImageSources (std::map< std::string, DataSource * > &sources)
virtual unsigned int nextTimestamp ()
 returns the simulator time of the next data segment
virtual const std::string & nextName ()
 returns a descriptive name of the next data segment for user feedback
virtual unsigned int getData (const char *&payload, unsigned int &payloadSize, unsigned int &timestamp, std::string &name)
 called to retrieve the most recent data segment, or blocking until new data is available
virtual void setDataSourceThread (LoadDataThread *th)
 called by the LoadDataThread subclass, allows you to register for properties which your subclass may care about
virtual void plistValueChanged (const plist::PrimitiveBase &pl)

Public Attributes

plist::Primitive< std::string > commName
plist::NamedEnumeration< format_tformat

Static Public Attributes

static const size_t NUM_FORMATS = 4
static const char * formatNames [NUM_FORMATS+1] = { "yuv", "png", "jpeg", "tekkotsu", "" }

Protected Member Functions

void copyImage (char *buf, unsigned int width, unsigned int height, unsigned int channels, const char *chan, unsigned int lwidth, unsigned int lheight, unsigned int chan)

Protected Attributes

unsigned int frameNumber
 image frame number
std::vector< char > buffer
 image buffer
char * img
 temporary storage for jpeg/png decompression
size_t imgSize
 size of allocation of img

Private Member Functions

 ImageStreamDriver (const ImageStreamDriver &)
 no call
ImageStreamDriver operator= (const ImageStreamDriver &)
 no call

Static Private Attributes

static const std::string autoRegisterImageStreamDriver = DeviceDriver::getRegistry().registerType<ImageStreamDriver>("ImageStream")
 holds the class name, set via registration with the DeviceDriver registry

Member Enumeration Documentation

enum format_t

Enumerator:
FORMAT_YUV 
FORMAT_PNG 
FORMAT_JPEG 
FORMAT_TEKKOTSU 

Definition at line 49 of file ImageStreamDriver.h.


Constructor & Destructor Documentation

ImageStreamDriver ( const std::string &  name  )  [inline, explicit]

Definition at line 14 of file ImageStreamDriver.h.

virtual ~ImageStreamDriver (  )  [inline, virtual]

Definition at line 25 of file ImageStreamDriver.h.

ImageStreamDriver ( const ImageStreamDriver  )  [private]

no call


Member Function Documentation

virtual std::string getClassName (  )  const [inline, virtual]

Returns the name of the class (aka its type).

Suggested implementation is to declare a static string member, set it to the result of calling the registry's registerType, and then return that member here

Implements DeviceDriver.

Definition at line 29 of file ImageStreamDriver.h.

Referenced by plistValueChanged().

virtual void getSensorSources ( std::map< std::string, DataSource * > &  sources  )  [inline, virtual]

Reimplemented from DeviceDriver.

Definition at line 31 of file ImageStreamDriver.h.

virtual void getImageSources ( std::map< std::string, DataSource * > &  sources  )  [inline, virtual]

Reimplemented from DeviceDriver.

Definition at line 35 of file ImageStreamDriver.h.

unsigned int nextTimestamp (  )  [virtual]

returns the simulator time of the next data segment

should be in the future if nothing new since last data segment, otherwise should be the timestamp of the most recent data segment (older segments are skipped), return -1U if there is no more data

See also:
timestamp argument of getData()

Implements DataSource.

Definition at line 18 of file ImageStreamDriver.cc.

virtual const std::string& nextName (  )  [inline, virtual]

returns a descriptive name of the next data segment for user feedback

See also:
name argument of getData()

Implements DataSource.

Definition at line 41 of file ImageStreamDriver.h.

unsigned int getData ( const char *&  payload,
unsigned int &  payloadSize,
unsigned int &  timestamp,
std::string &  name 
) [virtual]

called to retrieve the most recent data segment, or blocking until new data is available

Parameters:
[out] payload on return, should point to beginning of data segment, or NULL if none available
[out] payloadSize on return, should indicate size in bytes of data segment as payload
[in] timestamp the suggested return time; if multiple samples may be taken in the interval, they should be skipped until this time
[out] timestamp on return, should contain the time at which the data arrived (real time stream) or was scheduled to be sent (log on disk)
[out] name on return, a human-readable name for the frame -- e.g. filename for a data file loaded from disk
Returns:
frame serial number, used to tell when frames from the data source have been dropped (indicated by the return value incrementing by more than one)
If no more data is available, set payload to NULL, and return the current frame (i.e. don't increment serial number).

This call should block until data is available. Other functions may be called asynchronously from other threads while in this function, see ThreadNS::Lock to implement mutual exclusion locks if needed.

The input value of timestamp is a suggestion from the user's requested framerate -- try to return the frame closest to it. If it is already past (e.g. 0 on 'advance'), return the current data! If you return a timestamp in the future, the LoadDataThread will sleep until the appropriate time.

Note that this can be called when the source is frozen, which means you should unfreeze, get the current (unread) data or block until the next data, freeze again, and return the data.

Implements DataSource.

Definition at line 25 of file ImageStreamDriver.cc.

void setDataSourceThread ( LoadDataThread th  )  [virtual]

called by the LoadDataThread subclass, allows you to register for properties which your subclass may care about

a pointer to the LoadDataThread is passed when this is becoming the current data source; NULL will be passed when the data source is no longer being used

Reimplemented from DataSource.

Definition at line 261 of file ImageStreamDriver.cc.

void plistValueChanged ( const plist::PrimitiveBase pl  )  [virtual]

Implements PrimitiveListener.

Definition at line 277 of file ImageStreamDriver.cc.

void copyImage ( char *  buf,
unsigned int  width,
unsigned int  height,
unsigned int  channels,
const char *  chan,
unsigned int  lwidth,
unsigned int  lheight,
unsigned int  chan 
) [protected]

Definition at line 304 of file ImageStreamDriver.cc.

Referenced by getData().

ImageStreamDriver operator= ( const ImageStreamDriver  )  [private]

no call


Member Data Documentation

const size_t NUM_FORMATS = 4 [static]

Definition at line 55 of file ImageStreamDriver.h.

const char * formatNames = { "yuv", "png", "jpeg", "tekkotsu", "" } [static]

Definition at line 56 of file ImageStreamDriver.h.

unsigned int frameNumber [protected]

image frame number

Definition at line 63 of file ImageStreamDriver.h.

Referenced by getData().

std::vector<char> buffer [protected]

image buffer

Definition at line 64 of file ImageStreamDriver.h.

Referenced by getData().

char* img [protected]

temporary storage for jpeg/png decompression

Definition at line 65 of file ImageStreamDriver.h.

Referenced by getData(), and plistValueChanged().

size_t imgSize [protected]

size of allocation of img

Definition at line 66 of file ImageStreamDriver.h.

Referenced by getData(), and plistValueChanged().

const std::string autoRegisterImageStreamDriver = DeviceDriver::getRegistry().registerType<ImageStreamDriver>("ImageStream") [static, private]

holds the class name, set via registration with the DeviceDriver registry

Definition at line 70 of file ImageStreamDriver.h.

Referenced by getClassName().


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

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:01:21 2007 by Doxygen 1.5.4