Fawkes API  Fawkes Development Version
kinect.h
1 
2 /***************************************************************************
3  * kinect.h - Microsoft Kinect 3D Camera using the freenect driver
4  *
5  * Created: Fri Nov 26 10:46:09 2010
6  * Copyright 2010 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_CAMS_KINECT_H_
25 #define __FIREVISION_CAMS_KINECT_H_
26 
27 #include "camera.h"
28 
29 #include <libfreenect.hpp>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 class CameraArgumentParser;
37 
38 class FvFreenectDevice : public Freenect::FreenectDevice
39 {
40  public:
41  FvFreenectDevice( freenect_context* ctx, int index );
43 
44  void RGBCallback( freenect_pixel* rgb, uint32_t timestamp );
45  void DepthCallback( void* depth, uint32_t timestamp );
46 
47  unsigned char* rgb_buffer();
48  uint16_t* depth_buffer();
49 
50  private:
51  unsigned char* m_rgb_buffer;
52  uint16_t* m_depth_buffer;
53 
54  uint32_t m_rgb_timestamp;
55  uint32_t m_depth_timestamp;
56 };
57 
58 class KinectCamera : public Camera
59 {
60  public:
61  KinectCamera( const CameraArgumentParser* cap = NULL );
62  ~KinectCamera();
63 
64  virtual void open();
65  virtual void start();
66  virtual void stop();
67  virtual void close();
68  virtual void capture();
69  virtual void flush();
70 
71  virtual bool ready();
72 
73  virtual void print_info();
74 
75  virtual unsigned char* buffer();
76  virtual unsigned int buffer_size();
77  virtual void dispose_buffer();
78 
79  virtual unsigned int pixel_width();
80  virtual unsigned int pixel_height();
81  virtual colorspace_t colorspace();
82 
83  virtual void set_image_number( unsigned int n );
84 
85  public:
86  static const unsigned int RGB_IMAGE;
87  static const unsigned int FALSE_COLOR_DEPTH_IMAGE;
88 
89  private:
90  Freenect::Freenect< FvFreenectDevice >* m_freenect_ctx;
91  FvFreenectDevice* m_freenect_dev;
92 
93  bool m_opened;
94  bool m_started;
95 
96  unsigned int m_image_num;
97 
98  unsigned char* m_buffer;
99  unsigned char* m_false_color_depth_buffer;
100 
101  uint16_t m_gamma[2048];
102 };
103 
104 } // end namespace firevision
105 
106 #endif /* __FIREVISION_CAMS_KINECT_H_ */
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:35
Access the Microsoft Kinect camera using the freenect driver.
Definition: kinect.h:58
unsigned char * rgb_buffer()
Access the RGB buffer.
Definition: kinect.cpp:101
static const unsigned int FALSE_COLOR_DEPTH_IMAGE
False color depth image.
Definition: kinect.h:87
Camera argument parser.
Definition: camargp.h:38
Implementation of the FreenectDevice interface of the driver.
Definition: kinect.h:38
void DepthCallback(void *depth, uint32_t timestamp)
Callback function for the freenect driver.
Definition: kinect.cpp:91
uint16_t * depth_buffer()
Access the depth buffer.
Definition: kinect.cpp:110
void RGBCallback(freenect_pixel *rgb, uint32_t timestamp)
Callback function for the freenect driver.
Definition: kinect.cpp:78
static const unsigned int RGB_IMAGE
Color image.
Definition: kinect.h:86
FvFreenectDevice(freenect_context *ctx, int index)
Constructor.
Definition: kinect.cpp:57
~FvFreenectDevice()
Destructor.
Definition: kinect.cpp:65