void StartRecording_ValidDepthImage_WritesImageToFile()
  {
    m_ToFImageRecorder->SetDistanceImageFileName(m_DistanceImageName);
    m_ToFImageRecorder->StartRecording();
    m_ToFImageRecorder->WaitForThreadBeingTerminated();
    m_ToFImageRecorder->StopRecording();

    mitk::Image::Pointer recordedImage = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(m_DistanceImageName)[0].GetPointer());
    MITK_ASSERT_EQUAL( m_GroundTruthDepthImage, recordedImage, "Recorded image should be equal to the test data.");

    //delete the tmp image
    if( remove( m_DistanceImageName.c_str() ) != 0 )
    {
      MITK_ERROR<<"File: "<< m_DistanceImageName << " not successfully deleted!";
    }
  }
  /**
    * @brief Setup a recorder including a device. Here, we use a player, because in an automatic test
    * hardware is not useful.
    */
  void setUp() override
  {
    m_ToFImageRecorder = mitk::ToFImageRecorder::New();
    m_DistanceImageName = mitk::IOUtil::CreateTemporaryFile();
    m_AmplitudeImageName = mitk::IOUtil::CreateTemporaryFile();
    m_IntensityImageName = mitk::IOUtil::CreateTemporaryFile();

    //The recorder would automatically append the default extension ".nrrd"
    //but we have to append it here, because the data is later loaded with
    //IOUtil which does not know what kind of data to load/look for.
    m_DistanceImageName.append("Distance.nrrd");
    m_AmplitudeImageName.append("Amplitude.nrrd");
    m_IntensityImageName.append("Intensity.nrrd");

    m_PlayerDevice = mitk::ToFCameraMITKPlayerDevice::New();
    m_ToFImageRecorder->SetCameraDevice(m_PlayerDevice);

    //the test data set has 20 frames, so we record 20 per default
    m_ToFImageRecorder->SetNumOfFrames(20);
    m_ToFImageRecorder->SetRecordMode(mitk::ToFImageRecorder::PerFrames);

    std::string dirName = MITK_TOF_DATA_DIR;
    std::string distanceFileName = dirName + "/PMDCamCube2_MF0_IT0_20Images_DistanceImage.pic";
    std::string amplitudeFileName = dirName + "/PMDCamCube2_MF0_IT0_20Images_AmplitudeImage.pic";
    std::string intensityFileName = dirName + "/PMDCamCube2_MF0_IT0_20Images_IntensityImage.pic";

    m_PlayerDevice->SetProperty("DistanceImageFileName",mitk::StringProperty::New(distanceFileName));
    m_PlayerDevice->SetProperty("AmplitudeImageFileName",mitk::StringProperty::New(amplitudeFileName));
    m_PlayerDevice->SetProperty("IntensityImageFileName",mitk::StringProperty::New(intensityFileName));

    //comparing against IOUtil seems fair enough
    m_GroundTruthDepthImage = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(distanceFileName)[0].GetPointer());
    m_GroundTruthAmplitudeImage = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(amplitudeFileName)[0].GetPointer());
    m_GroundTruthIntensityImage = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(intensityFileName)[0].GetPointer());

    m_PlayerDevice->ConnectCamera();
    m_PlayerDevice->StartCamera();
  }
예제 #3
0
  void StartRecording_ValidIntensityImage_WritesImageToFile()
  {
    m_ToFImageRecorder->SetIntensityImageFileName(m_IntensityImageName);
    m_ToFImageRecorder->SetIntensityImageSelected(true);
    m_ToFImageRecorder->SetDistanceImageSelected(false);
    m_ToFImageRecorder->StartRecording();
    m_ToFImageRecorder->WaitForThreadBeingTerminated();
    m_ToFImageRecorder->StopRecording();

    mitk::Image::Pointer recordedImage = mitk::IOUtil::LoadImage(m_IntensityImageName);
    MITK_ASSERT_EQUAL( m_GroundTruthIntensityImage, recordedImage, "Recorded image should be equal to the test data.");

    //delete the tmp image
    if( remove( m_IntensityImageName.c_str() ) != 0 )
    {
      MITK_ERROR<<"File: "<< m_IntensityImageName << " not successfully deleted!";
    }
  }