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 
33 class CameraArgumentParser;
34 
35 class FvFreenectDevice : public Freenect::FreenectDevice
36 {
37 public:
38  FvFreenectDevice(freenect_context *ctx, int index);
40 
41  void RGBCallback(freenect_pixel *rgb, uint32_t timestamp);
42  void DepthCallback(void *depth, uint32_t timestamp);
43 
44  unsigned char *rgb_buffer();
45  uint16_t * depth_buffer();
46 
47 private:
48  unsigned char *m_rgb_buffer;
49  uint16_t * m_depth_buffer;
50 
51  uint32_t m_rgb_timestamp;
52  uint32_t m_depth_timestamp;
53 };
54 
55 class KinectCamera : public Camera
56 {
57 public:
58  KinectCamera(const CameraArgumentParser *cap = NULL);
59  ~KinectCamera();
60 
61  virtual void open();
62  virtual void start();
63  virtual void stop();
64  virtual void close();
65  virtual void capture();
66  virtual void flush();
67 
68  virtual bool ready();
69 
70  virtual void print_info();
71 
72  virtual unsigned char *buffer();
73  virtual unsigned int buffer_size();
74  virtual void dispose_buffer();
75 
76  virtual unsigned int pixel_width();
77  virtual unsigned int pixel_height();
78  virtual colorspace_t colorspace();
79 
80  virtual void set_image_number(unsigned int n);
81 
82 public:
83  static const unsigned int RGB_IMAGE;
84  static const unsigned int FALSE_COLOR_DEPTH_IMAGE;
85 
86 private:
87  Freenect::Freenect<FvFreenectDevice> *m_freenect_ctx;
88  FvFreenectDevice * m_freenect_dev;
89 
90  bool m_opened;
91  bool m_started;
92 
93  unsigned int m_image_num;
94 
95  unsigned char *m_buffer;
96  unsigned char *m_false_color_depth_buffer;
97 
98  uint16_t m_gamma[2048];
99 };
100 
101 } // end namespace firevision
102 
103 #endif /* FIREVISION_CAMS_KINECT_H__ */
Camera argument parser.
Definition: camargp.h:36
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:33
Implementation of the FreenectDevice interface of the driver.
Definition: kinect.h:36
FvFreenectDevice(freenect_context *ctx, int index)
Constructor.
Definition: kinect.cpp:53
~FvFreenectDevice()
Destructor.
Definition: kinect.cpp:60
void RGBCallback(freenect_pixel *rgb, uint32_t timestamp)
Callback function for the freenect driver.
Definition: kinect.cpp:73
unsigned char * rgb_buffer()
Access the RGB buffer.
Definition: kinect.cpp:96
uint16_t * depth_buffer()
Access the depth buffer.
Definition: kinect.cpp:105
void DepthCallback(void *depth, uint32_t timestamp)
Callback function for the freenect driver.
Definition: kinect.cpp:86
Access the Microsoft Kinect camera using the freenect driver.
Definition: kinect.h:56
virtual unsigned int pixel_height()
Height of image in pixels.
Definition: kinect.cpp:285
KinectCamera(const CameraArgumentParser *cap=NULL)
Constructor.
Definition: kinect.cpp:113
static const unsigned int FALSE_COLOR_DEPTH_IMAGE
False color depth image.
Definition: kinect.h:84
virtual void set_image_number(unsigned int n)
Set image number to retrieve.
Definition: kinect.cpp:297
virtual void print_info()
Print out camera information.
Definition: kinect.cpp:257
virtual void start()
Start image transfer from the camera.
Definition: kinect.cpp:152
static const unsigned int RGB_IMAGE
Color image.
Definition: kinect.h:83
virtual void capture()
Capture an image.
Definition: kinect.cpp:187
virtual colorspace_t colorspace()
Colorspace of returned image.
Definition: kinect.cpp:291
~KinectCamera()
Destructor.
Definition: kinect.cpp:132
virtual void close()
Close camera.
Definition: kinect.cpp:180
virtual unsigned int pixel_width()
Width of image in pixels.
Definition: kinect.cpp:279
virtual bool ready()
Camera is ready for taking pictures.
Definition: kinect.cpp:251
virtual unsigned int buffer_size()
Size of buffer.
Definition: kinect.cpp:268
virtual void open()
Open the camera.
Definition: kinect.cpp:138
virtual void flush()
Flush image queue.
Definition: kinect.cpp:246
virtual void stop()
Stop image transfer from the camera.
Definition: kinect.cpp:166
virtual unsigned char * buffer()
Get access to current image buffer.
Definition: kinect.cpp:262
virtual void dispose_buffer()
Dispose current buffer.
Definition: kinect.cpp:274