itom 2.0.0
|
Helper class to give plugin-Developer an easy access to cameras in other threads. More...
#include <helperGrabber.h>
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::AddInGrabber * | pMyCamera |
ito::RetVal | errorBuffer |
ItomSharedSemaphoreLocker | pMySemaphoreLocker |
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.
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.
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.
[in] | parameterVector | is the ParameterVector (optional or mandatory) of the filter / algorithm |
[in] | paramNumber | is the zerobased number of the camera in the parameterlist |
ito::threadCamera::~threadCamera | ( | ) |
< Constructor
The destructor. Deletes the semaphore after waiting a last time.
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.
[in] | trigger | A currently not implemented constant to define trigger-modes during exposure of the camera |
[in] | timeOutMS | TimeOut for the semaphore-wait |
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.
[in|out] | dObj IN: an dataObject | OUT: an dataObject containing an shallow copy of the last captured image | |
[in] | timeOutMS | TimeOut for the semaphore-wait |
< 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.
[out] | bpp | Number of Bits this camera grabs |
[out] | xsize | Size of the camera in x (cols) |
[out] | ysize | Size of the camera in y (rows) |
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.
[in|out] | val Initialised tParam (correct name | in) | |
[in] | timeOutMS | TimeOut for the semaphore-wait |
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.
[in|out] | dObj IN: an dataObject | OUT: an dataObject containing an shallow copy of the last captured image | |
[in] | timeOutMS | TimeOut for the semaphore-wait |
< 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.
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.
[in] | val | Initialised tParam (correct name | value) |
[in] | timeOutMS | TimeOut for the semaphore-wait |
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().
[in] | timeOutMS | TimeOut for the semaphore-wait |
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().
[in] | timeOutMS | TimeOut for the semaphore-wait |
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.
[in] | timeOutMS | TimeOut for the semaphore-wait |
ito::RetVal ito::threadCamera::errorBuffer [private] |
< Handle to the Grabber
< Buffer containing unrecieved errors from the semaphore