Classes | Defines | Typedefs | Enumerations | Functions

/Users/qdot/git-projects/libfreenect/include/libfreenect.h File Reference

#include <stdint.h>
#include <libusb-1.0/libusb.h>

Go to the source code of this file.

Classes

struct  freenect_raw_tilt_state
 Data from the tilt motor and accelerometer. More...

Defines

#define FREENECT_FRAME_W   640
#define FREENECT_FRAME_H   480
#define FREENECT_FRAME_PIX   (FREENECT_FRAME_H*FREENECT_FRAME_W)
#define FREENECT_IR_FRAME_W   640
#define FREENECT_IR_FRAME_H   488
#define FREENECT_IR_FRAME_PIX   (FREENECT_IR_FRAME_H*FREENECT_IR_FRAME_W)
#define FREENECT_VIDEO_RGB_SIZE   (FREENECT_FRAME_PIX*3)
#define FREENECT_VIDEO_BAYER_SIZE   (FREENECT_FRAME_PIX)
#define FREENECT_VIDEO_YUV_RGB_SIZE   (FREENECT_VIDEO_RGB_SIZE)
#define FREENECT_VIDEO_YUV_RAW_SIZE   (FREENECT_FRAME_PIX*2)
#define FREENECT_VIDEO_IR_8BIT_SIZE   (FREENECT_IR_FRAME_PIX)
#define FREENECT_VIDEO_IR_10BIT_SIZE   (FREENECT_IR_FRAME_PIX*sizeof(uint16_t))
#define FREENECT_VIDEO_IR_10BIT_PACKED_SIZE   390400
#define FREENECT_DEPTH_11BIT_SIZE   (FREENECT_FRAME_PIX*sizeof(uint16_t))
#define FREENECT_DEPTH_10BIT_SIZE   FREENECT_DEPTH_11BIT_SIZE
#define FREENECT_DEPTH_11BIT_PACKED_SIZE   422400
#define FREENECT_DEPTH_10BIT_PACKED_SIZE   384000
#define FREENECT_COUNTS_PER_G   819
#define EXPORT
 If Win32, export all functions for DLL usage.

Typedefs

typedef struct _freenect_context freenect_context
typedef struct _freenect_device freenect_device
typedef libusb_context freenect_usb_context
typedef void(* freenect_log_cb )(freenect_context *dev, freenect_loglevel level, const char *msg)
 Typedef for logging callback functions.
typedef void(* freenect_depth_cb )(freenect_device *dev, void *depth, uint32_t timestamp)
 Typedef for depth image received event callbacks.
typedef void(* freenect_video_cb )(freenect_device *dev, void *video, uint32_t timestamp)
 Typedef for video image received event callbacks.

Enumerations

enum  freenect_video_format {
  FREENECT_VIDEO_RGB = 0, FREENECT_VIDEO_BAYER = 1, FREENECT_VIDEO_IR_8BIT = 2, FREENECT_VIDEO_IR_10BIT = 3,
  FREENECT_VIDEO_IR_10BIT_PACKED = 4, FREENECT_VIDEO_YUV_RGB = 5, FREENECT_VIDEO_YUV_RAW = 6
}
enum  freenect_led_options {
  LED_OFF = 0, LED_GREEN = 1, LED_RED = 2, LED_YELLOW = 3,
  LED_BLINK_YELLOW = 4, LED_BLINK_GREEN = 5, LED_BLINK_RED_YELLOW = 6
}
enum  freenect_depth_format { FREENECT_DEPTH_11BIT = 0, FREENECT_DEPTH_10BIT = 1, FREENECT_DEPTH_11BIT_PACKED = 2, FREENECT_DEPTH_10BIT_PACKED = 3 }
enum  freenect_tilt_status_code { TILT_STATUS_STOPPED = 0x00, TILT_STATUS_LIMIT = 0x01, TILT_STATUS_MOVING = 0x04 }
 

Enumeration of tilt motor status.

More...
enum  freenect_loglevel {
  FREENECT_LOG_FATAL = 0, FREENECT_LOG_ERROR, FREENECT_LOG_WARNING, FREENECT_LOG_NOTICE,
  FREENECT_LOG_INFO, FREENECT_LOG_DEBUG, FREENECT_LOG_SPEW, FREENECT_LOG_FLOOD
}
 

Enumeration of message logging levels.

More...

Functions

EXPORT int freenect_init (freenect_context **ctx, freenect_usb_context *usb_ctx)
EXPORT int freenect_shutdown (freenect_context *ctx)
EXPORT void freenect_set_log_level (freenect_context *ctx, freenect_loglevel level)
EXPORT void freenect_set_log_callback (freenect_context *ctx, freenect_log_cb cb)
EXPORT int freenect_process_events (freenect_context *ctx)
EXPORT int freenect_num_devices (freenect_context *ctx)
EXPORT int freenect_open_device (freenect_context *ctx, freenect_device **dev, int index)
EXPORT int freenect_close_device (freenect_device *dev)
EXPORT void freenect_set_user (freenect_device *dev, void *user)
EXPORT void * freenect_get_user (freenect_device *dev)
EXPORT void freenect_set_depth_callback (freenect_device *dev, freenect_depth_cb cb)
EXPORT void freenect_set_video_callback (freenect_device *dev, freenect_video_cb cb)
EXPORT int freenect_set_depth_format (freenect_device *dev, freenect_depth_format fmt)
EXPORT int freenect_set_video_format (freenect_device *dev, freenect_video_format fmt)
EXPORT int freenect_set_depth_buffer (freenect_device *dev, void *buf)
EXPORT int freenect_set_video_buffer (freenect_device *dev, void *buf)
EXPORT int freenect_start_depth (freenect_device *dev)
EXPORT int freenect_start_video (freenect_device *dev)
EXPORT int freenect_stop_depth (freenect_device *dev)
EXPORT int freenect_stop_video (freenect_device *dev)
EXPORT int freenect_update_tilt_state (freenect_device *dev)
EXPORT freenect_raw_tilt_statefreenect_get_tilt_state (freenect_device *dev)
EXPORT double freenect_get_tilt_degs (freenect_raw_tilt_state *state)
EXPORT int freenect_set_tilt_degs (freenect_device *dev, double angle)
EXPORT freenect_tilt_status_code freenect_get_tilt_status (freenect_raw_tilt_state *state)
EXPORT int freenect_set_led (freenect_device *dev, freenect_led_options option)
EXPORT void freenect_get_mks_accel (freenect_raw_tilt_state *state, double *x, double *y, double *z)

Define Documentation

#define EXPORT

If Win32, export all functions for DLL usage.

DLLExport information for windows, set to nothing on other platforms

#define FREENECT_COUNTS_PER_G   819
#define FREENECT_DEPTH_10BIT_PACKED_SIZE   384000

Size of the packed 10 bit depth frame

#define FREENECT_DEPTH_10BIT_SIZE   FREENECT_DEPTH_11BIT_SIZE

Size of the 10 bit depth frame

#define FREENECT_DEPTH_11BIT_PACKED_SIZE   422400

Size of the packed 11 bit depth frame

#define FREENECT_DEPTH_11BIT_SIZE   (FREENECT_FRAME_PIX*sizeof(uint16_t))

Size of the 11 bit depth frame

#define FREENECT_FRAME_H   480

Default video frame height

#define FREENECT_FRAME_PIX   (FREENECT_FRAME_H*FREENECT_FRAME_W)

Pixel count for default video frame

#define FREENECT_FRAME_W   640

Default video frame width

#define FREENECT_IR_FRAME_H   488

Default depth frame height

#define FREENECT_IR_FRAME_PIX   (FREENECT_IR_FRAME_H*FREENECT_IR_FRAME_W)

Pixel count for default depth frame

#define FREENECT_IR_FRAME_W   640

Default depth frame width

#define FREENECT_VIDEO_BAYER_SIZE   (FREENECT_FRAME_PIX)

Size of the bayer frame

#define FREENECT_VIDEO_IR_10BIT_PACKED_SIZE   390400

Size of the packed 10 bit IR video frame

#define FREENECT_VIDEO_IR_10BIT_SIZE   (FREENECT_IR_FRAME_PIX*sizeof(uint16_t))

Size of the 10 bit IR video frame

#define FREENECT_VIDEO_IR_8BIT_SIZE   (FREENECT_IR_FRAME_PIX)

Size of the 8 bit IR video frame

#define FREENECT_VIDEO_RGB_SIZE   (FREENECT_FRAME_PIX*3)

Size of the decompressed rgb frame

#define FREENECT_VIDEO_YUV_RAW_SIZE   (FREENECT_FRAME_PIX*2)

Size of the raw YUV frame

#define FREENECT_VIDEO_YUV_RGB_SIZE   (FREENECT_VIDEO_RGB_SIZE)

Size of the rgb YUV frame


Typedef Documentation

typedef struct _freenect_context freenect_context

Holds information about the usb context.

typedef void(* freenect_depth_cb)(freenect_device *dev, void *depth, uint32_t timestamp)

Typedef for depth image received event callbacks.

typedef struct _freenect_device freenect_device

Holds device information.

typedef void(* freenect_log_cb)(freenect_context *dev, freenect_loglevel level, const char *msg)

Typedef for logging callback functions.

typedef libusb_context freenect_usb_context

Holds libusb-1.0 specific information

typedef void(* freenect_video_cb)(freenect_device *dev, void *video, uint32_t timestamp)

Typedef for video image received event callbacks.


Enumeration Type Documentation

Enumeration of depth frame states See http://openkinect.org/wiki/Protocol_Documentation#RGB_Camera for more information.

Enumerator:
FREENECT_DEPTH_11BIT 

11 bit depth information in one uint_16t/pixel

FREENECT_DEPTH_10BIT 

10 bit depth information in one uint_16t/pixel

FREENECT_DEPTH_11BIT_PACKED 

11 bit compressed depth information

FREENECT_DEPTH_10BIT_PACKED 

10 bit compressed depth information

Enumeration of LED states See http://openkinect.org/wiki/Protocol_Documentation#Setting_LED for more information.

Enumerator:
LED_OFF 

Turn LED off

LED_GREEN 

Turn LED to Green

LED_RED 

Turn LED to Red

LED_YELLOW 

Turn LED to Yellow

LED_BLINK_YELLOW 

Make LED blink Green (Not Yellow)

LED_BLINK_GREEN 

Make LED blink Green

LED_BLINK_RED_YELLOW 

Make LED blink Red/Yellow

Enumeration of message logging levels.

Enumerator:
FREENECT_LOG_FATAL 

Log for crashing/non-recoverable errors

FREENECT_LOG_ERROR 

Log for major errors

FREENECT_LOG_WARNING 

Log for warning messages

FREENECT_LOG_NOTICE 

Log for important messages

FREENECT_LOG_INFO 

Log for normal messages

FREENECT_LOG_DEBUG 

Log for useful development messages

FREENECT_LOG_SPEW 

Log for slightly less useful messages

FREENECT_LOG_FLOOD 

Log EVERYTHING. May slow performance.

Enumeration of tilt motor status.

Enumerator:
TILT_STATUS_STOPPED 

Tilt motor is stopped

TILT_STATUS_LIMIT 

Tilt motor has reached movement limit

TILT_STATUS_MOVING 

Tilt motor is currently moving to new position

Enumeration of video frame information states. See http://openkinect.org/wiki/Protocol_Documentation#RGB_Camera for more information.

Enumerator:
FREENECT_VIDEO_RGB 

Decompressed RGB mode (decompression done by libfreenect)

FREENECT_VIDEO_BAYER 

Bayer compressed mode (raw information from camera)

FREENECT_VIDEO_IR_8BIT 

8-bit IR mode

FREENECT_VIDEO_IR_10BIT 

10-bit IR mode

FREENECT_VIDEO_IR_10BIT_PACKED 

10-bit packed IR mode

FREENECT_VIDEO_YUV_RGB 

YUV RGB mode

FREENECT_VIDEO_YUV_RAW 

YUV Raw mode


Function Documentation

EXPORT int freenect_close_device ( freenect_device dev )

Closes a device that is currently open

Parameters:
devDevice to close
Returns:
0 on success
EXPORT void freenect_get_mks_accel ( freenect_raw_tilt_state state,
double *  x,
double *  y,
double *  z 
)

Get the axis-based gravity adjusted accelerometer state, as laid out via the accelerometer data sheet, which is available at

http://www.kionix.com/Product%20Sheets/KXSD9%20Product%20Brief.pdf

Parameters:
stateState to extract accelerometer data from
xStores X-axis accelerometer state
yStores Y-axis accelerometer state
zStores Z-axis accelerometer state
EXPORT double freenect_get_tilt_degs ( freenect_raw_tilt_state state )

Return the tilt state, in degrees with respect to the horizon

Parameters:
stateThe tilt state struct from a device
Returns:
Current degree of tilt of the device
EXPORT freenect_raw_tilt_state* freenect_get_tilt_state ( freenect_device dev )

Retrieve the tilt state from a device

Parameters:
devDevice to retrieve tilt state from
Returns:
The tilt state struct of the device
EXPORT freenect_tilt_status_code freenect_get_tilt_status ( freenect_raw_tilt_state state )

Return the movement state of the tilt motor (moving, stopped, etc...)

Parameters:
stateRaw state struct to get the tilt status code from
Returns:
Status code of the tilt device. See freenect_tilt_status_code enum for more info.
EXPORT void* freenect_get_user ( freenect_device dev )

Retrieve the pointer to user data from the device struct

Parameters:
devDevice from which to get user data
Returns:
Pointer to user data
EXPORT int freenect_init ( freenect_context **  ctx,
freenect_usb_context usb_ctx 
)

Initialize a freenect context and do any setup required for platform specific USB libraries.

Parameters:
ctxPointer to freenect context struct to initialize
usb_ctxUSB context to initialize. Can be NULL if not using multiple contexts.
Returns:
0 on success, < 0 on error
EXPORT int freenect_num_devices ( freenect_context ctx )

Return the number of kinect devices currently connected to the system

Parameters:
ctxContext to access device count through
Returns:
Number of devices connected, < 0 on error
EXPORT int freenect_open_device ( freenect_context ctx,
freenect_device **  dev,
int  index 
)

Opens a kinect device via a context. Index specifies the index of the device on the current state of the bus. Bus resets may cause indexes to shift.

Parameters:
ctxContext to open device through
devDevice structure to assign opened device to
indexIndex of the device on the bus
Returns:
0 on success, < 0 on error
EXPORT int freenect_process_events ( freenect_context ctx )

Calls the platform specific usb event processor

Parameters:
ctxcontext to process events for
Returns:
0 on success, other values on error, platform/library dependant
EXPORT int freenect_set_depth_buffer ( freenect_device dev,
void *  buf 
)

Set the buffer to store depth information to. Size of buffer is dependant on depth format. See FREENECT_DEPTH_*_SIZE defines for more information.

Parameters:
devDevice to set depth buffer for.
bufBuffer to store depth information to.
Returns:
0 on success, < 0 on error
EXPORT void freenect_set_depth_callback ( freenect_device dev,
freenect_depth_cb  cb 
)

Set callback for depth information received event

Parameters:
devDevice to set callback for
cbFunction pointer for processing depth information
EXPORT int freenect_set_depth_format ( freenect_device dev,
freenect_depth_format  fmt 
)

Set the format for depth information

Parameters:
devDevice to set depth information format for
fmtFormat of depth information. See freenect_depth_format enum.
Returns:
0 on success, < 0 on error
EXPORT int freenect_set_led ( freenect_device dev,
freenect_led_options  option 
)

Set the state of the LED. Uses blocking control message call to update device.

Parameters:
devDevice to set the LED state
optionLED state to set on device. See freenect_led_options enum.
Returns:
0 on success, < 0 on error
EXPORT void freenect_set_log_callback ( freenect_context ctx,
freenect_log_cb  cb 
)

Callback for log messages (i.e. for rerouting to a file instead of stdout)

Parameters:
ctxcontext to set log callback for
cbcallback function pointer
EXPORT void freenect_set_log_level ( freenect_context ctx,
freenect_loglevel  level 
)

Set the log level for the specified freenect context

Parameters:
ctxcontext to set log level for
levellog level to use (see freenect_loglevel enum)
EXPORT int freenect_set_tilt_degs ( freenect_device dev,
double  angle 
)

Set the tilt state of the device, in degrees with respect to the horizon. Uses blocking control message call to update device. Function return does not reflect state of device, device may still be moving to new position after the function returns. Use freenect_get_tilt_status() to find current movement state.

Parameters:
devDevice to set tilt state
angleAngle the device should tilt to
Returns:
0 on success, < 0 on error.
EXPORT void freenect_set_user ( freenect_device dev,
void *  user 
)

Set the device user data, for passing generic information into callbacks

Parameters:
devDevice to attach user data to
userUser data to attach
EXPORT int freenect_set_video_buffer ( freenect_device dev,
void *  buf 
)

Set the buffer to store depth information to. Size of buffer is dependant on video format. See FREENECT_VIDEO_*_SIZE defines for more information.

Parameters:
devDevice to set video buffer for.
bufBuffer to store video information to.
Returns:
0 on success, < 0 on error
EXPORT void freenect_set_video_callback ( freenect_device dev,
freenect_video_cb  cb 
)

Set callback for video information received event

Parameters:
devDevice to set callback for
cbFunction pointer for processing video information
EXPORT int freenect_set_video_format ( freenect_device dev,
freenect_video_format  fmt 
)

Set the format for video information

Parameters:
devDevice to set video information format for
fmtFormat of video information. See freenect_video_format enum.
Returns:
0 on success, < 0 on error
EXPORT int freenect_shutdown ( freenect_context ctx )

Closes the device if it is open, and frees the context

Parameters:
ctxfreenect context to close/free
Returns:
0 on success
EXPORT int freenect_start_depth ( freenect_device dev )

Start the depth information stream for a device.

Parameters:
devDevice to start depth information stream for.
Returns:
0 on success, < 0 on error
EXPORT int freenect_start_video ( freenect_device dev )

Start the video information stream for a device.

Parameters:
devDevice to start video information stream for.
Returns:
0 on success, < 0 on error
EXPORT int freenect_stop_depth ( freenect_device dev )

Stop the depth information stream for a device

Parameters:
devDevice to stop depth information stream on.
Returns:
0 on success, < 0 on error
EXPORT int freenect_stop_video ( freenect_device dev )

Stop the video information stream for a device

Parameters:
devDevice to stop video information stream on.
Returns:
0 on success, < 0 on error
EXPORT int freenect_update_tilt_state ( freenect_device dev )

Updates the accelerometer state using a blocking control message call.

Parameters:
devDevice to get accelerometer data from
Returns:
0 on success, < 0 on error. Accelerometer data stored to device struct.