MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkToFCameraPMDCamCubeDeviceTest.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 mitkToFCameraPMDCamCubeDeviceTest(int /* argc */, char* /*argv*/[])
20{
21 MITK_TEST_BEGIN("ToFCameraPMDCamCubeDevice");
22
23 mitk::ToFCameraPMDCamCubeDevice::Pointer camCubeDevice = mitk::ToFCameraPMDCamCubeDevice::New();
24 // No hardware attached for automatic testing -> test correct error handling
25 try
26 {
27 MITK_TEST_CONDITION_REQUIRED(camCubeDevice.IsNotNull(), "Testing initialization");
28 MITK_TEST_CONDITION_REQUIRED(camCubeDevice->ConnectCamera(), "Test ConnectCamera()");
29 MITK_TEST_CONDITION_REQUIRED(!camCubeDevice->IsCameraActive(), "Test IsCameraActive() before StartCamera()");
30 MITK_TEST_OUTPUT(<<"Call StartCamera()");
31 camCubeDevice->StartCamera();
32 MITK_TEST_CONDITION_REQUIRED(camCubeDevice->IsCameraActive(), "Test IsCameraActive() after StartCamera()");
33 MITK_TEST_OUTPUT(<<"Call UpdateCamera()");
34 camCubeDevice->UpdateCamera();
35 int numberOfPixels = camCubeDevice->GetCaptureWidth()*camCubeDevice->GetCaptureHeight();
36 MITK_INFO<<numberOfPixels;
37 float* distances = new float[numberOfPixels];
38 float* amplitudes = new float[numberOfPixels];
39 float* intensities = new float[numberOfPixels];
40 char* sourceData = new char[numberOfPixels];
41 int requiredImageSequence = 0;
42 int imageSequence = 0;
43 camCubeDevice->GetDistances(distances,imageSequence);
44 camCubeDevice->GetAmplitudes(amplitudes,imageSequence);
45 camCubeDevice->GetIntensities(intensities,imageSequence);
46 camCubeDevice->GetAllImages(distances,amplitudes,intensities,sourceData,requiredImageSequence,imageSequence);
47 MITK_TEST_CONDITION_REQUIRED(camCubeDevice->IsCameraActive(), "Test IsCameraActive() before StopCamera()");
48 MITK_TEST_OUTPUT(<<"Call StopCamera()");
49 camCubeDevice->StopCamera();
50 MITK_TEST_CONDITION_REQUIRED(!camCubeDevice->IsCameraActive(), "Test IsCameraActive() after StopCamera()");
51
52 MITK_TEST_CONDITION_REQUIRED(camCubeDevice->DisconnectCamera(), "Test DisonnectCamera()");
53 delete[] distances;
54 delete[] amplitudes;
55 delete[] intensities;
56 delete[] sourceData;
57 }
58 catch(std::exception &e)
59 {
60 MITK_INFO << e.what();
61 MITK_TEST_CONDITION_REQUIRED(camCubeDevice->IsCameraActive()==false, "Testing that no connection could be established.");
62 }
63
64 MITK_TEST_END();
65}
int mitkToFCameraPMDCamCubeDeviceTest(int, char *[])