Image Component Library (ICL)
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
icl::io::dc::DCGrabberThread Class Reference

Internally spawned thread class to provide continuous grabbing without drop frames. More...

#include <DCGrabberThread.h>

Inheritance diagram for icl::io::dc::DCGrabberThread:
icl::utils::Thread icl::utils::ShallowCopyable< ThreadImpl, ThreadImplDelOp >

Public Member Functions

virtual ICLIO_API void run ()
 the thread function (moved frames) More...
 
ICLIO_API void resetBus ()
 internally calls dc1394_reset_bus (not save!) More...
 
- Public Member Functions inherited from icl::utils::Thread
 Thread ()
 Create a new Thread. More...
 
virtual ~Thread ()
 Destructor (if the thread is still running, it is ended) More...
 
void start ()
 starts the thread More...
 
virtual void stop ()
 stops the thread and waits till it is ended More...
 
void wait ()
 waits for this thread to be ended More...
 
virtual void finalize ()
 at the end of the stop function, this function is called More...
 
bool running () const
 returns the internal running state More...
 
bool runningNoLock () const
 returns the running state of the thread (without locking the mutex) More...
 
- Public Member Functions inherited from icl::utils::ShallowCopyable< ThreadImpl, ThreadImplDelOp >
bool isNull () const
 returns wheter the objects implementation holds a null pointer More...
 

Static Public Member Functions

static ICLIO_API void stopAllGrabberThreads ()
 called by the signal handler to stop all grabber threads More...
 
- Static Public Member Functions inherited from icl::utils::Thread
static void usleep (unsigned int usec)
 just calling usleep More...
 
static void msleep (unsigned int msecs)
 sets the current thread to sleep for some milli-seconds More...
 
static void sleep (float secs)
 sets the current thread to sleep for some seconds More...
 

Private Member Functions

 DCGrabberThread (dc1394camera_t *c, DCDeviceOptions *options)
 private constructor )can only be called by icl::DCGrabber More...
 
 ~DCGrabberThread ()
 Destructor. More...
 
void getCurrentImage (core::ImgBase **ppoDst, core::ImgBase **ppoDstTmp, bool &desiredParamsFullfilled, const utils::Size &desiredSizeHint, core::format desiredFormatHint, core::depth desiredDepthHint, dc1394color_filter_t bayerLayout, dc1394bayer_method_t bayerMethod=DC1394_BAYER_METHOD_BILINEAR)
 private image access function More...
 
void getCurrentImage (core::ImgBase **ppoDst, dc1394color_filter_t bayerLayout, dc1394bayer_method_t bayerMethod=DC1394_BAYER_METHOD_BILINEAR)
 returns the current image directly (if no desried parameters are set) More...
 
dc1394video_frame_t * waitForNextImageFrame ()
 

Private Attributes

DCFrameQueuem_poFrameQueue
 internally used DCFrameQueue object More...
 
dc1394camera_t * m_poCam
 Associated camera. More...
 
std::vector< icl8um_oRGBInterleavedBuffer
 internally used buffer for RGB-Bayer image conversion More...
 
DCDeviceOptionsm_poOptions
 Parents DCGrabbers options pointer. More...
 
utils::Time m_lastFramesTimeStamp
 to remember the time stamp of the last frame grabbed More...
 

Friends

class icl::io::DCGrabber
 A DCGrabberThread can only be instantiated by a DCGrabber. More...
 

Additional Inherited Members

- Public Types inherited from icl::utils::ShallowCopyable< ThreadImpl, ThreadImplDelOp >
typedef ShallowCopyable< ThreadImpl, ThreadImplDelOp > ParentSC
 
- Protected Member Functions inherited from icl::utils::Thread
void exit ()
 exits the thread using pthread_exit (must be called from within the run function) More...
 
void lock ()
 internal used lock function More...
 
int trylock ()
 internal used trylock function More...
 
void unlock ()
 internal used unlock function More...
 
void join ()
 internal used join function More...
 
- Protected Member Functions inherited from icl::utils::ShallowCopyable< ThreadImpl, ThreadImplDelOp >
 ShallowCopyable (ThreadImpl *t=0)
 create a the implementation with a given T* value More...
 
- Protected Attributes inherited from icl::utils::ShallowCopyable< ThreadImpl, ThreadImplDelOp >
SmartPtrBase< ThreadImpl, ThreadImplDelOp > impl
 shared pointer for the classes implementation More...
 

Detailed Description

Internally spawned thread class to provide continuous grabbing without drop frames.

Each DCGrabber instance uses a DCGrabberThread, which continuously dequeues and enqueus frames. Each frame can either be inside of the DMA queue or inside of the DCGrabberThreads wrapped DCFrameQueue at on time. The following ASCII art should illustrate this:

Example: using a 5-frame DMA ring buffer
DMA-Queue           [ F1 ][ F2 ]
                                                 System-Space
--------------------------------------------------------------
                                                 User-Space
                      <------------
DCFrameQueue       [ F3 ][ F4 ][ F5 ] <-- new frames a pushed here
                     /\                   so the newest frame is always
                     |                    QUEUE.back()
                     |
                  old frames move more to the left, the leftest frame is
                  then removed from the DCFrameQueue and enqeued into the
                  DMA-Queue, where it is filled with new frame data.

The DCGrabberThread continuously pops the oldest frame from its internal DCFrameQueue, and enques this frame into the DMA-Queue immediately. Then, it waits for the next frame that was filled by the DMA-Thread by calling dc1394_capture_deque(..,POLICY_WAIT). When this function call returns, the Thread will push the new frame into its internal DCFrameQueue, where it can be accessed by the application by calling the getCurrentImage() function.
Note: As it is strongly recommended not to create an own DCGrabberThread, but to use an instance of the DCGrabber instead, the DCGrabberThread has no public constructor.

Constructor & Destructor Documentation

◆ DCGrabberThread()

icl::io::dc::DCGrabberThread::DCGrabberThread ( dc1394camera_t *  c,
DCDeviceOptions options 
)
private

private constructor )can only be called by icl::DCGrabber

◆ ~DCGrabberThread()

icl::io::dc::DCGrabberThread::~DCGrabberThread ( )
private

Destructor.

Member Function Documentation

◆ getCurrentImage() [1/2]

void icl::io::dc::DCGrabberThread::getCurrentImage ( core::ImgBase **  ppoDst,
core::ImgBase **  ppoDstTmp,
bool &  desiredParamsFullfilled,
const utils::Size desiredSizeHint,
core::format  desiredFormatHint,
core::depth  desiredDepthHint,
dc1394color_filter_t  bayerLayout,
dc1394bayer_method_t  bayerMethod = DC1394_BAYER_METHOD_BILINEAR 
)
private

private image access function

complex function to get the next image The function gets all desired params from the top level grabber, which it should fullfill. But in some cases it's not possible to satisfy all desired params constraints. In this case, this function will use the second given core::ImgBase** (ppoDstTmp) as destination image and it will set the boolean reference named desiredParamsFullfilled to false. The parent grabber can check this variable, to decide whether to use the original destination pointer (ppoDst) or to use the ppoDstTmp pointer temporarily and convert is into ppoDst by itself, using the desired params for ppoDst. TODO: some more text here !

◆ getCurrentImage() [2/2]

void icl::io::dc::DCGrabberThread::getCurrentImage ( core::ImgBase **  ppoDst,
dc1394color_filter_t  bayerLayout,
dc1394bayer_method_t  bayerMethod = DC1394_BAYER_METHOD_BILINEAR 
)
private

returns the current image directly (if no desried parameters are set)

◆ resetBus()

ICLIO_API void icl::io::dc::DCGrabberThread::resetBus ( )

internally calls dc1394_reset_bus (not save!)

◆ run()

virtual ICLIO_API void icl::io::dc::DCGrabberThread::run ( )
virtual

the thread function (moved frames)

Implements icl::utils::Thread.

◆ stopAllGrabberThreads()

static ICLIO_API void icl::io::dc::DCGrabberThread::stopAllGrabberThreads ( )
static

called by the signal handler to stop all grabber threads

◆ waitForNextImageFrame()

dc1394video_frame_t* icl::io::dc::DCGrabberThread::waitForNextImageFrame ( )
private

Friends And Related Function Documentation

◆ icl::io::DCGrabber

friend class icl::io::DCGrabber
friend

A DCGrabberThread can only be instantiated by a DCGrabber.

Member Data Documentation

◆ m_lastFramesTimeStamp

utils::Time icl::io::dc::DCGrabberThread::m_lastFramesTimeStamp
private

to remember the time stamp of the last frame grabbed

◆ m_oRGBInterleavedBuffer

std::vector<icl8u> icl::io::dc::DCGrabberThread::m_oRGBInterleavedBuffer
private

internally used buffer for RGB-Bayer image conversion

◆ m_poCam

dc1394camera_t* icl::io::dc::DCGrabberThread::m_poCam
private

Associated camera.

◆ m_poFrameQueue

DCFrameQueue* icl::io::dc::DCGrabberThread::m_poFrameQueue
private

internally used DCFrameQueue object

◆ m_poOptions

DCDeviceOptions* icl::io::dc::DCGrabberThread::m_poOptions
private

Parents DCGrabbers options pointer.


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