Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CameraDriver Class Reference

#include <CameraDriverOSX.h>

Inheritance diagram for CameraDriver:

List of all members.


Detailed Description

description of CameraDriver

Definition at line 10 of file CameraDriverOSX.h.


Public Member Functions

 CameraDriver (const std::string &name)
 constructor, may throw a const char* on error
 ~CameraDriver ()
virtual std::string getClassName () const
 Returns the name of the class (aka its type).
virtual void getImageSources (std::map< std::string, DataSource * > &sources)
 CameraDriver (const std::string &name)
 ~CameraDriver ()
virtual std::string getClassName () const
 Returns the name of the class (aka its type).
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)
 watches path, triggers a close() and re-open() if it changes

Public Attributes

plist::Primitive< std::string > path
plist::Primitive< unsigned int > resolution
plist::Primitive< int > layer
 Controls the resolution layer at which the image should be processed.
0 indicates "automatic" mode (picks layer closest to image's resolution), positive numbers indicate the resolution layer directly.
Negative values are relative to the number of layers marked available by the vision setup, so that typically -1 would correspond to the "double" layer, and -2 would correspond to the "full" layer.
plist::Primitive< bool > autobright

Protected Member Functions

void updateCameraList ()
void close_cam ()
void open_cam ()
void get_cam_info ()
void set_cam_info ()
void set_resolution ()
void auto_bright ()
void interleave_yuv_down ()
void interleave_yuv_up ()
size_t getWidth () const
size_t getHeight () const
size_t getBufferSize () const

Static Protected Member Functions

static std::string p2c (unsigned char pascalStr[])
 converts from pascal-format string to c-format string
static void dumpLiteral (OSType t)

Protected Attributes

int camfd
size_t img_size
struct video_capability vid_caps
struct video_window vid_win
struct video_picture vid_pic
unsigned int frameCount
bool isYUVMode
bool blocking
std::vector< unsigned char > curBuf
 the buffer to write the image into
std::vector< unsigned char > lastBuf
 the buffer we returned last time (might still be in use while writing curBuf)
std::vector< unsigned char > tmpBuf
 used during interleave_yuv_up(), swapped back and forth with curBuf
ThreadNS::Lock lock

Static Protected Attributes

static const size_t HEADER_SIZE

Static Private Attributes

static const std::string autoRegisterCameraDriver
 holds the class name, set via registration with the DeviceDriver registry

Constructor & Destructor Documentation

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

constructor, may throw a const char* on error

Definition at line 13 of file CameraDriverOSX.h.

~CameraDriver (  )  [inline]

Definition at line 24 of file CameraDriverOSX.h.

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

Definition at line 19 of file CameraDriverV4L.h.

~CameraDriver (  )  [inline]

Definition at line 33 of file CameraDriverV4L.h.


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 26 of file CameraDriverOSX.h.

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

Reimplemented from DeviceDriver.

Definition at line 28 of file CameraDriverOSX.h.

static std::string p2c ( unsigned char  pascalStr[]  )  [inline, static, protected]

converts from pascal-format string to c-format string

Definition at line 42 of file CameraDriverOSX.h.

static void dumpLiteral ( OSType  t  )  [static, protected]

void updateCameraList (  )  [protected]

Referenced by CameraDriver().

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 38 of file CameraDriverV4L.h.

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

Reimplemented from DeviceDriver.

Definition at line 40 of file CameraDriverV4L.h.

virtual unsigned int nextTimestamp (  )  [inline, 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 44 of file CameraDriverV4L.h.

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 45 of file CameraDriverV4L.h.

virtual 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.

virtual 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.

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

watches path, triggers a close() and re-open() if it changes

Implements PrimitiveListener.

void close_cam (  )  [protected]

void open_cam (  )  [protected]

void get_cam_info (  )  [protected]

void set_cam_info (  )  [protected]

void set_resolution (  )  [protected]

void auto_bright (  )  [protected]

void interleave_yuv_down (  )  [protected]

void interleave_yuv_up (  )  [protected]

size_t getWidth (  )  const [inline, protected]

Definition at line 67 of file CameraDriverV4L.h.

size_t getHeight (  )  const [inline, protected]

Definition at line 68 of file CameraDriverV4L.h.

size_t getBufferSize (  )  const [inline, protected]

Definition at line 69 of file CameraDriverV4L.h.


Member Data Documentation

static const std::string autoRegisterCameraDriver [static, private]

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

Definition at line 53 of file CameraDriverOSX.h.

Referenced by getClassName().

plist::Primitive<std::string> path

Definition at line 52 of file CameraDriverV4L.h.

Referenced by CameraDriver(), and ~CameraDriver().

Definition at line 53 of file CameraDriverV4L.h.

Referenced by CameraDriver(), getBufferSize(), getHeight(), getWidth(), and ~CameraDriver().

Controls the resolution layer at which the image should be processed.
0 indicates "automatic" mode (picks layer closest to image's resolution), positive numbers indicate the resolution layer directly.
Negative values are relative to the number of layers marked available by the vision setup, so that typically -1 would correspond to the "double" layer, and -2 would correspond to the "full" layer.

Definition at line 54 of file CameraDriverV4L.h.

Referenced by CameraDriver().

Definition at line 55 of file CameraDriverV4L.h.

Referenced by CameraDriver().

const size_t HEADER_SIZE [static, protected]

Definition at line 71 of file CameraDriverV4L.h.

Referenced by getBufferSize().

int camfd [protected]

Definition at line 73 of file CameraDriverV4L.h.

size_t img_size [protected]

Definition at line 74 of file CameraDriverV4L.h.

struct video_capability vid_caps [read, protected]

Definition at line 75 of file CameraDriverV4L.h.

struct video_window vid_win [read, protected]

Definition at line 76 of file CameraDriverV4L.h.

Referenced by getBufferSize(), getHeight(), and getWidth().

struct video_picture vid_pic [read, protected]

Definition at line 77 of file CameraDriverV4L.h.

unsigned int frameCount [protected]

Definition at line 78 of file CameraDriverV4L.h.

bool isYUVMode [protected]

Definition at line 79 of file CameraDriverV4L.h.

bool blocking [protected]

Definition at line 80 of file CameraDriverV4L.h.

std::vector<unsigned char> curBuf [protected]

the buffer to write the image into

Definition at line 82 of file CameraDriverV4L.h.

std::vector<unsigned char> lastBuf [protected]

the buffer we returned last time (might still be in use while writing curBuf)

Definition at line 83 of file CameraDriverV4L.h.

std::vector<unsigned char> tmpBuf [protected]

used during interleave_yuv_up(), swapped back and forth with curBuf

Definition at line 84 of file CameraDriverV4L.h.

ThreadNS::Lock lock [protected]

Definition at line 85 of file CameraDriverV4L.h.


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

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