15#include "itkMultiThreader.h"
16#include <itksys/SystemTools.hxx>
21 m_SourceDataBuffer(nullptr), m_SourceDataArray(nullptr)
79 this->m_FreePos = (this->m_FreePos+1) % this->
m_BufferSize;
87 this->m_ThreadID = this->m_MultiThreader->SpawnThread(this->
Acquire,
this);
89 itksys::SystemTools::Delay(10);
93 MITK_INFO<<
"Camera not connected";
108 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
109 if (pInfo ==
nullptr)
111 return ITK_THREAD_RETURN_VALUE;
113 if (pInfo->UserData ==
nullptr)
115 return ITK_THREAD_RETURN_VALUE;
118 if (toFCameraDevice!=
nullptr)
120 mitk::RealTimeClock::Pointer realTimeClock;
123 t1 = realTimeClock->GetCurrentStamp();
125 bool overflow =
false;
126 bool printStatus =
false;
138 toFCameraDevice->Modified();
157 t2 = realTimeClock->GetCurrentStamp() - t1;
158 MITK_INFO <<
" Framerate (fps): " << n / (t2/1000) <<
" Sequence: " << toFCameraDevice->
m_ImageSequence;
159 t1 = realTimeClock->GetCurrentStamp();
164 return ITK_THREAD_RETURN_VALUE;
181 amplitudeArray[i*this->m_CaptureWidth+j] = this->
m_AmplitudeArray[(i+1)*this->m_CaptureWidth-1-j];
188 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
207 intensityArray[i*this->m_CaptureWidth+j] = this->
m_IntensityArray[(i+1)*this->m_CaptureWidth-1-j];
214 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
234 distanceArray[i*this->m_CaptureWidth+j] = this->
m_DistanceArray[(i+1)*this->m_CaptureWidth-1-j];
241 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
246 int requiredImageSequence,
int& capturedImageSequence,
unsigned char* rgbDataArray)
258 MITK_INFO <<
"Buffer empty!! ";
264 if ((requiredImageSequence < 0) || (requiredImageSequence > this->
m_ImageSequence))
277 capturedImageSequence = requiredImageSequence;
294 MITK_WARN(
"ToF") <<
"Warning: Data can only be acquired if camera is active.";
306 if (
strcmp(propertyKey,
"ModulationFrequency") == 0)
308 int modulationFrequency = 0;
310 modulationFrequency =
m_Controller->SetModulationFrequency(modulationFrequency);
311 static_cast<mitk::IntProperty*
>(propertyValue)->SetValue(modulationFrequency);
314 else if (
strcmp(propertyKey,
"IntegrationTime") == 0)
316 int integrationTime = 0;
318 integrationTime =
m_Controller->SetIntegrationTime(integrationTime);
319 static_cast<mitk::IntProperty*
>(propertyValue)->SetValue(integrationTime);
static Pointer New(void)
instanciates a new, operating-system dependant, instance of mitk::RealTimeClock.
int m_ImageSequence
counter for acquired images
PropertyList::Pointer m_PropertyList
a list of the corresponding properties
virtual void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
set a BaseProperty property in the property list
int m_CaptureWidth
width of the range image (x dimension)
int m_FreePos
current position in the buffer which will be filled with data acquired from the hardware
virtual void CleanupPixelArrays()
method for cleanup memory allocated for pixel arrays m_IntensityArray, m_DistanceArray and m_Amplitud...
virtual bool IsCameraActive()
returns true if the camera is connected and started
virtual void AllocatePixelArrays()
method for allocating memory for pixel arrays m_IntensityArray, m_DistanceArray and m_AmplitudeArray
int m_CurrentPos
current position in the buffer which will be retrieved by the Get methods
int m_PixelNumber
number of pixels in the range image (m_CaptureWidth*m_CaptureHeight)
bool GetIntProperty(const char *propertyKey, int &integer)
get an int from the property list
bool m_CameraConnected
flag indicating if the camera is successfully connected or not. Caution: thread safe access only!
int m_CaptureHeight
height of the range image (y dimension)
bool m_CameraActive
flag indicating if the camera is currently active or not. Caution: thread safe access only!
float * m_AmplitudeArray
float array holding the amplitude image
int m_BufferSize
buffer size of the image buffer needed for loss-less acquisition of range data
std::mutex m_CameraActiveMutex
mutex for the cameraActive flag
std::mutex m_ImageMutex
mutex for images provided by the range camera
float * m_IntensityArray
float array holding the intensity image
int m_SourceDataSize
size of the PMD source data
float * m_DistanceArray
float array holding the distance image
int m_MaxBufferSize
maximal buffer size needed for initialization of data arrays. Default value is 100.
Interface for all representations of PMD ToF devices. ToFCameraPMDDevice internally holds an instance...
virtual void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
set a BaseProperty
virtual void AllocateSourceData()
method for allocating m_SourceDataArray and m_SourceDataBuffer
ToFCameraPMDController::Pointer GetController()
returns the corresponding camera controller
virtual bool OnConnectCamera()
opens a connection to the ToF camera
static ITK_THREAD_RETURN_TYPE Acquire(void *pInfoStruct)
Thread method continuously acquiring images from the ToF hardware.
char ** m_SourceDataBuffer
buffer holding the last acquired images
virtual bool DisconnectCamera()
closes the connection to the camera
virtual void StartCamera()
starts the continuous updating of the camera. A separate thread updates the source data,...
ToFCameraPMDController::Pointer m_Controller
corresponding CameraController
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...
char * m_SourceDataArray
array holding the current PMD source data
virtual void CleanUpSourceData()
method for cleaning up memory allocated for m_SourceDataArray and m_SourceDataBuffer
virtual void GetAllImages(float *distanceArray, float *amplitudeArray, float *intensityArray, char *sourceDataArray, int requiredImageSequence, int &capturedImageSequence, unsigned char *rgbDataArray=nullptr)
gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsi...
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...
virtual void GetDistances(float *distanceArray, int &imageSequence)
gets the distance data from the ToF camera measuring the distance between the camera and the differen...
virtual void UpdateCamera()
updated the controller hold by this device
int strcmp(const String &s1, const String &s2)