Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CameraSource Class Reference

#include <CameraSourceOSX.h>

Inheritance diagram for CameraSource:

List of all members.


Detailed Description

Definition at line 18 of file CameraSourceOSX.h.


Public Member Functions

 CameraSource (SeqGrabComponent grabber, const std::string &srcName, const std::string &devName, const std::string &inputName, int inputIdx) throw (std::pair<OSErr,const char*>)
 constructor, pass the short name, device name and input index
 ~CameraSource ()
 destructor, free system resources
virtual const std::string & getName () const
 accessor for the instance name
virtual const std::string & getDeviceName () const
 accessor for the device name
virtual const std::string & getInputName () const
 accessor for the name of the input from the device
virtual unsigned int nextTimestamp ()
 returns the simulator time of the next data segment
virtual const std::string & nextName ()
 this is supposed to be the name for the next camera frame, we just reuse our static instance name
virtual void setDataSourceThread (LoadDataThread *ldt)
 called by the LoadDataThread subclass, allows you to register for properties which your subclass may care about
virtual void setDataSourceFramerate (float fps)
 called by LoadDataThread whenever the expected framerate changes (LoadDataThread::framerate)
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

Public Attributes

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.

Protected Member Functions

void initCamera ()
void imgFrom2vuy (const unsigned char *s, short srcWidth, short srcHeight, short depth, long dataSize)
 Resamples a YUV 4:2:2 (aka '2vuy') image to a YUV 4:4:4 form which is expected in getData()'s payload.
void imgFromyuv2 (const unsigned char *s, short srcWidth, short srcHeight, short depth, long dataSize)
 Resamples a YUV 4:2:2 (aka 'yuv2' or 'yuvu') image to YUV 4:4:4 form which is expected in getData()'s payload.

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)
static ComponentResult setVideoChannelBounds (SGChannel videoChannel, const Rect *scaledVideoBounds)
static pascal ComponentResult compressCompleteBottleProc (SGChannel c, UInt8 *queuedFrameCount, SGCompressInfo *ci, TimeRecord *t, long refCon)
static pascal OSErr grabDataProc (SGChannel c, Ptr p, long len, long *offset, long chRefCon, TimeValue time, short writeType, long refCon)

Protected Attributes

SeqGrabComponent sg
 sequence grabber, might need one of these globally instead of one per CameraSource
SGChannel sgChan
 channel within the sequence grabber, I think there will be one channel per camera
GWorldPtr gworld
 graphics buffer to store the decompressed image (RGB, will have to be converted back to YUV)
std::string name
 name to use for image frames
const std::string deviceName
 name of hardware device the source is connected
const std::string devInputName
 name of the input on the device (in case a single device has multiple inputs)
int devInputIdx
 index number of the input
unsigned int frame
 current frame number
unsigned int skipped
 number of frames skipped since last successful frame
unsigned int queuedFrames
 number of frames the system indicates are waiting to be processed
bool grabbing
 set to true when setDataSourceThread is called with a non-NULL value, but can be set back to false if an error occurs
TimeValue lastTime
UInt32 duration
TimeScale chanTimeScale
TimeBase chanTimeBase
ImageSequence drawSeq
OSErr callbackerr
 error value from call back, so we can tell if an error came from SGIdle itself or the callback functions it may trigger
char * gworldBuf
 buffer used for gworld
char * imgbuf
 buffer where YUV image will be stored and returned back to getData caller via payload parameter
size_t imgbufSize
 size of imgbuf allocation
size_t imgbufUsed
 amount of imgbuf's allocation which is actually in use with data

Private Member Functions

 CameraSource (const CameraSource &)
 don't call (copy constructor)
CameraSourceoperator= (const CameraSource &)
 don't call (assignment operator)

Constructor & Destructor Documentation

CameraSource ( SeqGrabComponent  grabber,
const std::string &  srcName,
const std::string &  devName,
const std::string &  inputName,
int  inputIdx 
) throw (std::pair<OSErr,const char*>) [inline]

constructor, pass the short name, device name and input index

Definition at line 21 of file CameraSourceOSX.h.

~CameraSource (  ) 

destructor, free system resources

CameraSource ( const CameraSource  )  [private]

don't call (copy constructor)


Member Function Documentation

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

accessor for the instance name

Definition at line 41 of file CameraSourceOSX.h.

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

accessor for the device name

Definition at line 43 of file CameraSourceOSX.h.

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

accessor for the name of the input from the device

Definition at line 45 of file CameraSourceOSX.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 47 of file CameraSourceOSX.h.

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

this is supposed to be the name for the next camera frame, we just reuse our static instance name

Implements DataSource.

Definition at line 48 of file CameraSourceOSX.h.

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 setDataSourceFramerate ( float  fr  )  [virtual]

called by LoadDataThread whenever the expected framerate changes (LoadDataThread::framerate)

Reimplemented from DataSource.

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.

void initCamera (  )  [protected]

Referenced by CameraSource().

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

converts from pascal-format string to c-format string

Definition at line 61 of file CameraSourceOSX.h.

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

static ComponentResult setVideoChannelBounds ( SGChannel  videoChannel,
const Rect *  scaledVideoBounds 
) [static, protected]

static pascal ComponentResult compressCompleteBottleProc ( SGChannel  c,
UInt8 *  queuedFrameCount,
SGCompressInfo *  ci,
TimeRecord *  t,
long  refCon 
) [static, protected]

static pascal OSErr grabDataProc ( SGChannel  c,
Ptr  p,
long  len,
long *  offset,
long  chRefCon,
TimeValue  time,
short  writeType,
long  refCon 
) [static, protected]

void imgFrom2vuy ( const unsigned char *  s,
short  srcWidth,
short  srcHeight,
short  depth,
long  dataSize 
) [protected]

Resamples a YUV 4:2:2 (aka '2vuy') image to a YUV 4:4:4 form which is expected in getData()'s payload.

void imgFromyuv2 ( const unsigned char *  s,
short  srcWidth,
short  srcHeight,
short  depth,
long  dataSize 
) [protected]

Resamples a YUV 4:2:2 (aka 'yuv2' or 'yuvu') image to YUV 4:4:4 form which is expected in getData()'s payload.

CameraSource& operator= ( const CameraSource  )  [private]

don't call (assignment operator)


Member Data Documentation

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 55 of file CameraSourceOSX.h.

Referenced by CameraSource().

SeqGrabComponent sg [protected]

sequence grabber, might need one of these globally instead of one per CameraSource

Definition at line 76 of file CameraSourceOSX.h.

SGChannel sgChan [protected]

channel within the sequence grabber, I think there will be one channel per camera

Definition at line 77 of file CameraSourceOSX.h.

GWorldPtr gworld [protected]

graphics buffer to store the decompressed image (RGB, will have to be converted back to YUV)

Definition at line 78 of file CameraSourceOSX.h.

std::string name [protected]

name to use for image frames

Definition at line 79 of file CameraSourceOSX.h.

Referenced by getName(), and nextName().

const std::string deviceName [protected]

name of hardware device the source is connected

Definition at line 80 of file CameraSourceOSX.h.

Referenced by getDeviceName().

const std::string devInputName [protected]

name of the input on the device (in case a single device has multiple inputs)

Definition at line 81 of file CameraSourceOSX.h.

Referenced by getInputName().

int devInputIdx [protected]

index number of the input

Definition at line 82 of file CameraSourceOSX.h.

unsigned int frame [protected]

current frame number

Definition at line 84 of file CameraSourceOSX.h.

unsigned int skipped [protected]

number of frames skipped since last successful frame

Definition at line 85 of file CameraSourceOSX.h.

unsigned int queuedFrames [protected]

number of frames the system indicates are waiting to be processed

Definition at line 86 of file CameraSourceOSX.h.

bool grabbing [protected]

set to true when setDataSourceThread is called with a non-NULL value, but can be set back to false if an error occurs

Definition at line 87 of file CameraSourceOSX.h.

TimeValue lastTime [protected]

Definition at line 88 of file CameraSourceOSX.h.

Referenced by nextTimestamp().

UInt32 duration [protected]

Definition at line 89 of file CameraSourceOSX.h.

Referenced by nextTimestamp().

TimeScale chanTimeScale [protected]

Definition at line 90 of file CameraSourceOSX.h.

TimeBase chanTimeBase [protected]

Definition at line 91 of file CameraSourceOSX.h.

ImageSequence drawSeq [protected]

Definition at line 92 of file CameraSourceOSX.h.

OSErr callbackerr [protected]

error value from call back, so we can tell if an error came from SGIdle itself or the callback functions it may trigger

Definition at line 93 of file CameraSourceOSX.h.

char* gworldBuf [protected]

buffer used for gworld

Definition at line 95 of file CameraSourceOSX.h.

char* imgbuf [protected]

buffer where YUV image will be stored and returned back to getData caller via payload parameter

Definition at line 97 of file CameraSourceOSX.h.

size_t imgbufSize [protected]

size of imgbuf allocation

Definition at line 98 of file CameraSourceOSX.h.

size_t imgbufUsed [protected]

amount of imgbuf's allocation which is actually in use with data

Definition at line 99 of file CameraSourceOSX.h.


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

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