MITK-ToF - Getting started

From mitk.org
Jump to navigation Jump to search

Configuration

Using MITK-ToF in a given MITK based application requires the following steps:

  1. Chose your preferred camera when configuring the project. E.g.:

MITK-ToF - Getting started$HardwareConfiguration.jpg

  1. 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

MITK-ToF - Getting started$SDKConfiguration.jpg

  1. 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.

MITK-ToF - Getting started$ToFUtilConfiguration.jpg

  1. "Configure" and "Generate" will finalize the MITK-ToF configuration for MITK.
  2. 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.


Implementation Basics

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).

  • tofImageGrabber->SetCameraDevice(mitk::ToFCameraMITKPlayerDevice::New());

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)

  • tofImageGrabber->ConnectCamera();
  • tofImageGrabber->StartCamera();

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);
  • tofImageGrabber->Update();

... Do some image processing ...

Stop camera (terminates acquisition thread) and disconnect

  • tofImageGrabber->StopCamera();
  • tofImageGrabber->DisconnectCamera();


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();