13#include <itkCommand.h>
14#include <usModuleContext.h>
15#include <usGetModuleContext.h>
20 m_ToFCameraDevice(nullptr),
29 m_IntensityArray(nullptr),
30 m_DistanceArray(nullptr),
31 m_AmplitudeArray(nullptr),
32 m_SourceDataArray(nullptr),
33 m_RgbDataArray(nullptr),
38 OutputImageType::Pointer output0 =
static_cast<OutputImageType*
>(this->MakeOutput(0).GetPointer());
39 OutputImageType::Pointer output1 =
static_cast<OutputImageType*
>(this->MakeOutput(1).GetPointer());
40 OutputImageType::Pointer output2 =
static_cast<OutputImageType*
>(this->MakeOutput(2).GetPointer());
41 OutputImageType::Pointer output3 =
static_cast<OutputImageType*
>(this->MakeOutput(3).GetPointer());
42 mitk::ImageSource::SetNumberOfRequiredOutputs(3);
43 mitk::ImageSource::SetNthOutput(0, output0.GetPointer());
44 mitk::ImageSource::SetNthOutput(1, output1.GetPointer());
45 mitk::ImageSource::SetNthOutput(2, output2.GetPointer());
46 mitk::ImageSource::SetNthOutput(3, output3.GetPointer());
64 int requiredImageSequence = 0;
69 mitk::Image::Pointer distanceImage = this->GetOutput(0);
75 bool hasAmplitudeImage =
false;
79 mitk::Image::Pointer amplitudeImage = this->GetOutput(1);
83 bool hasIntensityImage =
false;
87 mitk::Image::Pointer intensityImage = this->GetOutput(2);
91 bool hasRGBImage =
false;
95 mitk::Image::Pointer rgbImage = this->GetOutput(3);
131 us::ModuleContext* context = us::GetModuleContext();
132 us::ServiceProperties deviceProps;
133 deviceProps[
"ToFImageSourceName"] = std::string(
"Image Grabber");
156 itk::SimpleMemberCommand<ToFImageGrabber>::Pointer modifiedCommand = itk::SimpleMemberCommand<ToFImageGrabber>::New();
202 return modulationFrequency;
207 this->
m_ToFCameraDevice->SetProperty(
"IntegrationTime",mitk::IntProperty::New(integrationTime));
210 return integrationTime;
215 int integrationTime = 0;
217 return integrationTime;
222 int modulationFrequency = 0;
223 this->
m_ToFCameraDevice->GetIntProperty(
"ModulationFrequency",modulationFrequency);
224 return modulationFrequency;
229 SetProperty(propertyKey, mitk::BoolProperty::New(boolValue));
234 SetProperty(propertyKey, mitk::IntProperty::New(intValue));
239 SetProperty(propertyKey, mitk::FloatProperty::New(floatValue));
244 SetProperty(propertyKey, mitk::StringProperty::New(stringValue));
254 mitk::BoolProperty::Pointer boolProp =
dynamic_cast<mitk::BoolProperty*
>(
GetProperty(propertyKey));
255 if(!boolProp)
return false;
256 return boolProp->GetValue();
261 mitk::IntProperty::Pointer intProp =
dynamic_cast<mitk::IntProperty*
>(
GetProperty(propertyKey));
262 return intProp->GetValue();
267 mitk::FloatProperty::Pointer floatProp =
dynamic_cast<mitk::FloatProperty*
>(
GetProperty(propertyKey));
268 return floatProp->GetValue();
273 mitk::StringProperty::Pointer stringProp =
dynamic_cast<mitk::StringProperty*
>(
GetProperty(propertyKey));
274 return stringProp->GetValue();
331 unsigned int dimensions[3];
335 mitk::PixelType FloatType = MakeScalarPixelType<float>();
336 mitk::Image::Pointer distanceImage = this->GetOutput();
337 distanceImage->ReleaseData();
338 distanceImage->Initialize(FloatType, 3, dimensions, 1);
340 bool hasAmplitudeImage =
false;
342 if(hasAmplitudeImage)
344 mitk::Image::Pointer amplitudeImage = this->GetOutput(1);
345 amplitudeImage->ReleaseData();
346 amplitudeImage->Initialize(FloatType, 3, dimensions, 1);
349 bool hasIntensityImage =
false;
351 if(hasIntensityImage)
353 mitk::Image::Pointer intensityImage = this->GetOutput(2);
354 intensityImage->ReleaseData();
355 intensityImage->Initialize(FloatType, 3, dimensions, 1);
358 bool hasRGBImage =
false;
362 unsigned int rgbDimension[3];
365 rgbDimension[2] = 1 ;
366 mitk::Image::Pointer rgbImage = this->GetOutput(3);
367 rgbImage->ReleaseData();
368 rgbImage->Initialize(mitk::PixelType(MakePixelType<
unsigned char, itk::RGBPixel<unsigned char>, 3>()), 3, rgbDimension,1);
Virtual interface and base class for all Time-of-Flight devices.
virtual void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
set a BaseProperty property in the property list
int GetCaptureWidth()
Get the dimension in x direction of the ToF image.
float * m_AmplitudeArray
member holding the current amplitude array
void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
unsigned char * m_RgbDataArray
member holding the current rgb data array
void OnToFCameraDeviceModified()
virtual bool IsCameraConnected()
Returns true if the camera is connected.
int m_ImageSequence
counter for currently acquired images
int m_RGBPixelNumber
Number of pixels in the RGB image.
virtual bool DisconnectCamera()
Disconnects the ToF camera.
int GetIntProperty(const char *propertyKey)
virtual void StopCamera()
Stops the continuous updating of the camera.
void InitializeImages()
InitializeImages Initialze the geometries of the images according to the device properties.
int GetRGBImageWidth()
Get the dimension in x direction of the ToF image.
int m_SourceDataSize
size of the source data in bytes
int SetModulationFrequency(int modulationFrequency)
Set the modulation frequency used by the ToF camera. For default values see the corresponding device ...
unsigned long m_DeviceObserverTag
tag of the observer for the ToFCameraDevice
~ToFImageGrabber() override
int GetCaptureHeight()
Get the dimension in y direction of the ToF image.
int GetIntegrationTime()
Get the integration time in used by the ToF camera.
void SetFloatProperty(const char *propertyKey, float floatValue)
virtual bool ConnectCamera()
Establish a connection to the ToF camera.
int GetRGBPixelNumber()
Get the number of pixel in the ToF image.
virtual void AllocateImageArrays()
Allocate memory for the image arrays m_IntensityArray, m_DistanceArray, m_AmplitudeArray and m_Source...
int GetModulationFrequency()
Get the modulation frequency used by the ToF camera.
float GetFloatProperty(const char *propertyKey)
float * m_DistanceArray
member holding the current distance array
void GenerateData() override
Method generating the outputs of this filter. Called in the updated process of the pipeline....
void SetIntProperty(const char *propertyKey, int intValue)
void SetBoolProperty(const char *propertyKey, bool boolValue)
float * m_IntensityArray
member holding the current intensity array
int m_CaptureHeight
Height of the captured ToF image.
int m_CaptureWidth
Width of the captured ToF image.
int SetIntegrationTime(int integrationTime)
Set the integration time used by the ToF camera. For default values see the corresponding device clas...
virtual void StartCamera()
Starts the continuous updating of the camera. A separate thread updates the source data,...
int m_RGBImageHeight
Height of the captured RGB image.
ToFCameraDevice::Pointer m_ToFCameraDevice
Device allowing access to ToF image data.
virtual void CleanUpImageArrays()
clean up memory allocated for the image arrays m_IntensityArray, m_DistanceArray, m_AmplitudeArray an...
bool GetBoolProperty(const char *propertyKey)
ToFCameraDevice * GetCameraDevice()
Get the currently set ToF camera device.
int m_RGBImageWidth
Width of the captured RGB image.
const char * GetStringProperty(const char *propertyKey)
BaseProperty * GetProperty(const char *propertyKey)
void SetCameraDevice(ToFCameraDevice *aToFCameraDevice)
Sets the ToF device, the image grabber is grabbing the images from.
char * m_SourceDataArray
member holding the current source data array
void SetStringProperty(const char *propertyKey, const char *stringValue)
virtual bool IsCameraActive()
Returns true if the camera is connected and started.
int GetRGBImageHeight()
Get the dimension in y direction of the ToF image.
int GetPixelNumber()
Get the number of pixel in the ToF image.
int m_PixelNumber
Number of pixels in the image.
Image source providing ToF images. Interface for filters provided in ToFProcessing module.
us::ServiceRegistration< Self > m_ServiceRegistration