22 #include <itkMultiThreader.h>
23 #include <itksys/SystemTools.hxx>
28 m_DistanceDataBuffer(NULL), m_AmplitudeDataBuffer(NULL), m_IntensityDataBuffer(NULL), m_RGBDataBuffer(NULL)
82 this->
m_Controller->GetAmplitudes(this->m_AmplitudeDataBuffer[this->m_FreePos]);
83 this->
m_Controller->GetIntensities(this->m_IntensityDataBuffer[this->m_FreePos]);
84 this->
m_Controller->GetRgb(this->m_RGBDataBuffer[this->m_FreePos]);
85 this->m_FreePos = (this->m_FreePos+1) % this->
m_BufferSize;
95 itksys::SystemTools::Delay(10);
111 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
114 return ITK_THREAD_RETURN_VALUE;
116 if (pInfo->UserData == NULL)
118 return ITK_THREAD_RETURN_VALUE;
121 if (toFCameraDevice!=NULL)
127 t1 = realTimeClock->GetCurrentStamp();
128 bool overflow =
false;
129 bool printStatus =
false;
135 toFCameraDevice->
m_Controller->GetDistances(toFCameraDevice->m_DistanceDataBuffer[toFCameraDevice->
m_FreePos]);
136 toFCameraDevice->
m_Controller->GetAmplitudes(toFCameraDevice->m_AmplitudeDataBuffer[toFCameraDevice->
m_FreePos]);
137 toFCameraDevice->
m_Controller->GetIntensities(toFCameraDevice->m_IntensityDataBuffer[toFCameraDevice->
m_FreePos]);
139 toFCameraDevice->Modified();
160 t2 = realTimeClock->GetCurrentStamp() - t1;
162 t1 = realTimeClock->GetCurrentStamp();
167 return ITK_THREAD_RETURN_VALUE;
176 amplitudeArray[i] = this->m_AmplitudeDataBuffer[this->
m_CurrentPos][i];
188 intensityArray[i] = this->m_IntensityDataBuffer[this->
m_CurrentPos][i];
200 distanceArray[i] = this->m_DistanceDataBuffer[this->
m_CurrentPos][i];
212 rgbArray[i] = this->m_RGBDataBuffer[this->
m_CurrentPos][i];
219 int requiredImageSequence,
int& capturedImageSequence,
unsigned char* rgbDataArray)
234 if ((requiredImageSequence < 0) || (requiredImageSequence > this->
m_ImageSequence))
246 capturedImageSequence = requiredImageSequence;
250 if(this->m_DistanceDataBuffer&&this->m_AmplitudeDataBuffer&&this->m_IntensityDataBuffer&&this->m_RGBDataBuffer)
253 memcpy(distanceArray, this->m_DistanceDataBuffer[pos], this->
m_PixelNumber *
sizeof(
float));
254 memcpy(amplitudeArray, this->m_AmplitudeDataBuffer[pos], this->
m_PixelNumber *
sizeof(
float));
255 memcpy(intensityArray, this->m_IntensityDataBuffer[pos], this->
m_PixelNumber *
sizeof(
float));
256 memcpy(rgbDataArray, this->m_RGBDataBuffer[pos], this->
m_RGBPixelNumber * 3 *
sizeof(
unsigned char));
273 std::string strValue;
275 if (strcmp(propertyKey,
"DistanceImageFileName") == 0)
277 myController->SetDistanceImageFileName(strValue);
279 else if (strcmp(propertyKey,
"AmplitudeImageFileName") == 0)
281 std::ifstream amplitudeImage(strValue.c_str());
285 myController->SetAmplitudeImageFileName(strValue);
289 MITK_WARN <<
"File " << strValue <<
" does not exist!";
292 else if (strcmp(propertyKey,
"IntensityImageFileName") == 0)
294 std::ifstream intensityImage(strValue.c_str());
298 myController->SetIntensityImageFileName(strValue);
302 MITK_WARN <<
"File " << strValue <<
" does not exist!";
305 else if (strcmp(propertyKey,
"RGBImageFileName") == 0)
307 std::ifstream intensityImage(strValue.c_str());
311 myController->SetRGBImageFileName(strValue);
315 MITK_WARN <<
"File " << strValue <<
" does not exist!";
322 if (m_DistanceDataBuffer)
326 delete[] this->m_DistanceDataBuffer[i];
328 delete[] this->m_DistanceDataBuffer;
330 if (m_AmplitudeDataBuffer)
334 delete[] this->m_AmplitudeDataBuffer[i];
336 delete[] this->m_AmplitudeDataBuffer;
338 if (m_IntensityDataBuffer)
342 delete[] this->m_IntensityDataBuffer[i];
344 delete[] this->m_IntensityDataBuffer;
350 delete[] this->m_RGBDataBuffer[i];
352 delete[] this->m_RGBDataBuffer;
364 this->m_DistanceDataBuffer[i] =
new float[this->
m_PixelNumber];
369 this->m_AmplitudeDataBuffer[i] =
new float[this->
m_PixelNumber];
374 this->m_IntensityDataBuffer[i] =
new float[this->
m_PixelNumber];
itk::SmartPointer< Self > Pointer
std::string m_InputFileName
member holding the file name of the current input file
int m_RGBPixelNumber
number of pixels in the range image (m_RGBImageWidth*m_RGBImageHeight)
bool GetStringProperty(const char *propertyKey, std::string &string)
get a string from the property list
virtual void SetInputFileName(std::string inputFileName)
Set file name where the data is recorded.
int m_PixelNumber
number of pixels in the range image (m_CaptureWidth*m_CaptureHeight)
DataCollection - Class to facilitate loading/accessing structured data.
ToFCameraMITKPlayerDevice()
~ToFCameraMITKPlayerDevice()
PropertyList::Pointer m_PropertyList
a list of the corresponding properties
int m_ThreadID
ID of the started thread.
void CleanUpDataBuffers()
Clean up memory (pixel buffers)
virtual bool DisconnectCamera() override
closes the connection to the camera
itk::FastMutexLock::Pointer m_CameraActiveMutex
mutex for the cameraActive flag
virtual void GetRgb(unsigned char *rgbArray, int &imageSequence)
gets the rgb data from the ToF camera. Caution! The user is responsible for allocating and deleting t...
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.
int m_RGBImageHeight
height of the RGB image (y dimension)
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! ...
Device class representing a player for MITK-ToF images.
int m_CaptureWidth
width of the range image (x dimension)
itk::FastMutexLock::Pointer m_ImageMutex
mutex for images provided by the range camera
ToFCameraMITKPlayerController::Pointer m_Controller
member holding the corresponding controller
virtual void AllocatePixelArrays()
method for allocating memory for pixel arrays m_IntensityArray, m_DistanceArray and m_AmplitudeArray ...
virtual void UpdateCamera() override
updates the camera for image acquisition
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.
virtual bool OnConnectCamera() override
opens a connection to the ToF camera
virtual void GetAllImages(float *distanceArray, float *amplitudeArray, float *intensityArray, char *sourceDataArray, int requiredImageSequence, int &capturedImageSequence, unsigned char *rgbDataArray=NULL) override
gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsi...
int m_CaptureHeight
height of the range image (y dimension)
virtual void SetProperty(const char *propertyKey, BaseProperty *propertyValue) override
set a BaseProperty
virtual void GetAmplitudes(float *amplitudeArray, int &imageSequence) override
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) override
gets the distance data from the ToF camera measuring the distance between the camera and the differen...
void AllocateDataBuffers()
Allocate pixel buffers.
Controller for playing ToF images saved in MITK (.pic) format.
static Pointer New(void)
instanciates a new, operating-system dependant, instance of mitk::RealTimeClock.
void SetBoolProperty(const char *propertyKey, bool boolValue)
set a bool property in the property list
int m_RGBImageWidth
width of the RGB image (x dimension)
static ITK_THREAD_RETURN_TYPE Acquire(void *pInfoStruct)
Thread method continuously acquiring images from the specified input file.
int m_ImageSequence
counter for acquired images
virtual bool IsCameraActive()
returns true if the camera is connected and started
virtual void GetIntensities(float *intensityArray, int &imageSequence) override
gets the intensity data from the ToF camera as a greyscale image. Caution! The user is responsible fo...
virtual void StartCamera() override
starts the continuous updating of the camera. A separate thread updates the source data...