35 #define GRAVITY 9.80665 60 for (c = fgetc(fp); !(c ==
'\n' || c == EOF); c = fgetc(fp))
62 out = realloc(out, pos + 1);
66 out = realloc(out, pos + 1);
75 fseek(fp, 0L, SEEK_END);
77 fseek(fp, orig, SEEK_SET);
81 static int parse_line(
char *type,
double *cur_time,
unsigned int *timestamp,
unsigned int *data_size,
char **data)
85 printf(
"Warning: No more lines in [%s]\n",
input_path);
88 int file_path_size = strlen(
input_path) + strlen(line) + 50;
89 char *file_path = malloc(file_path_size);
90 snprintf(file_path, file_path_size,
"%s/%s",
input_path, line);
92 FILE *cur_fp = fopen(file_path,
"rb");
94 printf(
"Error: Cannot open file [%s]\n", file_path);
100 sscanf(line,
"%c-%lf-%u-%*s", type, cur_time, timestamp);
101 *data = malloc(*data_size);
102 if (fread(*data, *data_size, 1, cur_fp) != 1) {
103 printf(
"Error: Couldn't read entire file.\n");
116 printf(
"Error: Environmental variable FAKENECT_PATH is not set. Set it to a path that was created using the 'record' utility.\n");
119 int index_path_size = strlen(
input_path) + 50;
120 char *index_path = malloc(index_path_size);
121 snprintf(index_path, index_path_size,
"%s/INDEX.txt",
input_path);
124 printf(
"Error: Cannot open file [%s]\n", index_path);
132 char *out = strchr(str,
'\n');
134 printf(
"Error: PGM/PPM has incorrect formatting, expected a header on one line followed by a newline\n");
154 double record_cur_time;
155 unsigned int timestamp, data_size;
157 if (
parse_line(&type, &record_cur_time, ×tamp, &data_size, &data))
187 if (data_size ==
sizeof(state)) {
188 memcpy(&state, data,
sizeof(state));
191 printf(
"\n\nWarning: Accelerometer data has an unexpected" 192 " size [%u] instead of [%u]. The acceleration " 193 "and tilt data will be substituted for dummy " 194 "values. This data was probably made with an " 195 "older version of record (the upstream interface " 197 data_size, (
unsigned int)
sizeof state);
void freenect_set_video_callback(freenect_device *dev, freenect_video_cb cb)
freenect_frame_mode freenect_get_depth_mode(int mode_num)
void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs)
static double record_prev_time
void freenect_get_mks_accel(freenect_raw_tilt_state *state, double *x, double *y, double *z)
void freenect_set_log_callback(freenect_context *ctx, freenect_log_cb cb)
int freenect_stop_video(freenect_device *dev)
int freenect_open_device_by_camera_serial(freenect_context *ctx, freenect_device **dev, const char *camera_serial)
static void * depth_buffer
freenect_frame_mode freenect_get_video_mode(int mode_num)
static int parse_line(char *type, double *cur_time, unsigned int *timestamp, unsigned int *data_size, char **data)
static double playback_prev_time
void freenect_usb_context
int freenect_num_devices(freenect_context *ctx)
freenect_tilt_status_code tilt_status
int freenect_start_depth(freenect_device *dev)
static freenect_context * fake_ctx
int freenect_set_led(freenect_device *dev, freenect_led_options option)
int freenect_set_video_buffer(freenect_device *dev, void *buf)
int freenect_shutdown(freenect_context *ctx)
void(* freenect_depth_cb)(freenect_device *dev, void *depth, uint32_t timestamp)
Typedef for depth image received event callbacks.
#define FREENECT_COUNTS_PER_G
int freenect_set_video_mode(freenect_device *dev, const freenect_frame_mode mode)
int freenect_set_tilt_degs(freenect_device *dev, double angle)
int freenect_process_events_timeout(freenect_context *ctx, struct timeval *timeout)
void freenect_set_depth_callback(freenect_device *dev, freenect_depth_cb cb)
freenect_loglevel
Enumeration of message logging levels.
void freenect_set_log_level(freenect_context *ctx, freenect_loglevel level)
int freenect_start_video(freenect_device *dev)
double freenect_get_tilt_degs(freenect_raw_tilt_state *state)
freenect_tilt_status_code freenect_get_tilt_status(freenect_raw_tilt_state *state)
freenect_frame_mode freenect_find_video_mode(freenect_resolution res, freenect_video_format fmt)
static freenect_device * fake_dev
int freenect_set_video_format(freenect_device *dev, freenect_video_format fmt)
freenect_frame_mode freenect_get_current_depth_mode(freenect_device *dev)
void * freenect_get_user(freenect_device *dev)
freenect_frame_mode freenect_find_depth_mode(freenect_resolution res, freenect_depth_format fmt)
static char * skip_line(char *str)
freenect_raw_tilt_state * freenect_get_tilt_state(freenect_device *dev)
static freenect_depth_cb cur_depth_cb
int freenect_update_tilt_state(freenect_device *dev)
void(* freenect_log_cb)(freenect_context *dev, freenect_loglevel level, const char *msg)
Typedef for logging callback functions.
int freenect_get_video_mode_count()
int freenect_close_device(freenect_device *dev)
int freenect_set_depth_mode(freenect_device *dev, const freenect_frame_mode mode)
freenect_frame_mode freenect_get_current_video_mode(freenect_device *dev)
int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index)
int freenect_get_depth_mode_count()
static int get_data_size(FILE *fp)
static freenect_video_cb cur_rgb_cb
int freenect_supported_subdevices(void)
static freenect_context * ctx
Data from the tilt motor and accelerometer.
static freenect_raw_tilt_state state
int freenect_stop_depth(freenect_device *dev)
static int already_warned
void(* freenect_video_cb)(freenect_device *dev, void *video, uint32_t timestamp)
Typedef for video image received event callbacks.
freenect_tilt_status_code
Enumeration of tilt motor status.
static char * one_line(FILE *fp)
int freenect_process_events(freenect_context *ctx)
int freenect_set_depth_format(freenect_device *dev, freenect_depth_format fmt)
int freenect_set_depth_buffer(freenect_device *dev, void *buf)
void freenect_set_user(freenect_device *dev, void *user)
int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx)