Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CameraSourceQTKit Class Reference

This interfaces with a specific camera through the QTKit API, which is the only capture interface which supports 64-bit on OS X. More...

#include <CameraSourceQTKit.h>

Inheritance diagram for CameraSourceQTKit:

Detailed Description

This interfaces with a specific camera through the QTKit API, which is the only capture interface which supports 64-bit on OS X.

Definition at line 14 of file CameraSourceQTKit.h.

List of all members.

Public Types

enum  PixelFormat_t { TYPE_UNKNOWN = 0, TYPE_YUVS = kComponentVideoUnsigned, TYPE_2VUY = kCVPixelFormatType_422YpCbCr8, TYPE_GRAY = kCVPixelFormatType_8IndexedGray_WhiteIsZero }
 

Conversion formats supported for requesting camera output.

More...

Public Member Functions

 CameraSourceQTKit (const std::string &srcName, QTCaptureDevice *capDevice)
 constructor
 ~CameraSourceQTKit ()
 destructor
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 (e.g. a filename for logged data).
virtual void registerSource ()
 User hook, called when the data source should claim which outputs it provides feedback (providingOuput()).
virtual void deregisterSource ()
 User hook, called when the data source should release its claim on outputs with feedback (ignoringOuput()).
virtual bool advance ()
 Called when the simulator is stepping while paused or advancing a frozen data source, return true if successful, or false if no more data is available.
void processImage (CVImageBufferRef videoFrame, QTSampleBuffer *sampleBuffer)
 called from delegate with each frame

Public Attributes

plist::Primitive< boolparallel
 If true, will attempt to use Apple's Grand Central Dispatch to do block processing... this parallelizes image processing, may slightly increase total CPU usage but reduces per-frame wall time.
plist::Primitive< boolhighRes
 If true, upsamples color channels horizontally to match Y channel, otherwise downsamples everything to common resolution (y/4, u,v/2); set to true to use full resolution of camera (either as the “full” layer or if you are accessing the “double” layer), set to false if you are using half-resolution as the resolution of the “full” layer.
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::NamedEnumeration
< PixelFormat_t
format
 If non-empty, requests the camera convert to the specified format (a four character code aka FourCC).

Protected Member Functions

void init ()
 general initialization: add configuration entries, retain device and create delegate
void doFreeze ()
 user hook for when frozen is set to true; advance() will be called by simulator at user discretion.
void doUnfreeze ()
 user hook for when frozen is set to false; if enteringRealtime() has been called then you should resume sending data.
void process_yuvs_U (const unsigned char *s, unsigned int srcWidth, unsigned int srcHeight)
 yuyv ordering, upsample by duplicating u and v columns
void process_yuvs_D (const unsigned char *s, unsigned int srcWidth, unsigned int srcHeight)
 yuyv ordering, downsample to common resolution (y/4, u,v/2)
void process_2vuy_D (const unsigned char *s, unsigned int srcWidth, unsigned int srcHeight)
 uyvy ordering, upsample by duplicating u and v columns
void process_2vuy_U (const unsigned char *s, unsigned int srcWidth, unsigned int srcHeight)
 uyvy ordering, downsample to common resolution (y/4, u,v/2)
void process_grayscale_zerowhite (const unsigned char *s, unsigned int srcWidth, unsigned int srcHeight)
 Grayscale, white is 0.

Static Protected Member Functions

static std::string CC2Str (unsigned int fourcc)
 Returns the four-character-code as a string for display.
static unsigned int Str2CC (const std::string &fourcc)
 returns the display string as a four-character-code

Protected Attributes

std::string name
QTCaptureDevice *const device
 the camera associated with this instance
QTCaptureSession * session
 the capture session created in registerSource (thus non-NULL if registered), used to start/stop capture when frozen
CameraSourceQTKitDelegatedelegate
 receives per-frame callbacks from the session, forwards calls to processImage()
unsigned int frame
 a frame index counter
float lastTime
 time in seconds of ideal frame arrival time, if drifts more than a frame duration, reset via get_time()
float duration
 the frame duration encoded in the captured frame meta-data
bool oneFrame
 set to true by advance(), indicates capture should stop once a frame is sent
Thread::Lock frameLock
 held by advance() when waiting for a frame
Thread::Condition frameCond
 condition to wake up advance when a frame has been sent

Private Member Functions

 CameraSourceQTKit (const CameraSourceQTKit &)
 do not copy
CameraSourceQTKitoperator= (const CameraSourceQTKit &)
 do not assign

Member Enumeration Documentation

Conversion formats supported for requesting camera output.

Enumerator:
TYPE_UNKNOWN 

should avoid requesting any format, see what the camera's “native” format is

TYPE_YUVS 

the native format for iSight camera on 2010 Macbook Pros, 10.6.3

TYPE_2VUY 

alternative supported format of 2010 iSight camera on 10.6.3, byte reordering of TYPE_YUVS

TYPE_GRAY 

alternative supported format of 2010 iSight camera on 10.6.3, Y channel only

Definition at line 27 of file CameraSourceQTKit.h.


Constructor & Destructor Documentation

CameraSourceQTKit ( const std::string &  srcName,
QTCaptureDevice *  capDevice 
)

constructor

Definition at line 38 of file CameraSourceQTKit.h.

destructor

CameraSourceQTKit ( const CameraSourceQTKit  )  [private]

do not copy


Member Function Documentation

virtual bool advance (  )  [virtual]

Called when the simulator is stepping while paused or advancing a frozen data source, return true if successful, or false if no more data is available.

Implements DataSource.

static std::string CC2Str ( unsigned int  fourcc  )  [static, protected]

Returns the four-character-code as a string for display.

virtual void deregisterSource (  )  [virtual]

User hook, called when the data source should release its claim on outputs with feedback (ignoringOuput()).

It would be wise to call this from your destructor as well.

Reimplemented from DataSource.

void doFreeze (  )  [protected, virtual]

user hook for when frozen is set to true; advance() will be called by simulator at user discretion.

Reimplemented from DataSource.

void doUnfreeze (  )  [protected, virtual]

user hook for when frozen is set to false; if enteringRealtime() has been called then you should resume sending data.

Reimplemented from DataSource.

void init (  )  [protected]

general initialization: add configuration entries, retain device and create delegate

Referenced by CameraSourceQTKit().

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

Returns a descriptive name of the next data segment for user feedback (e.g. a filename for logged data).

Just use your class name if you don't have a useful name for individual samples.

Implements DataSource.

Definition at line 48 of file CameraSourceQTKit.h.

virtual 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

Implements DataSource.

Definition at line 47 of file CameraSourceQTKit.h.

CameraSourceQTKit& operator= ( const CameraSourceQTKit  )  [private]

do not assign

void process_2vuy_D ( const unsigned char *  s,
unsigned int  srcWidth,
unsigned int  srcHeight 
) [protected]

uyvy ordering, upsample by duplicating u and v columns

Uses CCIR601 range (e.g. Y ∈ [16,235] )

void process_2vuy_U ( const unsigned char *  s,
unsigned int  srcWidth,
unsigned int  srcHeight 
) [protected]

uyvy ordering, downsample to common resolution (y/4, u,v/2)

Uses CCIR601 range (e.g. Y ∈ [16,235] )

void process_grayscale_zerowhite ( const unsigned char *  s,
unsigned int  srcWidth,
unsigned int  srcHeight 
) [protected]

Grayscale, white is 0.

Need to convert to CCIR601 (y = (255-g)·219/255+16) and fill in u=v=128 You might think compressing the Y range would lower quality, but inspecting data from iSight indicates it originates as CCIR601, with this setting showing gaps in the histogram as it was stretched to full range, so really this is just resetting

void process_yuvs_D ( const unsigned char *  s,
unsigned int  srcWidth,
unsigned int  srcHeight 
) [protected]

yuyv ordering, downsample to common resolution (y/4, u,v/2)

Uses CCIR601 range (e.g. Y ∈ [16,235] )

void process_yuvs_U ( const unsigned char *  s,
unsigned int  srcWidth,
unsigned int  srcHeight 
) [protected]

yuyv ordering, upsample by duplicating u and v columns

Uses CCIR601 range (e.g. Y ∈ [16,235] )

void processImage ( CVImageBufferRef  videoFrame,
QTSampleBuffer *  sampleBuffer 
)

called from delegate with each frame

virtual void registerSource (  )  [virtual]

User hook, called when the data source should claim which outputs it provides feedback (providingOuput()).

Does not indicate the data source should start sending updates yet — wait for enteringRealtime() or advance() to be called

Reimplemented from DataSource.

static unsigned int Str2CC ( const std::string &  fourcc  )  [static, protected]

returns the display string as a four-character-code


Member Data Documentation

receives per-frame callbacks from the session, forwards calls to processImage()

Definition at line 96 of file CameraSourceQTKit.h.

QTCaptureDevice* const device [protected]

the camera associated with this instance

Definition at line 94 of file CameraSourceQTKit.h.

float duration [protected]

the frame duration encoded in the captured frame meta-data

Definition at line 100 of file CameraSourceQTKit.h.

Referenced by nextTimestamp().

If non-empty, requests the camera convert to the specified format (a four character code aka FourCC).

Definition at line 35 of file CameraSourceQTKit.h.

unsigned int frame [protected]

a frame index counter

Definition at line 98 of file CameraSourceQTKit.h.

condition to wake up advance when a frame has been sent

Definition at line 103 of file CameraSourceQTKit.h.

Thread::Lock frameLock [protected]

held by advance() when waiting for a frame

Definition at line 102 of file CameraSourceQTKit.h.

If true, upsamples color channels horizontally to match Y channel, otherwise downsamples everything to common resolution (y/4, u,v/2); set to true to use full resolution of camera (either as the “full” layer or if you are accessing the “double” layer), set to false if you are using half-resolution as the resolution of the “full” layer.

Definition at line 21 of file CameraSourceQTKit.h.

float lastTime [protected]

time in seconds of ideal frame arrival time, if drifts more than a frame duration, reset via get_time()

Definition at line 99 of file CameraSourceQTKit.h.

Referenced by nextTimestamp().

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 24 of file CameraSourceQTKit.h.

std::string name [protected]

Definition at line 93 of file CameraSourceQTKit.h.

Referenced by nextName().

bool oneFrame [protected]

set to true by advance(), indicates capture should stop once a frame is sent

Definition at line 101 of file CameraSourceQTKit.h.

If true, will attempt to use Apple's Grand Central Dispatch to do block processing... this parallelizes image processing, may slightly increase total CPU usage but reduces per-frame wall time.

Definition at line 18 of file CameraSourceQTKit.h.

QTCaptureSession* session [protected]

the capture session created in registerSource (thus non-NULL if registered), used to start/stop capture when frozen

Definition at line 95 of file CameraSourceQTKit.h.


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

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:40 2016 by Doxygen 1.6.3