MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkToFCameraPMDDeviceTest.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13#include <mitkTestingMacros.h>
15
19int mitkToFCameraPMDDeviceTest(int /* argc */, char* /*argv*/[])
20{
21 MITK_TEST_BEGIN("ToFCameraPMDDevice");
22
23 mitk::ToFCameraPMDDevice::Pointer PMDDevice = mitk::ToFCameraPMDDevice::New();
24 try
25 {
26 // No hardware attached for automatic testing -> test correct error handling
27 MITK_TEST_CONDITION_REQUIRED(!PMDDevice->ConnectCamera(), "Test ConnectCamera()");
28 MITK_TEST_CONDITION_REQUIRED(!PMDDevice->IsCameraActive(), "Test IsCameraActive()");
29 MITK_TEST_OUTPUT(<<"Call StartCamera()");
30 PMDDevice->StartCamera();
31 MITK_TEST_OUTPUT(<<"Call UpdateCamera()");
32 PMDDevice->UpdateCamera();
33 int numberOfPixels = PMDDevice->GetCaptureWidth()*PMDDevice->GetCaptureHeight();
34 MITK_INFO<<numberOfPixels;
35 float* distances = new float[numberOfPixels];
36 float* amplitudes = new float[numberOfPixels];
37 float* intensities = new float[numberOfPixels];
38 char* sourceData = new char[numberOfPixels];
39 int requiredImageSequence = 0;
40 int imageSequence = 0;
41 PMDDevice->GetDistances(distances,imageSequence);
42 PMDDevice->GetAmplitudes(amplitudes,imageSequence);
43 PMDDevice->GetIntensities(intensities,imageSequence);
44 PMDDevice->GetAllImages(distances,amplitudes,intensities,sourceData,requiredImageSequence,imageSequence);
45 MITK_TEST_OUTPUT(<<"Call StopCamera()");
46 PMDDevice->StopCamera();
47
48 MITK_TEST_CONDITION_REQUIRED(!PMDDevice->DisconnectCamera(), "Test DisonnectCamera()");
49 delete[] distances;
50 delete[] amplitudes;
51 delete[] intensities;
52 delete[] sourceData;
53 }
54 catch(std::exception &e)
55 {
56 MITK_INFO << e.what();
57 MITK_TEST_CONDITION_REQUIRED(PMDDevice->IsCameraActive()==false, "Testing that no device could be connected.");
58 }
59
60 MITK_TEST_END();
61
62}
int mitkToFCameraPMDDeviceTest(int, char *[])