ViSP  2.8.0
vpKinect.h
1 /****************************************************************************
2  *
3  * $Id: vpKinect.h 4131 2013-02-11 20:45:31Z fspindle $
4  *
5  *
6  * This file is part of the ViSP software.
7  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
8  *
9  * This software is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.txt at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using ViSP with software that can not be combined with the GNU
16  * GPL, please contact INRIA about acquiring a ViSP Professional
17  * Edition License.
18  *
19  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
20  *
21  * This software was developed at:
22  * INRIA Rennes - Bretagne Atlantique
23  * Campus Universitaire de Beaulieu
24  * 35042 Rennes Cedex
25  * France
26  * http://www.irisa.fr/lagadic
27  *
28  * If you have questions regarding the use of this file, please contact
29  * INRIA at visp@inria.fr
30  *
31  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33  *
34  *
35  * Description:
36  * API for using a Microsoft Kinect device
37  * Requires libfreenect as a third party library
38  *
39  * Authors:
40  * Celine Teuliere
41  *
42  *****************************************************************************/
43 
44 
45 #ifndef __VP_KINECT__
46 #define __VP_KINECT__
47 
48 #include <visp/vpConfig.h>
49 // Note that libfreenect needs libusb-1.0 and libpthread
50 #if defined(VISP_HAVE_LIBFREENECT_AND_DEPENDENCIES)
51 
52 #include <iostream>
53 #include <libfreenect.hpp>
54 
55 #include <visp/vpMutex.h> // need pthread
56 #include <visp/vpImage.h>
57 #include <visp/vpHomogeneousMatrix.h>
58 #include <visp/vpCameraParameters.h>
59 #include <visp/vpPixelMeterConversion.h>
60 #include <visp/vpMeterPixelConversion.h>
61 
112 class VISP_EXPORT vpKinect : public Freenect::FreenectDevice
113 {
114  public:
118  typedef enum {
120  DMAP_MEDIUM_RES
121  } vpDMResolution;
122 
123  vpKinect(freenect_context *ctx, int index);
124  virtual ~vpKinect();
125 
126 #ifndef DOXYGEN_SHOULD_SKIP_THIS
127  vpKinect(const vpKinect &); // Not implemented!
128  void operator=(const vpKinect &){
129  throw vpException(vpException::functionNotImplementedError,"Not implemented!");
130  }
131 #endif
132 
133  void start(vpKinect::vpDMResolution res = DMAP_LOW_RES);
134  void stop();
135 
136  bool getDepthMap(vpImage<float>& map);
137  bool getDepthMap(vpImage<float>& map, vpImage<unsigned char>& Imap);
138  bool getRGB(vpImage<vpRGBa>& IRGB);
139 
140 
141  inline void getIRCamParameters(vpCameraParameters &cam) const {
142  cam = IRcam;
143  }
144  inline void getRGBCamParameters(vpCameraParameters &cam) const {
145  cam = RGBcam;
146  }
147  inline void setIRCamParameters(const vpCameraParameters &cam) {
148  IRcam = cam;
149  }
150  inline void setRGBCamParameters(const vpCameraParameters &cam) {
151  RGBcam = cam;
152  }
153 
154  void warpRGBFrame(const vpImage<vpRGBa> & Irgb, const vpImage<float> & Idepth, vpImage<vpRGBa> & IrgbWarped);//warp the RGB image into the Depth camera frame
155 
156  private:
158  // Do not call directly even in child
159  void VideoCallback(void* rgb, uint32_t timestamp);
160 
161  // Do not call directly even in child
162  void DepthCallback(void* depth, uint32_t timestamp);
163 
164  private:
165  vpMutex m_rgb_mutex;
166  vpMutex m_depth_mutex;
167 
168  vpCameraParameters RGBcam, IRcam;//intrinsic parameters of the two cameras
169  vpHomogeneousMatrix rgbMir;//Transformation from IRcam coordinate frame to RGBcam coordinate frame.
170  vpHomogeneousMatrix irMrgb;//Transformation from RGBcam coordinate frame to IRcam coordinate frame .
171  vpDMResolution DMres;
172  unsigned int hd;//height of the depth map
173  unsigned int wd;//width of the depth map
174 
175  //Access protected by a mutex:
176  vpImage<float> dmap;
177  vpImage<vpRGBa> IRGB;
178  bool m_new_rgb_frame;
179  bool m_new_depth_map;
180  bool m_new_depth_image;
181  unsigned int height;//height of the rgb image
182  unsigned int width;//width of the rgb image
183 
184 };
185 
186 #endif
187 
188 #endif
void getRGBCamParameters(vpCameraParameters &cam) const
Definition: vpKinect.h:144
vpDMResolution
Definition: vpKinect.h:118
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void setIRCamParameters(const vpCameraParameters &cam)
Definition: vpKinect.h:147
error that can be emited by ViSP classes.
Definition: vpException.h:75
Driver for the Kinect device.
Definition: vpKinect.h:112
Class that allows protection by mutex.
Definition: vpMutex.h:63
Generic class defining intrinsic camera parameters.
void getIRCamParameters(vpCameraParameters &cam) const
Definition: vpKinect.h:141
void setRGBCamParameters(const vpCameraParameters &cam)
Definition: vpKinect.h:150