MITK-ToF - Getting started
Using MITK-ToF in a given MITK based application requires the following steps:
- Chose your preferred camera when configuring the project. E.g.:
- Activating the desired hardware and configuring again will require to set the vendors SDK directory. Here, this will be PMDSDK2. The following CMake variables must be specified for your device. Here we use:
- MITK_PMD_INCLUDE_DIR: path to the include directory of the PMDSDK2 which must contain pmdsdk2.h
- MITK_PMD_LIB: file path to the PMD library pmdaccess2.lib
- To add the sample plugin (!ToFUtil) to the MITK main application MitkWorkbench, the CMake variable MITK_BUILD_org.mitk.gui.qt.tofutil has to be activated additionally.
- "Configure" and "Generate" will finalize the MITK-ToF configuration for MITK.
- Before starting the application, the file path to the vendor specific library (in the current case the pmdaccess.dll (Windows) or pmdaccess.so (Linux)) has to be added to the system's path variable (Windows: PATH, Linux: LD_LIBRARY_PATH). This should be done automatically by our build system. But you can double-check this in case of error.
Before starting to write MITK-ToF based applications, the dependencies to the required ToF module has to be set. These are:
- mitkToFHardware for module ToFHardware
- mitkToFProcessing for module ToFProcessing
- mitkTOFUI for module ToFUI
A basic tutorial on how to use the existing MITK-ToF classes is included in the source code. Activate MITK_BUILD_org.mitk.gui.qt.toftutorial in the CMakeConfiguration to build it. Currently two tutorial steps are available. The basic ideas are explained below, the source code provides a more detailed description.
Step 1 - Acquiring image data
First, we need a ToFImageGrabber:
- mitk::ToFImageGrabber::Pointer tofImageGrabber = mitk::ToFImageGrabberNew();
Assign the used device to this grabber (in this case the MITK Player).
This ToFImageGrabber is the source of an image-based filter pipeline and is now used to grab the images from the associated Device (in our example a player device)
Establish connection to the camera and start camera (i.e. start thread in device)
Update filter pipeline and get output images
- mitk::Image::Pointer distanceImage = tofImageGrabber->GetOutput(0);
- mitk::Image::Pointer amplitudeImage = tofImageGrabber->GetOutput(1);
- mitk::Image::Pointer intensityImage = tofImageGrabber->GetOutput(2);
... Do some image processing ...
Stop camera (terminates acquisition thread) and disconnect
Step 2 - Generating a surface from the range data
The acquired distance image is now used to calculate a surface representation.
Create CameraIntrinsics which represents the intrinsic camera parameters
- mitk::CameraIntrinsics::Pointer cameraIntrinsics = mitk::CameraIntrinsics::New();
Create an instance of the distance image to surface filter used for processing the distance image and apply the camera intrinsics
- mitk::ToFDistanceImageToSurfaceFilter::Pointer surfaceFilter = mitk::ToFDistanceImageToSurfaceFilter::New(); surfaceFilter->SetCameraModel(cameraIntrinsics);
Set the distance image as input of the surface filter and update the pipeline
- surfaceFilter->SetInput(distanceImage); surfaceFilter->Update();
Get the surface as output of this filter
- mitk::Surface::Pointer surface = surfaceFilter->GetOutput();