itom 1.3.0
ito::threadCamera Class Reference

Helper class to give plugin-Developer an easy access to cameras in other threads. More...

#include <helperGrabber.h>

List of all members.

Public Member Functions

 threadCamera (QVector< ito::ParamBase > *parameterVector, int paramNumber)
 ~threadCamera ()
ito::RetVal startDevice (int timeOutMS=PLUGINWAIT)
ito::RetVal stopDevice (int timeOutMS=PLUGINWAIT)
ito::RetVal acquire (const int trigger, int timeOutMS=PLUGINWAIT)
ito::RetVal getVal (ito::DataObject &dObj, int timeOutMS=PLUGINWAIT)
ito::RetVal copyVal (ito::DataObject &dObj, int timeOutMS=PLUGINWAIT)
ito::RetVal getParam (ito::Param &val, int timeOutMS=PLUGINWAIT)
ito::RetVal setParam (ito::ParamBase val, int timeOutMS=PLUGINWAIT)
ito::RetVal getImageParams (int &bpp, int &xsize, int &ysize, int timeOutMS=PLUGINWAIT)

Private Member Functions

ito::RetVal securityChecks ()
ito::RetVal waitForSemaphore (int timeOutMS=PLUGINWAIT)

Private Attributes

ito::AddInGrabberpMyCamera
ito::RetVal errorBuffer
ItomSharedSemaphoreLocker pMySemaphoreLocker

Detailed Description

Helper class to give plugin-Developer an easy access to cameras in other threads.

The threadCamera-Class can be used in filters and algorithms when a camera (framegrabber) in another thread is neccessary. Every capture procedure starts with the startDevice() to set the camera active and is ended with stopDevice(). Between this a undefined number of captures can be done. A capture procedure constist either of threadCamera::acquire(...) + threadCamera::getVal(...) or threadCamera::acquire(...) + threadCamera::copyVal(...). Thereby the acquire only triggers an exposure and DO NOT wait until it is finished. This is done by getVal or copyVal! The acquire / getVal combination returns a shallow copy of the inner dataObject in the grabber. After the next acquire / getVal the content of the result will be overwritten though it is not deep copied earlier. The acquire / copyVal combination returns a deep copy of the grabber memory to the defined external dataObject.

Warning:
check the shallow-copy / deep copy part
Author:
Wolfram Lyda (ITO)
Date:
04.2012

Constructor & Destructor Documentation

ito::threadCamera::threadCamera ( QVector< ito::ParamBase > *  parameterVector,
int  paramNumber 
)

< Wait until camera-thread has finished the last command

The constructor checks if parameterVector[paramNumber] is a valid camera. If yes and the camera is accessable (try bpp) the camera handle is stored in pMyCamera. The Semaphore for the invoke-method is also allocated here. If the camera is invalid keeps beeing NULL.

Parameters:
[in]parameterVectoris the ParameterVector (optional or mandatory) of the filter / algorithm
[in]paramNumberis the zerobased number of the camera in the parameterlist
Returns:
(void)
See also:
threadCamera
ito::threadCamera::~threadCamera ( )

< Constructor

The destructor. Deletes the semaphore after waiting a last time.

Returns:
(void)
See also:
threadActuator

Member Function Documentation

ito::RetVal ito::threadCamera::acquire ( const int  trigger,
int  timeOutMS = PLUGINWAIT 
)

< Set camera deactive

The acquire()-function triggers a new exposure of the camera and returns afterwards. It can only be executed after startDevice(). The function does not wait until the exposure is done. This is performed by the getVal or copyVal-method.

Parameters:
[in]triggerA currently not implemented constant to define trigger-modes during exposure of the camera
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera, threadCamera::stopDevice, threadCamera::startDevice, threadCamera::getVal, threadCamera::copyVal
ito::RetVal ito::threadCamera::copyVal ( ito::DataObject dObj,
int  timeOutMS = PLUGINWAIT 
)

< Get a shallow-copy of the dataObject

The copyVal function is used to wait until an exposure is finished. Than it gives a deep copy of the inner dataObject within the grabber to the dObj-argument. Before the copyVal()-function can be used an acquire() is neccessary. If the content of dObj do not need to be deepcopied to another object and will not be overwritten after the next acquire() - getVal() combination.

Parameters:
[in|out]dObj IN: an dataObject | OUT: an dataObject containing an shallow copy of the last captured image
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera, threadCamera::stopDevice, threadCamera::acquire, threadCamera::getVal, threadCamera::startDevice

< Get a deep-copy of the dataObject

ito::RetVal ito::threadCamera::getImageParams ( int &  bpp,
int &  xsize,
int &  ysize,
int  timeOutMS = PLUGINWAIT 
)

< Set the parameter of the stage

Get the most important parameter of the camera.

Parameters:
[out]bppNumber of Bits this camera grabs
[out]xsizeSize of the camera in x (cols)
[out]ysizeSize of the camera in y (rows)
Returns:
retOk or retError
See also:
threadActuator, threadCamera
ito::RetVal ito::threadCamera::getParam ( ito::Param val,
int  timeOutMS = PLUGINWAIT 
)

< Get a deep-copy of the dataObject

Get any parameter of the camera defined by val.name. val must be initialised and name must be correct. After correct execution, val has the correct value.

Parameters:
[in|out]val Initialised tParam (correct name | in)
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera
ito::RetVal ito::threadCamera::getVal ( ito::DataObject dObj,
int  timeOutMS = PLUGINWAIT 
)

< Trigger an exposure and return before image is done

The getVal function is used to wait until an exposure is finished. Than it gives a shallow copy of the inner dataObject within the grabber to the dObj-argument. Before the getVal()-function can be used an acquire() is neccessary. If the content of dObj is not deepcopied to another object, the data is lost after the next acquire() - getVal() combination and overwritten by the newly captured image.

Parameters:
[in|out]dObj IN: an dataObject | OUT: an dataObject containing an shallow copy of the last captured image
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera, threadCamera::stopDevice, threadCamera::acquire, threadCamera::startDevice, threadCamera::copyVal

< Get a shallow-copy of the dataObject

ito::RetVal ito::threadCamera::securityChecks ( ) [inline, private]

< Handle to the semaphore needed for thread save communication. Allocated in constructor

This function is called by every subroutine of the threadActuator. It checks if the camera-handle and the semaphore handle is zero and if the semaphore has waited after last command. If the semaphore droppes or dropped to time-out it returns retError.

Returns:
retOk or retError
See also:
threadActuator
ito::RetVal ito::threadCamera::setParam ( ito::ParamBase  val,
int  timeOutMS = PLUGINWAIT 
)

< Get the parameter of the stage

Get the parameter of the camera defined by val.name to the value of val.

Parameters:
[in]valInitialised tParam (correct name | value)
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera
ito::RetVal ito::threadCamera::startDevice ( int  timeOutMS = PLUGINWAIT)

< Desctructor

Every capture procedure starts with the startDevice() to set the camera active and is ended with stopDevice().

Parameters:
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera, threadCamera::stopDevice, threadCamera::acquire, threadCamera::getVal, threadCamera::copyVal
ito::RetVal ito::threadCamera::stopDevice ( int  timeOutMS = PLUGINWAIT)

< Set camera active

Every capture procedure starts with the startDevice() to set the camera active and is ended with stopDevice().

Parameters:
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera, threadCamera::startDevice, threadCamera::acquire, threadCamera::getVal, threadCamera::copyVal
ito::RetVal ito::threadCamera::waitForSemaphore ( int  timeOutMS = PLUGINWAIT) [private]

After the invoke-command this thread must wait / be synchronize with the camera-thread. Therefore the wait-Function of pMySemaphore is called. If the camera do not answer within timeOutMS and the pMyCamera is not alive anymore, the function returns a timeout.

Parameters:
[in]timeOutMSTimeOut for the semaphore-wait
Returns:
retOk or retError
See also:
threadActuator, threadCamera

Member Data Documentation

< Handle to the Grabber

< Buffer containing unrecieved errors from the semaphore


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends