Macros | Functions | Variables
fakenect.c File Reference
#include "libfreenect.h"
#include "platform.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <assert.h>
Include dependency graph for fakenect.c:

Go to the source code of this file.

Macros

#define GRAVITY   9.80665
 

Functions

int freenect_close_device (freenect_device *dev)
 
freenect_frame_mode freenect_find_depth_mode (freenect_resolution res, freenect_depth_format fmt)
 
freenect_frame_mode freenect_find_video_mode (freenect_resolution res, freenect_video_format fmt)
 
freenect_frame_mode freenect_get_current_depth_mode (freenect_device *dev)
 
freenect_frame_mode freenect_get_current_video_mode (freenect_device *dev)
 
freenect_frame_mode freenect_get_depth_mode (int mode_num)
 
int freenect_get_depth_mode_count ()
 
void freenect_get_mks_accel (freenect_raw_tilt_state *state, double *x, double *y, double *z)
 
double freenect_get_tilt_degs (freenect_raw_tilt_state *state)
 
freenect_raw_tilt_statefreenect_get_tilt_state (freenect_device *dev)
 
freenect_tilt_status_code freenect_get_tilt_status (freenect_raw_tilt_state *state)
 
void * freenect_get_user (freenect_device *dev)
 
freenect_frame_mode freenect_get_video_mode (int mode_num)
 
int freenect_get_video_mode_count ()
 
int freenect_init (freenect_context **ctx, freenect_usb_context *usb_ctx)
 
int freenect_num_devices (freenect_context *ctx)
 
int freenect_open_device (freenect_context *ctx, freenect_device **dev, int index)
 
int freenect_open_device_by_camera_serial (freenect_context *ctx, freenect_device **dev, const char *camera_serial)
 
int freenect_process_events (freenect_context *ctx)
 
int freenect_process_events_timeout (freenect_context *ctx, struct timeval *timeout)
 
void freenect_select_subdevices (freenect_context *ctx, freenect_device_flags subdevs)
 
int freenect_set_depth_buffer (freenect_device *dev, void *buf)
 
void freenect_set_depth_callback (freenect_device *dev, freenect_depth_cb cb)
 
int freenect_set_depth_format (freenect_device *dev, freenect_depth_format fmt)
 
int freenect_set_depth_mode (freenect_device *dev, const freenect_frame_mode mode)
 
int freenect_set_led (freenect_device *dev, freenect_led_options option)
 
void freenect_set_log_callback (freenect_context *ctx, freenect_log_cb cb)
 
void freenect_set_log_level (freenect_context *ctx, freenect_loglevel level)
 
int freenect_set_tilt_degs (freenect_device *dev, double angle)
 
void freenect_set_user (freenect_device *dev, void *user)
 
int freenect_set_video_buffer (freenect_device *dev, void *buf)
 
void freenect_set_video_callback (freenect_device *dev, freenect_video_cb cb)
 
int freenect_set_video_format (freenect_device *dev, freenect_video_format fmt)
 
int freenect_set_video_mode (freenect_device *dev, const freenect_frame_mode mode)
 
int freenect_shutdown (freenect_context *ctx)
 
int freenect_start_depth (freenect_device *dev)
 
int freenect_start_video (freenect_device *dev)
 
int freenect_stop_depth (freenect_device *dev)
 
int freenect_stop_video (freenect_device *dev)
 
int freenect_supported_subdevices (void)
 
int freenect_update_tilt_state (freenect_device *dev)
 
static int get_data_size (FILE *fp)
 
static char * one_line (FILE *fp)
 
static void open_index ()
 
static int parse_line (char *type, double *cur_time, unsigned int *timestamp, unsigned int *data_size, char **data)
 
static char * skip_line (char *str)
 

Variables

static int already_warned = 0
 
static freenect_depth_cb cur_depth_cb = NULL
 
static freenect_video_cb cur_rgb_cb = NULL
 
static void * depth_buffer = NULL
 
static int depth_running = 0
 
static freenect_contextfake_ctx = (freenect_context *)5678
 
static freenect_devicefake_dev = (freenect_device *)1234
 
static FILE * index_fp = NULL
 
static char * input_path = NULL
 
static double playback_prev_time = 0.
 
static double record_prev_time = 0.
 
static void * rgb_buffer = NULL
 
static int rgb_running = 0
 
static freenect_raw_tilt_state state = { 0 }
 
static void * user_ptr = NULL
 

Macro Definition Documentation

#define GRAVITY   9.80665

Definition at line 35 of file fakenect.c.

Function Documentation

int freenect_close_device ( freenect_device dev)

Closes a device that is currently open

Parameters
devDevice to close
Returns
0 on success

Definition at line 406 of file fakenect.c.

freenect_frame_mode freenect_find_depth_mode ( freenect_resolution  res,
freenect_depth_format  fmt 
)

Convenience function to return a mode descriptor matching the specified resolution and depth camera pixel format, if one exists.

Parameters
resResolution desired
fmtPixel format desired
Returns
A freenect_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect_frame_mode.

Definition at line 284 of file fakenect.c.

freenect_frame_mode freenect_find_video_mode ( freenect_resolution  res,
freenect_video_format  fmt 
)

Convenience function to return a mode descriptor matching the specified resolution and video camera pixel format, if one exists.

Parameters
resResolution desired
fmtPixel format desired
Returns
A freenect_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect_frame_mode.

Definition at line 260 of file fakenect.c.

freenect_frame_mode freenect_get_current_depth_mode ( freenect_device dev)

Get the frame descriptor of the current depth mode for the specified freenect device.

Parameters
devWhich device to return the currently-set depth mode for
Returns
A freenect_frame_mode describing the current depth mode of the specified device

Definition at line 303 of file fakenect.c.

freenect_frame_mode freenect_get_current_video_mode ( freenect_device dev)

Get the frame descriptor of the current video mode for the specified freenect device.

Parameters
devWhich device to return the currently-set video mode for
Returns
A freenect_frame_mode describing the current video mode of the specified device

Definition at line 279 of file fakenect.c.

freenect_frame_mode freenect_get_depth_mode ( int  mode_num)

Get the frame descriptor of the nth supported depth mode for the depth camera.

Parameters
mode_numWhich of the supported modes to return information about
Returns
A freenect_frame_mode describing the nth depth mode

Definition at line 298 of file fakenect.c.

int freenect_get_depth_mode_count ( )

Get the number of depth camera modes supported by the driver. This includes both RGB and IR modes.

Returns
Number of depth modes supported by the driver

Definition at line 293 of file fakenect.c.

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

Definition at line 227 of file fakenect.c.

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

Definition at line 211 of file fakenect.c.

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

Definition at line 217 of file fakenect.c.

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.

Definition at line 222 of file fakenect.c.

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

Definition at line 360 of file fakenect.c.

freenect_frame_mode freenect_get_video_mode ( int  mode_num)

Get the frame descriptor of the nth supported video mode for the video camera.

Parameters
mode_numWhich of the supported modes to return information about
Returns
A freenect_frame_mode describing the nth video mode

Definition at line 274 of file fakenect.c.

int freenect_get_video_mode_count ( )

Get the number of video camera modes supported by the driver. This includes both RGB and IR modes.

Returns
Number of video modes supported by the driver

Definition at line 269 of file fakenect.c.

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
ctxAddress of pointer to freenect context struct to allocate and initialize
usb_ctxUSB context to initialize. Can be NULL if not using multiple contexts.
Returns
0 on success, < 0 on error

Definition at line 327 of file fakenect.c.

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

Definition at line 308 of file fakenect.c.

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

Definition at line 314 of file fakenect.c.

int freenect_open_device_by_camera_serial ( freenect_context ctx,
freenect_device **  dev,
const char *  camera_serial 
)

Opens a kinect device (via a context) associated with a particular camera subdevice serial number. This function will fail if no device with a matching serial number is found.

Parameters
ctxContext to open device through
devDevice structure to assign opened device to
camera_serialNull-terminated ASCII string containing the serial number of the camera subdevice in the device to open
Returns
0 on success, < 0 on error

Definition at line 321 of file fakenect.c.

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

Definition at line 140 of file fakenect.c.

int freenect_process_events_timeout ( freenect_context ctx,
struct timeval *  timeout 
)

Calls the platform specific usb event processor until either an event occurs or the timeout parameter time has passed. If a zero timeval is passed, this function will handle any already-pending events, then return immediately.

Parameters
ctxContext to process events for
timeoutPointer to a timeval containing the maximum amount of time to block waiting for events, or zero for nonblocking mode
Returns
0 on success, other values on error, platform/library dependant

Definition at line 206 of file fakenect.c.

void freenect_select_subdevices ( freenect_context ctx,
freenect_device_flags  subdevs 
)

Set which subdevices any subsequent calls to freenect_open_device() should open. This will not affect devices which have already been opened. The default behavior, should you choose not to call this function at all, is to open all supported subdevices - motor, cameras, and audio, if supported on the platform.

Parameters
ctxContext to set future subdevice selection for
subdevsFlags representing the subdevices to select

Definition at line 338 of file fakenect.c.

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

Definition at line 343 of file fakenect.c.

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

Definition at line 236 of file fakenect.c.

int freenect_set_depth_format ( freenect_device dev,
freenect_depth_format  fmt 
)

Definition at line 394 of file fakenect.c.

int freenect_set_depth_mode ( freenect_device dev,
const freenect_frame_mode  mode 
)

Sets the current depth mode for the specified device. The mode cannot be changed while streaming is active.

Parameters
devDevice for which to set the depth mode
modeFrame mode to set
Returns
0 on success, < 0 if error

Definition at line 253 of file fakenect.c.

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

Definition at line 414 of file fakenect.c.

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

Definition at line 400 of file fakenect.c.

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)

Definition at line 401 of file fakenect.c.

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.

Definition at line 410 of file fakenect.c.

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

Definition at line 355 of file fakenect.c.

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

Definition at line 349 of file fakenect.c.

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

Definition at line 241 of file fakenect.c.

int freenect_set_video_format ( freenect_device dev,
freenect_video_format  fmt 
)

Definition at line 389 of file fakenect.c.

int freenect_set_video_mode ( freenect_device dev,
freenect_frame_mode  mode 
)

Sets the current video mode for the specified device. If the freenect_frame_mode specified is not one provided by the driver e.g. from freenect_get_video_mode() or freenect_find_video_mode() then behavior is undefined. The current video mode cannot be changed while streaming is active.

Parameters
devDevice for which to set the video mode
modeFrame mode to set
Returns
0 on success, < 0 if error

Definition at line 246 of file fakenect.c.

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

Definition at line 402 of file fakenect.c.

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

Definition at line 365 of file fakenect.c.

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

Definition at line 371 of file fakenect.c.

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

Definition at line 377 of file fakenect.c.

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

Definition at line 383 of file fakenect.c.

int freenect_supported_subdevices ( void  )

Answer which subdevices this library supports. This is most useful for wrappers trying to determine whether the underlying library was built with audio support or not, so the wrapper can avoid calling functions that do not exist.

Returns
Flags representing the subdevices that the library supports opening (see freenect_device_flags)

Definition at line 333 of file fakenect.c.

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.

Definition at line 418 of file fakenect.c.

static int get_data_size ( FILE *  fp)
static

Definition at line 72 of file fakenect.c.

static char* one_line ( FILE *  fp)
static

Definition at line 55 of file fakenect.c.

static void open_index ( )
static

Definition at line 112 of file fakenect.c.

static int parse_line ( char *  type,
double *  cur_time,
unsigned int *  timestamp,
unsigned int *  data_size,
char **  data 
)
static

Definition at line 81 of file fakenect.c.

static char* skip_line ( char *  str)
static

Definition at line 130 of file fakenect.c.

Variable Documentation

int already_warned = 0
static

Definition at line 46 of file fakenect.c.

freenect_depth_cb cur_depth_cb = NULL
static

Definition at line 41 of file fakenect.c.

freenect_video_cb cur_rgb_cb = NULL
static

Definition at line 42 of file fakenect.c.

void* depth_buffer = NULL
static

Definition at line 49 of file fakenect.c.

int depth_running = 0
static

Definition at line 51 of file fakenect.c.

freenect_context* fake_ctx = (freenect_context *)5678
static

Definition at line 40 of file fakenect.c.

freenect_device* fake_dev = (freenect_device *)1234
static

Definition at line 39 of file fakenect.c.

FILE* index_fp = NULL
static

Definition at line 44 of file fakenect.c.

char* input_path = NULL
static

Definition at line 43 of file fakenect.c.

double playback_prev_time = 0.
static

Definition at line 47 of file fakenect.c.

double record_prev_time = 0.
static

Definition at line 48 of file fakenect.c.

void* rgb_buffer = NULL
static

Definition at line 50 of file fakenect.c.

int rgb_running = 0
static

Definition at line 52 of file fakenect.c.

freenect_raw_tilt_state state = { 0 }
static

Definition at line 45 of file fakenect.c.

void* user_ptr = NULL
static

Definition at line 53 of file fakenect.c.



libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Mon Jun 10 2019 13:46:43