this class wraps the libfreenect library as a QObject this allows us to use singals and slots to communicate with the class from other Qt GUI elements. This class uses the Singleton pattern so must be accessed via the instance method
More...
#include <QKinect.h>
List of all members.
Public Slots |
freenect_context * | getContext () |
| return a pointer to the active device context
|
bool | getDepth (std::vector< uint8_t > &o_buffer) |
| getDepth buffer and convert it to an RGB colour representation this code is based on the sample implementation glview.c / cppview.cpp
|
bool | getDepth16Bit (std::vector< uint16_t > &o_buffer) |
| getDepth buffer as the raw 16 Bit values this is useful for generating point cloud renders as we have the full depth range
|
bool | getDepthRaw (std::vector< uint8_t > &o_buffer) |
| getDepth buffer as the raw values converted to uint8_t not sure if this will be much use but have used it in some tracking examples
|
bool | getRGB (std::vector< uint8_t > &o_buffer) |
| get the RGB buffer
|
void | resetAngle () |
| reset the tilt angle
|
void | setAngle (double _angle) |
| slot to change the angle of the Kinect
|
void | setGreenLed () |
| slot to enable the green LED
|
void | setGreenLedFlash () |
| slot to flash the green led
|
void | setLedOff () |
| slot to turn off the led
|
void | setRedLed () |
| slot to enable the red LED
|
void | setRedLedFlash () |
| slot to flash the red led
|
void | setVideoMode (int _mode) |
| slot to set the video mode
|
void | setYellowLed () |
| slot to enable the yellow LED
|
void | setYellowLedFlash () |
| slot to flash the yellow led
|
void | startDepth () |
| start the Depth buffer grabbing subsystem
|
void | startVideo () |
| start the Video buffer grabbing subsystem
|
void | stopDepth () |
| stop the Depth buffer grabbing subsystem
|
void | stopVideo () |
| stop the Depth buffer grabbing subsystem
|
void | toggleDepthState (bool _mode) |
| convenience method to toggle the depth mode with a bool to indicate mode, useful for connecting to buttons
|
void | toggleVideoState (bool _mode) |
| convenience method to toggle the video mode with a bool to indicate mode, useful for connecting to buttons
|
Signals |
void | message (QString text) |
Public Member Functions |
void | setUserDeviceNumber (int _m) |
| we can set the user device number here by default it will be 1
|
void | shutDownKinect () |
| method to shutdown our device and close
|
Static Public Member Functions |
static QKinect * | instance () |
| get the instance of the QKinect object this will call the init method of the class if the instance doesn't exist. This is because this class will construct some threads so we need to create an instance first then pass that to the other classes in the thread
|
Private Member Functions |
void | depthFunc (freenect_device *_dev, void *o_depth, uint32_t _timestamp) |
| function for depth callback this hooks into the libfreenect callback system
|
void | grabDepth (void *_depth, uint32_t timestamp) |
| method to grab the depth passed to the depthCallback function as we are hooking into a C lib we need to do it this way as the callback functions must be static (see below)
|
void | grabVideo (void *_video, uint32_t timestamp) |
| method to grab the Video passed to the depthCallback function as we are hooking into a C lib we need to do it this way as the callback functions must be static (see below)
|
void | init () |
| private copy ctor as we are a singleton class
|
| QKinect () |
| private ctor as we are a singleton class
|
void | rgbFunc (freenect_device *_dev, void *o_rgb, uint32_t _timestamp) |
| function for Video callback this hooks into the libfreenect callback system
|
| ~QKinect () |
| private dtor as we are a singleton class
|
Static Private Member Functions |
static void | depthCallback (freenect_device *_dev, void *_depth, uint32_t _timestamp=0) |
| this hooks into the feenet callback system an is the main way of getting the data from the kinect this is not called directly
|
static void | videoCallback (freenect_device *_dev, void *_video, uint32_t _timestamp=0) |
| this hooks into the feenet callback system an is the main way of getting the data from the kinect this is not called directly
|
Private Attributes |
std::vector< uint8_t > | m_bufferDepth |
| our depth buffer for the current depth frames will be filled from the depth callback, this data is converted into an RGB representation with Red being closest and blue far away, this is done via a gamma table and converting the depth from 16 bit to 8 bit RGB useful for OpenCV like motion tracking
|
std::vector< uint8_t > | m_bufferDepthRaw |
| our depth buffer for the current depth frames will be filled from the depth callback this is the unaltered data converted to 8 bit not really useful so may get rid of at a later date just legacy from testing the other examples
|
std::vector< uint16_t > | m_bufferDepthRaw16 |
| the 16Bit raw depth values, this is good for voxel rendering of the data
|
std::vector< uint8_t > | m_bufferVideo |
| our video buffer for the current rgb video frames will be filled from the rgb callback
|
freenect_context * | m_ctx |
| the contex for the device
|
freenect_device * | m_dev |
| our device pointer
|
bool | m_deviceActive |
| flag to indicate if the device is active
|
std::vector< uint16_t > | m_gamma |
| our gamma table this is filled in the ctor and used in the depth callbacks, this is taken from the sample code glview.c cppview.cpp
|
QMutex | m_mutex |
| our mutex used for the threaded processes, for ease we use a QMutexLocker to automagically control our mutex state
|
bool | m_newDepthFrame |
| flag to indicate if there is a new depth frame
|
bool | m_newRgbFrame |
| flag to indicate if there is a new rgb frame
|
QKinectProcessEvents * | m_process |
| pointer to our thread process used to process the events
|
bool | m_stopDevice |
| flag to indicate if we need to stop the device
|
int | m_userDeviceNumber |
| user device number
|
Static Private Attributes |
static QKinect * | s_instance = 0 |
| our instance of the Kinect device
|
Detailed Description
this class wraps the libfreenect library as a QObject this allows us to use singals and slots to communicate with the class from other Qt GUI elements. This class uses the Singleton pattern so must be accessed via the instance method
@author Jonathan Macey
- Version:
- 1.0
- Date:
- 20/12/10 Inital commit
Definition at line 105 of file QKinect.h.
Constructor & Destructor Documentation
private ctor as we are a singleton class
Definition at line 84 of file QKinect.cpp.
private dtor as we are a singleton class
Definition at line 56 of file QKinect.cpp.
Member Function Documentation
static void QKinect::depthCallback |
( |
freenect_device * |
_dev, |
|
|
void * |
_depth, |
|
|
uint32_t |
_timestamp = 0 |
|
) |
| |
|
inlinestaticprivate |
this hooks into the feenet callback system an is the main way of getting the data from the kinect this is not called directly
- Parameters:
-
[in] | _dev | this is not used as we use the class m_dev |
[out] | _video | the depth data |
[in] | _timestamp | the timestamp of the operation (not used) |
get an instance of our device
then call the grab method to fill the depth buffer and return it
Definition at line 416 of file QKinect.h.
void QKinect::depthFunc |
( |
freenect_device * |
_dev, |
|
|
void * |
o_depth, |
|
|
uint32_t |
_timestamp |
|
) |
| |
|
private |
function for depth callback this hooks into the libfreenect callback system
- Parameters:
-
[in] | _dev | the device we are querying |
[out] | the | actual depth data returned from the device |
| _timestamp | the time stamp for the grab (not used at present) |
freenect_context* QKinect::getContext |
( |
| ) |
|
|
inlineslot |
return a pointer to the active device context
- Returns:
- the current active contects
Definition at line 255 of file QKinect.h.
bool QKinect::getDepth |
( |
std::vector< uint8_t > & |
o_buffer | ) |
|
|
slot |
getDepth buffer and convert it to an RGB colour representation this code is based on the sample implementation glview.c / cppview.cpp
- Parameters:
-
[out] | o_buffer | the buffer to fill |
Definition at line 303 of file QKinect.cpp.
bool QKinect::getDepth16Bit |
( |
std::vector< uint16_t > & |
o_buffer | ) |
|
|
slot |
getDepth buffer as the raw 16 Bit values this is useful for generating point cloud renders as we have the full depth range
- Parameters:
-
[out] | o_buffer | the buffer to fill |
fill the 16 Bit data value first lock mutex
Definition at line 322 of file QKinect.cpp.
bool QKinect::getDepthRaw |
( |
std::vector< uint8_t > & |
o_buffer | ) |
|
|
slot |
getDepth buffer as the raw values converted to uint8_t not sure if this will be much use but have used it in some tracking examples
- Parameters:
-
[out] | o_buffer | the buffer to fill |
Definition at line 341 of file QKinect.cpp.
bool QKinect::getRGB |
( |
std::vector< uint8_t > & |
o_buffer | ) |
|
|
slot |
get the RGB buffer
- Parameters:
-
[out] | o_buffer | the rgb values |
this grabs the rgb data we first need to lock our mutex this will be unlocked on destruction of the locker
Definition at line 282 of file QKinect.cpp.
void QKinect::grabDepth |
( |
void * |
_depth, |
|
|
uint32_t |
timestamp |
|
) |
| |
|
private |
method to grab the depth passed to the depthCallback function as we are hooking into a C lib we need to do it this way as the callback functions must be static (see below)
- Parameters:
-
[out] | _depth | the depth data |
[in] | _timestamp | the timestamp of the operation (not used) |
lock our mutex
Definition at line 359 of file QKinect.cpp.
void QKinect::grabVideo |
( |
void * |
_video, |
|
|
uint32_t |
timestamp |
|
) |
| |
|
private |
method to grab the Video passed to the depthCallback function as we are hooking into a C lib we need to do it this way as the callback functions must be static (see below)
- Parameters:
-
[out] | _video | the depth data |
[in] | _timestamp | the timestamp of the operation (not used) |
Definition at line 432 of file QKinect.cpp.
private copy ctor as we are a singleton class
private init method, this makes the instance method thread safe as all the initialisations will be done here
- Returns:
- EXIT_SUCCESS on success, EXIT_FAILURE om error
set loggin level make this programmable at some stage
see how many devices we have
now allocate the buffers so we can fill them
open the device at present hard coded to device 0 as I only have 1 kinect
- Todo:
- make this support multiple devices at some stage
build the gamma table used for the depth to rgb conversion taken from the demo programs
init our flags
- Todo:
- make this more flexible at some stage
hook in the callbacks
Definition at line 94 of file QKinect.cpp.
get the instance of the QKinect object this will call the init method of the class if the instance doesn't exist. This is because this class will construct some threads so we need to create an instance first then pass that to the other classes in the thread
- Returns:
- an instance of the QKinect object
- Note:
- this could be made nicer to make it fully thread safe
Definition at line 66 of file QKinect.cpp.
void QKinect::message |
( |
QString |
text | ) |
|
|
signal |
Emits a info or error message to a slot. This slot can be used to display a text on a splash screen, log file, to print it to a console...
void QKinect::resetAngle |
( |
| ) |
|
|
slot |
void QKinect::rgbFunc |
( |
freenect_device * |
_dev, |
|
|
void * |
o_rgb, |
|
|
uint32_t |
_timestamp |
|
) |
| |
|
private |
function for Video callback this hooks into the libfreenect callback system
- Parameters:
-
[in] | _dev | the device we are querying |
[out] | o_rgb | the actual video data returned from the device |
| _timestamp | the time stamp for the grab (not used at present) |
void QKinect::setAngle |
( |
double |
_angle | ) |
|
|
slot |
slot to change the angle of the Kinect
- Parameters:
-
[in] | _angle | the angle to set will be constrained to -/+ 30.0 |
Definition at line 266 of file QKinect.cpp.
void QKinect::setGreenLed |
( |
| ) |
|
|
slot |
slot to enable the green LED
Definition at line 197 of file QKinect.cpp.
void QKinect::setGreenLedFlash |
( |
| ) |
|
|
slot |
slot to flash the green led
Definition at line 215 of file QKinect.cpp.
void QKinect::setLedOff |
( |
| ) |
|
|
slot |
void QKinect::setRedLed |
( |
| ) |
|
|
slot |
slot to enable the red LED
Definition at line 191 of file QKinect.cpp.
void QKinect::setRedLedFlash |
( |
| ) |
|
|
slot |
void QKinect::setUserDeviceNumber |
( |
int |
_m | ) |
|
|
inline |
we can set the user device number here by default it will be 1
- Parameters:
-
[in] | _m | the number we wish to set |
Definition at line 123 of file QKinect.h.
void QKinect::setVideoMode |
( |
int |
_mode | ) |
|
|
slot |
slot to set the video mode
param _mode the video mode as an int index FREENECT_VIDEO_RGB = 0, FREENECT_VIDEO_YUV_RGB = 1, FREENECT_VIDEO_IR_8BIT = 2,
stop the video and set to new mode
Definition at line 227 of file QKinect.cpp.
void QKinect::setYellowLed |
( |
| ) |
|
|
slot |
slot to enable the yellow LED
Definition at line 203 of file QKinect.cpp.
void QKinect::setYellowLedFlash |
( |
| ) |
|
|
slot |
slot to flash the yellow led
Definition at line 221 of file QKinect.cpp.
void QKinect::shutDownKinect |
( |
| ) |
|
method to shutdown our device and close
stop the processing thread
stop the video and depth callbacks
Definition at line 171 of file QKinect.cpp.
void QKinect::startDepth |
( |
| ) |
|
|
slot |
start the Depth buffer grabbing subsystem
Definition at line 463 of file QKinect.cpp.
void QKinect::startVideo |
( |
| ) |
|
|
slot |
start the Video buffer grabbing subsystem
Definition at line 445 of file QKinect.cpp.
void QKinect::stopDepth |
( |
| ) |
|
|
slot |
stop the Depth buffer grabbing subsystem
Definition at line 472 of file QKinect.cpp.
void QKinect::stopVideo |
( |
| ) |
|
|
slot |
stop the Depth buffer grabbing subsystem
Definition at line 454 of file QKinect.cpp.
void QKinect::toggleDepthState |
( |
bool |
_mode | ) |
|
|
slot |
convenience method to toggle the depth mode with a bool to indicate mode, useful for connecting to buttons
Definition at line 494 of file QKinect.cpp.
void QKinect::toggleVideoState |
( |
bool |
_mode | ) |
|
|
slot |
convenience method to toggle the video mode with a bool to indicate mode, useful for connecting to buttons
Definition at line 481 of file QKinect.cpp.
static void QKinect::videoCallback |
( |
freenect_device * |
_dev, |
|
|
void * |
_video, |
|
|
uint32_t |
_timestamp = 0 |
|
) |
| |
|
inlinestaticprivate |
this hooks into the feenet callback system an is the main way of getting the data from the kinect this is not called directly
- Parameters:
-
[in] | _dev | this is not used as we use the class m_dev |
[out] | _video | the depth data |
[in] | _timestamp | the timestamp of the operation (not used) |
get an instance of our device
then fill the video buffer
Definition at line 434 of file QKinect.h.
Member Data Documentation
bool QKinect::kinectDetected |
true if camera detected
Definition at line 133 of file QKinect.h.
std::vector<uint8_t> QKinect::m_bufferDepth |
|
private |
our depth buffer for the current depth frames will be filled from the depth callback, this data is converted into an RGB representation with Red being closest and blue far away, this is done via a gamma table and converting the depth from 16 bit to 8 bit RGB useful for OpenCV like motion tracking
Definition at line 332 of file QKinect.h.
std::vector<uint8_t> QKinect::m_bufferDepthRaw |
|
private |
our depth buffer for the current depth frames will be filled from the depth callback this is the unaltered data converted to 8 bit not really useful so may get rid of at a later date just legacy from testing the other examples
Definition at line 346 of file QKinect.h.
std::vector<uint16_t> QKinect::m_bufferDepthRaw16 |
|
private |
the 16Bit raw depth values, this is good for voxel rendering of the data
Definition at line 352 of file QKinect.h.
std::vector<uint8_t> QKinect::m_bufferVideo |
|
private |
our video buffer for the current rgb video frames will be filled from the rgb callback
Definition at line 338 of file QKinect.h.
freenect_context* QKinect::m_ctx |
|
private |
the contex for the device
Definition at line 297 of file QKinect.h.
freenect_device* QKinect::m_dev |
|
private |
our device pointer
Definition at line 302 of file QKinect.h.
bool QKinect::m_deviceActive |
|
private |
flag to indicate if the device is active
Definition at line 378 of file QKinect.h.
std::vector<uint16_t> QKinect::m_gamma |
|
private |
our gamma table this is filled in the ctor and used in the depth callbacks, this is taken from the sample code glview.c cppview.cpp
Definition at line 358 of file QKinect.h.
our mutex used for the threaded processes, for ease we use a QMutexLocker to automagically control our mutex state
Definition at line 389 of file QKinect.h.
bool QKinect::m_newDepthFrame |
|
private |
flag to indicate if there is a new depth frame
Definition at line 368 of file QKinect.h.
bool QKinect::m_newRgbFrame |
|
private |
flag to indicate if there is a new rgb frame
Definition at line 363 of file QKinect.h.
pointer to our thread process used to process the events
Definition at line 383 of file QKinect.h.
bool QKinect::m_stopDevice |
|
private |
flag to indicate if we need to stop the device
Definition at line 373 of file QKinect.h.
int QKinect::m_userDeviceNumber |
|
private |
user device number
Definition at line 307 of file QKinect.h.
our instance of the Kinect device
Definition at line 292 of file QKinect.h.
The documentation for this class was generated from the following files: