14#include <XnCppWrapper.h>
42 m_DepthGenerator(nullptr),
43 m_ImageGenerator(nullptr),
44 m_IRGenerator(nullptr),
45 m_ConnectionCheck(false),
58 if(error != XN_STATUS_OK)
60 MITK_ERROR <<
"Kinect Camera Error " << xnGetStatusString(error);
61 mitkThrow() <<
"Kinect Camera Error " << xnGetStatusString(error);
84 XnMapOutputMode DepthMode;
88 DepthMode.nXRes = xn::Resolution((XnResolution)XN_RES_VGA).GetXResolution();
89 DepthMode.nYRes = xn::Resolution((XnResolution)XN_RES_VGA).GetYResolution();
98 XnMapOutputMode IRMode;
100 IRMode.nXRes = XN_VGA_X_RES;
101 IRMode.nYRes = XN_VGA_Y_RES;
109 XnMapOutputMode ImageMode;
113 ImageMode.nXRes = xn::Resolution((XnResolution)XN_RES_VGA).GetXResolution();
114 ImageMode.nYRes = xn::Resolution((XnResolution)XN_RES_VGA).GetYResolution();
120 if( d->
m_DepthGenerator.IsCapabilitySupported(XN_CAPABILITY_ALTERNATIVE_VIEW_POINT) )
129 MITK_ERROR <<
"Alternative view point not supported by the depth generator...";
133 if( d->
m_IRGenerator.IsCapabilitySupported(XN_CAPABILITY_ALTERNATIVE_VIEW_POINT) )
139 MITK_ERROR <<
"Alternative view point not supported by the depth generator...";
159 xn::DepthMetaData DepthMD;
163 return updateSuccessful;
168 xn::DepthMetaData DepthMD;
170 const XnDepthPixel* DepthData = DepthMD.Data();
174 distances[i] =
static_cast<float>(DepthData[i]);
182 xn::ImageMetaData ImageMD;
184 const XnRGB24Pixel* rgbPixelArray = ImageMD.RGB24Data();
187 rgb[i*3] = rgbPixelArray[i].nRed;
188 rgb[i*3+1] = rgbPixelArray[i].nGreen;
189 rgb[i*3+2] = rgbPixelArray[i].nBlue;
197 xn::DepthMetaData DepthMD;
199 const XnDepthPixel* DepthData = DepthMD.Data();
201 xn::IRMetaData IRData;
202 const XnIRPixel* IRPixelData =
nullptr;
204 xn::ImageMetaData ImageMD;
205 const XnRGB24Pixel* rgbPixelArray =
nullptr;
209 IRPixelData = IRData.Data();
215 rgbPixelArray = ImageMD.RGB24Data();
220 distances[i] =
static_cast<float>(DepthData[i]);
223 amplitudes[i] =
static_cast<float>(IRPixelData[i]);
227 rgb[i*3] = rgbPixelArray[i].nRed;
228 rgb[i*3+1] = rgbPixelArray[i].nGreen;
229 rgb[i*3+2] = rgbPixelArray[i].nBlue;
238 xn::IRMetaData IRData;
240 const XnIRPixel* IRPixelData = IRData.Data();
244 amplitudes[i] =
static_cast<float>(IRPixelData[i]);
xn::IRGenerator m_IRGenerator
IR generator to access IR image of kinect.
KinectControllerPrivate()
unsigned int m_CaptureHeight
image height
xn::ImageGenerator m_ImageGenerator
Image generator to access RGB image of kinect.
xn::DepthGenerator m_DepthGenerator
Depth generator to access depth image of kinect.
bool ErrorText(unsigned int error)
bool m_ConnectionCheck
check if camera is connected or not
unsigned int m_CaptureWidth
image width
bool m_UseIR
flag indicating whether IR image is used or not
~KinectControllerPrivate()
xn::Context m_Context
OpenNI context.
void GetAmplitudes(float *amplitudes)
unsigned int GetCaptureWidth() const
virtual bool CloseCameraConnection()
closes the connection to the camera
void GetIntensities(float *intensities)
virtual bool UpdateCamera()
updates the camera. The update function of the hardware interface is called only when new data is ava...
void SetUseIR(bool useIR)
void GetAllData(float *distances, float *amplitudes, unsigned char *rgb)
convenience method for faster access to distance and rgb data
void GetRgb(unsigned char *rgb)
acquire new rgb data from the Kinect camera
void GetDistances(float *distances)
acquire new distance data from the Kinect camera
unsigned int GetCaptureHeight() const
virtual bool OpenCameraConnection()
opens a connection to the Kinect camera.