19 #ifdef MITK_USE_TOF_PMDCAMBOARD
23 #ifdef MITK_USE_TOF_PMDCAMCUBE
27 #ifdef MITK_USE_TOF_PMDO3
31 #include "itkMultiThreader.h"
32 #include <itksys/SystemTools.hxx>
37 m_SourceDataBuffer(NULL), m_SourceDataArray(NULL), m_ShortSourceData(NULL),
38 m_OriginControllerWidth(0), m_OriginControllerHeight(0)
96 this->m_FreePos = (this->m_FreePos+1) % this->
m_BufferSize;
107 itksys::SystemTools::Delay(100);
121 itksys::SystemTools::Delay(100);
127 itksys::SystemTools::Delay(10);
149 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
152 return ITK_THREAD_RETURN_VALUE;
154 if (pInfo->UserData == NULL)
156 return ITK_THREAD_RETURN_VALUE;
159 if (toFCameraDevice!=NULL)
163 t1 = realTimeClock->GetCurrentStamp();
165 bool overflow =
false;
166 bool printStatus =
false;
174 toFCameraDevice->Modified();
186 toFCameraDevice->
m_Controller->GetModulationFrequency(),
208 channelData->Delete();
218 t2 = realTimeClock->GetCurrentStamp() - t1;
220 t1 = realTimeClock->GetCurrentStamp();
226 return ITK_THREAD_RETURN_VALUE;
238 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
251 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
264 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
269 int requiredImageSequence,
int& capturedImageSequence,
unsigned char* rgbDataArray)
284 if ((requiredImageSequence < 0) || (requiredImageSequence > this->
m_ImageSequence))
299 capturedImageSequence = requiredImageSequence;
310 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
323 if(xAxis == 1 && yAxis != 1)
325 for (
int i=0; i<captureHeight; i++)
327 for (
int j=0; j<captureWidth; j++)
329 for (
int k=0; k<dimension; k++)
331 flippedData[i*captureWidth*dimension+j*dimension+k] = imageData[((captureHeight-1-i)*captureWidth*dimension)+((j)*dimension+k)];
340 if(xAxis!=1 && yAxis == 1)
342 for (
int i=0; i<captureHeight; i++)
344 for (
int j=0; j<captureWidth; j++)
346 for (
int k=0; k<dimension; k++)
348 flippedData[i*captureWidth*dimension+j*dimension+k] = imageData[(i+1)*captureWidth*dimension-1-j*dimension-k];
358 else if(xAxis == 1 && yAxis == 1)
360 for (
int i=0; i<captureHeight; i++)
362 for (
int j=0; j<captureWidth; j++)
364 for (
int k=0; k<dimension; k++)
366 flippedData[i*captureWidth*dimension+j*dimension+k] = imageData[((captureHeight-i)*(captureWidth)*dimension-1)-(j*dimension-k)];
382 if (strcmp(propertyKey,
"ModulationFrequency") == 0)
384 int modulationFrequency = 0;
386 m_Controller->SetModulationFrequency(modulationFrequency);
388 else if (strcmp(propertyKey,
"IntegrationTime") == 0)
390 int integrationTime = 0;
static ITK_THREAD_RETURN_TYPE Acquire(void *pInfoStruct)
Thread method continuously acquiring images from the ToF hardware.
virtual void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
set a BaseProperty
virtual int GetCaptureHeight()
get the currently set capture height
itk::SmartPointer< Self > Pointer
char * m_SourceDataArray
array holding the current PMD source data
virtual bool OnConnectCamera()
opens a connection to the ToF camera
virtual void CleanUpSourceData()
method for cleaning up memory allocated for m_SourceDataArray and m_SourceDataBuffer ...
char ** m_SourceDataBuffer
buffer holding the last acquired images
virtual bool DisconnectCamera()
closes the connection to the camera
int m_SourceDataSize
size of the PMD source data
float * m_IntensityArray
float array holding the intensity image
unsigned int m_OriginControllerHeight
holds the original controller height
int m_PixelNumber
number of pixels in the range image (m_CaptureWidth*m_CaptureHeight)
DataCollection - Class to facilitate loading/accessing structured data.
~ToFCameraPMDRawDataDevice()
ToFCameraPMDRawDataDevice()
ToFCameraPMDController::Pointer GetController()
returns the corresponding camera controller
PropertyList::Pointer m_PropertyList
a list of the corresponding properties
Interface for all representations of PMD ToF devices. ToFCameraPMDDevice internally holds an instance...
float * m_DistanceArray
float array holding the distance image
int m_ThreadID
ID of the started thread.
bool GetIntProperty(const char *propertyKey, int &integer)
get an int from the property list
virtual void CleanupPixelArrays()
method for cleanup memory allocated for pixel arrays m_IntensityArray, m_DistanceArray and m_Amplitud...
virtual void UpdateCamera()
updates the camera for image acquisition
virtual void GetDistances(float *distanceArray, int &imageSequence)
gets the distance data from the ToF camera measuring the distance between the camera and the differen...
itk::FastMutexLock::Pointer m_CameraActiveMutex
mutex for the cameraActive flag
itk::MultiThreader::Pointer m_MultiThreader
itk::MultiThreader used for thread handling
int m_FreePos
current position in the buffer which will be filled with data acquired from the hardware ...
Abstract base class for properties.
virtual void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
set a BaseProperty property in the property list
virtual void GetAllImages(float *distanceArray, float *amplitudeArray, float *intensityArray, char *sourceDataArray, int requiredImageSequence, int &capturedImageSequence, unsigned char *rgbDataArray=NULL)
gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsi...
virtual void GetChannelSourceData(short *, vtkShortArray *)
bool m_CameraActive
flag indicating if the camera is currently active or not. Caution: thread safe access only! ...
int m_CurrentPos
current position in the buffer which will be retrieved by the Get methods
bool m_CameraConnected
flag indicating if the camera is successfully connected or not. Caution: thread safe access only! ...
virtual void AllocateSourceData()
method for allocating m_SourceDataArray and m_SourceDataBuffer
ThreadedToFRawDataReconstruction::Pointer m_RawDataSource
int m_CaptureWidth
width of the range image (x dimension)
virtual void StartCamera()
starts the continuous updating of the camera. A separate thread updates the source data...
virtual void GetAmplitudes(float *amplitudeArray, int &imageSequence)
gets the amplitude data from the ToF camera as the strength of the active illumination of every pixel...
itk::FastMutexLock::Pointer m_ImageMutex
mutex for images provided by the range camera
virtual bool IsCameraActive()
returns whether the camera is currently active or not
virtual int GetChannelSize()
int m_BufferSize
buffer size of the image buffer needed for loss-less acquisition of range data
int m_MaxBufferSize
maximal buffer size needed for initialization of data arrays. Default value is 100.
ToFCameraPMDController::Pointer m_Controller
corresponding CameraController
int m_CaptureHeight
height of the range image (y dimension)
void XYAxisFlipImage(float *imageData, float *&flippedData, int xAxis, int yAxis, int dimension=1)
gets the image data and flips it according to user needs Caution! The user is responsible for allocat...
short * m_ShortSourceData
array holding the current PMD raw data
virtual void AllocatePixelArrays()
method for allocating memory for pixel arrays m_IntensityArray, m_DistanceArray and m_AmplitudeArray ...
float * m_AmplitudeArray
float array holding the amplitude image
static Pointer New(void)
instanciates a new, operating-system dependant, instance of mitk::RealTimeClock.
unsigned int m_OriginControllerWidth
holds the original controller width
virtual void StopCamera()
stops the continuous updating of the camera
virtual int GetCaptureWidth()
get the currently set capture width
int m_ImageSequence
counter for acquired images
virtual void GetIntensities(float *intensityArray, int &imageSequence)
gets the intensity data from the ToF camera as a greyscale image. Caution! The user is responsible fo...
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.