Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkToFCameraPMDO3Controller.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
13 #include <pmdsdk2.h>
14 #include "mitkToFConfig.h"
15 #include "mitkToFPMDConfig.h"
16 
17 #include "vnl/vnl_matrix.h"
18 
19 // IP Adress of the Camera, change here if needed
20 #define CAMERA_ADDR "192.168.0.69"
21 #define SOURCE_PARAM "192.168.0.69"
22 #define PROC_PARAM ""
23 
24 extern PMDHandle m_PMDHandle;
25 
26 extern PMDDataDescription m_DataDescription;
27 
28 namespace mitk
29 {
31  {
32  m_IPAddress = CAMERA_ADDR;
37  }
38 
40  {
41  }
42 
44  {
46  {
49 
50  // get image properties from camera
51  this->UpdateCamera();
52  m_PMDRes = pmdGetSourceDataDescription(m_PMDHandle, &m_DataDescription);
54  m_CaptureWidth = m_DataDescription.img.numColumns;
55  m_CaptureHeight = m_DataDescription.img.numRows;
59  m_NumberOfBytes = m_PixelNumber * sizeof(float);
61  m_SourceDataStructSize = m_DataDescription.size + sizeof(PMDDataDescription);
62  MITK_INFO << "Datasource size: " << m_SourceDataSize <<std::endl;
63  MITK_INFO << "Integration Time: " << this->GetIntegrationTime();
64  MITK_INFO << "Modulation Frequence: " << this->GetModulationFrequency();
65 
66  return m_ConnectionCheck;
67  }
68  else return m_ConnectionCheck;
69  }
70 
71  void ToFCameraPMDO3Controller::TransformCameraOutput(float* in, float* out, bool isDist)
72  {
73  vnl_matrix<float> inMat = vnl_matrix<float>(m_CaptureHeight,m_CaptureWidth);
74  inMat.copy_in(in);
75  vnl_matrix<float> outMat = vnl_matrix<float>(m_InternalCaptureHeight, m_InternalCaptureWidth);
76  vnl_matrix<float> temp = vnl_matrix<float>(m_InternalCaptureHeight, m_InternalCaptureWidth);
77  outMat = inMat.extract(m_InternalCaptureHeight, m_InternalCaptureWidth, 0,0);
78  outMat.fliplr();
79  if(isDist)
80  {
81  outMat*=1000;
82  }
83  outMat.copy_out(out);
84  inMat.clear();
85  outMat.clear();
86  temp.clear();
87  }
88 }
#define CAMERA_ADDR
unsigned int m_InternalCaptureHeight
holds the height of the image in pixel as is it requested by the user (cf. TransformCameraOutput()) D...
PMDDataDescription m_DataDescription
#define MITK_INFO
Definition: mitkLogMacros.h:18
virtual bool UpdateCamera()
calls update on the camera -> a new ToF-image is aquired
#define MITK_TOF_PMDO3_PROCESSING_PLUGIN
char * m_ProcParam
holds processing parameter(s)
int m_PixelNumber
holds the number of pixels contained in the image
DataCollection - Class to facilitate loading/accessing structured data.
virtual bool OpenCameraConnection()
opens a connection to the PMD O3 ToF camera
bool m_ConnectionCheck
flag showing whether the camera is connected (true) or not (false)
void TransformCameraOutput(float *in, float *out, bool isDist)
int m_NumberOfBytes
holds the number of bytes contained in the image
virtual int GetIntegrationTime()
Returns the currently set integration time.
unsigned int m_CaptureHeight
holds the height of the image in pixel as it is originally acquired by the camera ...
#define PROC_PARAM
virtual int GetModulationFrequency()
Returns the currently set modulation frequency.
bool ErrorText(int error)
Method printing the current error message to the console and returning whether the previous command w...
char * m_ProcPlugin
holds name of processing plugin to be loaded (e.g. camcubeproc.W64.pap for CamCube 3...
PMDHandle m_PMDHandle
unsigned int m_CaptureWidth
holds the width of the image in pixel as it is originally acquired by the camera
int m_PMDRes
holds the current result message provided by PMD
int m_SourceDataStructSize
size of the PMD source data struct and the PMD source data
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
unsigned int m_InternalCaptureWidth
holds the width of the image in pixel as it is requested by the user (cf. TransformCameraOutput()) De...
char * m_SourceParam
holds source parameter(s)
#define MITK_TOF_PMDO3_SOURCE_PLUGIN
#define SOURCE_PARAM
int m_SourceDataSize
size of the original PMD source data
char * m_SourcePlugin
holds name of source plugin to be loaded (e.g. camcube3.W64.pap for CamCube 3.0 on Win64 platform) ...