Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
17 #include <pmdsdk2.h>
18 #include "mitkToFConfig.h"
19 #include "mitkToFPMDConfig.h"
20 
21 #include "vnl/vnl_matrix.h"
22 
23 // IP Adress of the Camera, change here if needed
24 #define CAMERA_ADDR "192.168.0.69"
25 #define SOURCE_PARAM "192.168.0.69"
26 #define PROC_PARAM ""
27 
28 extern PMDHandle m_PMDHandle;
29 
30 extern PMDDataDescription m_DataDescription;
31 
32 namespace mitk
33 {
35  {
36  m_IPAddress = CAMERA_ADDR;
41  }
42 
44  {
45  }
46 
48  {
50  {
53 
54  // get image properties from camera
55  this->UpdateCamera();
56  m_PMDRes = pmdGetSourceDataDescription(m_PMDHandle, &m_DataDescription);
58  m_CaptureWidth = m_DataDescription.img.numColumns;
59  m_CaptureHeight = m_DataDescription.img.numRows;
63  m_NumberOfBytes = m_PixelNumber * sizeof(float);
65  m_SourceDataStructSize = m_DataDescription.size + sizeof(PMDDataDescription);
66  MITK_INFO << "Datasource size: " << m_SourceDataSize <<std::endl;
67  MITK_INFO << "Integration Time: " << this->GetIntegrationTime();
68  MITK_INFO << "Modulation Frequence: " << this->GetModulationFrequency();
69 
70  return m_ConnectionCheck;
71  }
72  else return m_ConnectionCheck;
73  }
74 
75  void ToFCameraPMDO3Controller::TransformCameraOutput(float* in, float* out, bool isDist)
76  {
77  vnl_matrix<float> inMat = vnl_matrix<float>(m_CaptureHeight,m_CaptureWidth);
78  inMat.copy_in(in);
79  vnl_matrix<float> outMat = vnl_matrix<float>(m_InternalCaptureHeight, m_InternalCaptureWidth);
80  vnl_matrix<float> temp = vnl_matrix<float>(m_InternalCaptureHeight, m_InternalCaptureWidth);
81  outMat = inMat.extract(m_InternalCaptureHeight, m_InternalCaptureWidth, 0,0);
82  outMat.fliplr();
83  if(isDist)
84  {
85  outMat*=1000;
86  }
87  outMat.copy_out(out);
88  inMat.clear();
89  outMat.clear();
90  temp.clear();
91  }
92 }
#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:22
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) ...