18 #include <itkMultiThreader.h> 19 #include <itksys/SystemTools.hxx> 24 m_DistanceDataBuffer(nullptr), m_AmplitudeDataBuffer(nullptr), m_IntensityDataBuffer(nullptr), m_RGBDataBuffer(nullptr)
78 this->
m_Controller->GetAmplitudes(this->m_AmplitudeDataBuffer[this->m_FreePos]);
79 this->
m_Controller->GetIntensities(this->m_IntensityDataBuffer[this->m_FreePos]);
80 this->
m_Controller->GetRgb(this->m_RGBDataBuffer[this->m_FreePos]);
81 this->m_FreePos = (this->m_FreePos+1) % this->
m_BufferSize;
91 itksys::SystemTools::Delay(10);
107 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
108 if (pInfo ==
nullptr)
110 return ITK_THREAD_RETURN_VALUE;
112 if (pInfo->UserData ==
nullptr)
114 return ITK_THREAD_RETURN_VALUE;
117 if (toFCameraDevice!=
nullptr)
119 mitk::RealTimeClock::Pointer realTimeClock;
123 t1 = realTimeClock->GetCurrentStamp();
124 bool overflow =
false;
125 bool printStatus =
false;
131 toFCameraDevice->
m_Controller->GetDistances(toFCameraDevice->m_DistanceDataBuffer[toFCameraDevice->
m_FreePos]);
132 toFCameraDevice->
m_Controller->GetAmplitudes(toFCameraDevice->m_AmplitudeDataBuffer[toFCameraDevice->
m_FreePos]);
133 toFCameraDevice->
m_Controller->GetIntensities(toFCameraDevice->m_IntensityDataBuffer[toFCameraDevice->
m_FreePos]);
135 toFCameraDevice->Modified();
156 t2 = realTimeClock->GetCurrentStamp() - t1;
158 t1 = realTimeClock->GetCurrentStamp();
163 return ITK_THREAD_RETURN_VALUE;
172 amplitudeArray[i] = this->m_AmplitudeDataBuffer[this->
m_CurrentPos][i];
184 intensityArray[i] = this->m_IntensityDataBuffer[this->
m_CurrentPos][i];
196 distanceArray[i] = this->m_DistanceDataBuffer[this->
m_CurrentPos][i];
208 rgbArray[i] = this->m_RGBDataBuffer[this->
m_CurrentPos][i];
215 int requiredImageSequence,
int& capturedImageSequence,
unsigned char* rgbDataArray)
230 if ((requiredImageSequence < 0) || (requiredImageSequence > this->
m_ImageSequence))
242 capturedImageSequence = requiredImageSequence;
246 if(this->m_DistanceDataBuffer&&this->m_AmplitudeDataBuffer&&this->m_IntensityDataBuffer&&this->m_RGBDataBuffer)
249 memcpy(distanceArray, this->m_DistanceDataBuffer[pos], this->
m_PixelNumber *
sizeof(
float));
250 memcpy(amplitudeArray, this->m_AmplitudeDataBuffer[pos], this->
m_PixelNumber *
sizeof(
float));
251 memcpy(intensityArray, this->m_IntensityDataBuffer[pos], this->
m_PixelNumber *
sizeof(
float));
252 memcpy(rgbDataArray, this->m_RGBDataBuffer[pos], this->
m_RGBPixelNumber * 3 *
sizeof(
unsigned char));
269 std::string strValue;
271 if (strcmp(propertyKey,
"DistanceImageFileName") == 0)
273 myController->SetDistanceImageFileName(strValue);
275 else if (strcmp(propertyKey,
"AmplitudeImageFileName") == 0)
277 std::ifstream amplitudeImage(strValue.c_str());
281 myController->SetAmplitudeImageFileName(strValue);
285 MITK_WARN <<
"File " << strValue <<
" does not exist!";
288 else if (strcmp(propertyKey,
"IntensityImageFileName") == 0)
290 std::ifstream intensityImage(strValue.c_str());
294 myController->SetIntensityImageFileName(strValue);
298 MITK_WARN <<
"File " << strValue <<
" does not exist!";
301 else if (strcmp(propertyKey,
"RGBImageFileName") == 0)
303 std::ifstream intensityImage(strValue.c_str());
307 myController->SetRGBImageFileName(strValue);
311 MITK_WARN <<
"File " << strValue <<
" does not exist!";
318 if (m_DistanceDataBuffer)
322 delete[] this->m_DistanceDataBuffer[i];
324 delete[] this->m_DistanceDataBuffer;
326 if (m_AmplitudeDataBuffer)
330 delete[] this->m_AmplitudeDataBuffer[i];
332 delete[] this->m_AmplitudeDataBuffer;
334 if (m_IntensityDataBuffer)
338 delete[] this->m_IntensityDataBuffer[i];
340 delete[] this->m_IntensityDataBuffer;
346 delete[] this->m_RGBDataBuffer[i];
348 delete[] this->m_RGBDataBuffer;
360 this->m_DistanceDataBuffer[i] =
new float[this->
m_PixelNumber];
365 this->m_AmplitudeDataBuffer[i] =
new float[this->
m_PixelNumber];
370 this->m_IntensityDataBuffer[i] =
new float[this->
m_PixelNumber];
void GetAllImages(float *distanceArray, float *amplitudeArray, float *intensityArray, char *sourceDataArray, int requiredImageSequence, int &capturedImageSequence, unsigned char *rgbDataArray=nullptr) override
gets the 3 images (distance, amplitude, intensity) from the ToF camera. Caution! The user is responsi...
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()
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)
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)
~ToFCameraMITKPlayerDevice() override
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 ...
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.
bool OnConnectCamera() override
opens a connection to the ToF camera
int m_CaptureHeight
height of the range image (y dimension)
void SetProperty(const char *propertyKey, BaseProperty *propertyValue) override
set a BaseProperty
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...
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
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...
void StartCamera() override
starts the continuous updating of the camera. A separate thread updates the source data...