libfreenect
0.1.2
Main Page
Classes
Files
File List
File Members
include
libfreenect.h
Go to the documentation of this file.
1
/*
2
* This file is part of the OpenKinect Project. http://www.openkinect.org
3
*
4
* Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
5
* for details.
6
*
7
* This code is licensed to you under the terms of the Apache License, version
8
* 2.0, or, at your option, the terms of the GNU General Public License,
9
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10
* or the following URLs:
11
* http://www.apache.org/licenses/LICENSE-2.0
12
* http://www.gnu.org/licenses/gpl-2.0.txt
13
*
14
* If you redistribute this file in source form, modified or unmodified, you
15
* may:
16
* 1) Leave this header intact and distribute it under the same terms,
17
* accompanying it with the APACHE20 and GPL20 files, or
18
* 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19
* 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20
* In all cases you must keep the copyright notice intact and include a copy
21
* of the CONTRIB file.
22
*
23
* Binary distributions must follow the binary distribution requirements of
24
* either License.
25
*/
26
27
#pragma once
28
29
#include <stdint.h>
30
31
/* We need struct timeval */
32
#ifdef _WIN32
33
#include <winsock.h>
34
#else
35
#include <sys/time.h>
36
#endif
37
38
#ifdef __cplusplus
39
extern
"C"
{
40
#endif
41
42
#define FREENECT_COUNTS_PER_G 819
44
#define FREENECT_DEPTH_MM_MAX_VALUE 10000
46
#define FREENECT_DEPTH_MM_NO_VALUE 0
48
#define FREENECT_DEPTH_RAW_MAX_VALUE 2048
50
#define FREENECT_DEPTH_RAW_NO_VALUE 2047
52
58
typedef
enum
{
59
FREENECT_DEVICE_MOTOR
= 0x01,
60
FREENECT_DEVICE_CAMERA
= 0x02,
61
FREENECT_DEVICE_AUDIO
= 0x04,
62
}
freenect_device_flags
;
63
67
struct
freenect_device_attributes
;
68
struct
freenect_device_attributes
{
69
struct
freenect_device_attributes
*
next
;
70
const
char
*
camera_serial
;
71
};
72
77
typedef
enum
{
78
FREENECT_RESOLUTION_LOW
= 0,
79
FREENECT_RESOLUTION_MEDIUM
= 1,
80
FREENECT_RESOLUTION_HIGH
= 2,
81
FREENECT_RESOLUTION_DUMMY
= 2147483647,
82
}
freenect_resolution
;
83
86
typedef
enum
{
87
FREENECT_VIDEO_RGB
= 0,
88
FREENECT_VIDEO_BAYER
= 1,
89
FREENECT_VIDEO_IR_8BIT
= 2,
90
FREENECT_VIDEO_IR_10BIT
= 3,
91
FREENECT_VIDEO_IR_10BIT_PACKED
= 4,
92
FREENECT_VIDEO_YUV_RGB
= 5,
93
FREENECT_VIDEO_YUV_RAW
= 6,
94
FREENECT_VIDEO_DUMMY
= 2147483647,
95
}
freenect_video_format
;
96
99
typedef
enum
{
100
FREENECT_DEPTH_11BIT
= 0,
101
FREENECT_DEPTH_10BIT
= 1,
102
FREENECT_DEPTH_11BIT_PACKED
= 2,
103
FREENECT_DEPTH_10BIT_PACKED
= 3,
104
FREENECT_DEPTH_REGISTERED
= 4,
105
FREENECT_DEPTH_MM
= 5,
106
FREENECT_DEPTH_DUMMY
= 2147483647,
107
}
freenect_depth_format
;
108
110
typedef
enum
{
111
// values written to the CMOS register
112
FREENECT_AUTO_EXPOSURE
= 1 << 14,
113
FREENECT_AUTO_WHITE_BALANCE
= 1 << 1,
114
FREENECT_RAW_COLOR
= 1 << 4,
115
// registers to be written with 0 or 1
116
FREENECT_MIRROR_DEPTH
= 0x0017,
117
FREENECT_MIRROR_VIDEO
= 0x0047,
118
}
freenect_flag
;
119
121
typedef
enum
{
122
FREENECT_OFF
= 0,
123
FREENECT_ON
= 1,
124
}
freenect_flag_value
;
125
129
typedef
struct
{
130
uint32_t
reserved
;
131
freenect_resolution
resolution
;
132
union
{
133
int32_t
dummy
;
134
freenect_video_format
video_format
;
135
freenect_depth_format
depth_format
;
136
};
137
int32_t
bytes
;
138
int16_t
width
;
139
int16_t
height
;
140
int8_t
data_bits_per_pixel
;
141
int8_t
padding_bits_per_pixel
;
142
int8_t
framerate
;
143
int8_t
is_valid
;
144
}
freenect_frame_mode
;
145
148
typedef
enum
{
149
LED_OFF
= 0,
150
LED_GREEN
= 1,
151
LED_RED
= 2,
152
LED_YELLOW
= 3,
153
LED_BLINK_GREEN
= 4,
154
// 5 is same as 4, LED blink Green
155
LED_BLINK_RED_YELLOW
= 6,
156
}
freenect_led_options
;
157
158
160
typedef
enum
{
161
TILT_STATUS_STOPPED
= 0x00,
162
TILT_STATUS_LIMIT
= 0x01,
163
TILT_STATUS_MOVING
= 0x04,
164
}
freenect_tilt_status_code
;
165
167
typedef
struct
{
168
int16_t
accelerometer_x
;
169
int16_t
accelerometer_y
;
170
int16_t
accelerometer_z
;
171
int8_t
tilt_angle
;
172
freenect_tilt_status_code
tilt_status
;
173
}
freenect_raw_tilt_state
;
174
175
struct
_freenect_context;
176
typedef
struct
_freenect_context
freenect_context
;
178
struct
_freenect_device;
179
typedef
struct
_freenect_device
freenect_device
;
181
// usb backend specific section
182
typedef
void
freenect_usb_context
;
183
//
184
186
#ifndef _WIN32
187
#define FREENECTAPI
188
#else
189
190
#ifdef __cplusplus
191
#define FREENECTAPI extern "C" __declspec(dllexport)
192
#else
193
// this is required when building from a Win32 port of gcc without being
194
// forced to compile all of the library files (.c) with g++...
195
#define FREENECTAPI __declspec(dllexport)
196
#endif
197
#endif
198
200
typedef
enum
{
201
FREENECT_LOG_FATAL
= 0,
202
FREENECT_LOG_ERROR
,
203
FREENECT_LOG_WARNING
,
204
FREENECT_LOG_NOTICE
,
205
FREENECT_LOG_INFO
,
206
FREENECT_LOG_DEBUG
,
207
FREENECT_LOG_SPEW
,
208
FREENECT_LOG_FLOOD
,
209
}
freenect_loglevel
;
210
220
FREENECTAPI
int
freenect_init
(
freenect_context
**ctx, freenect_usb_context *usb_ctx);
221
229
FREENECTAPI
int
freenect_shutdown
(
freenect_context
*ctx);
230
232
typedef
void (*
freenect_log_cb
)(
freenect_context
*dev,
freenect_loglevel
level,
const
char
*msg);
233
240
FREENECTAPI
void
freenect_set_log_level
(
freenect_context
*ctx,
freenect_loglevel
level);
241
249
FREENECTAPI
void
freenect_set_log_callback
(
freenect_context
*ctx,
freenect_log_cb
cb);
250
258
FREENECTAPI
int
freenect_process_events
(
freenect_context
*ctx);
259
270
FREENECTAPI
int
freenect_process_events_timeout
(
freenect_context
*ctx,
struct
timeval* timeout);
271
280
FREENECTAPI
int
freenect_num_devices
(
freenect_context
*ctx);
281
291
FREENECTAPI
int
freenect_list_device_attributes
(
freenect_context
*ctx,
struct
freenect_device_attributes
** attribute_list);
292
298
FREENECTAPI
void
freenect_free_device_attributes
(
struct
freenect_device_attributes
* attribute_list);
299
308
FREENECTAPI
int
freenect_supported_subdevices
(
void
);
309
320
FREENECTAPI
void
freenect_select_subdevices
(
freenect_context
*ctx,
freenect_device_flags
subdevs);
321
329
FREENECTAPI
freenect_device_flags
freenect_enabled_subdevices
(
freenect_context
*ctx);
330
342
FREENECTAPI
int
freenect_open_device
(
freenect_context
*ctx,
freenect_device
**dev,
int
index);
343
355
FREENECTAPI
int
freenect_open_device_by_camera_serial
(
freenect_context
*ctx,
freenect_device
**dev,
const
char
* camera_serial);
356
364
FREENECTAPI
int
freenect_close_device
(
freenect_device
*dev);
365
373
FREENECTAPI
void
freenect_set_user
(
freenect_device
*dev,
void
*user);
374
382
FREENECTAPI
void
*
freenect_get_user
(
freenect_device
*dev);
383
385
typedef
void (*
freenect_depth_cb
)(
freenect_device
*dev,
void
*depth, uint32_t timestamp);
387
typedef
void (*
freenect_video_cb
)(
freenect_device
*dev,
void
*video, uint32_t timestamp);
388
395
FREENECTAPI
void
freenect_set_depth_callback
(
freenect_device
*dev,
freenect_depth_cb
cb);
396
403
FREENECTAPI
void
freenect_set_video_callback
(
freenect_device
*dev,
freenect_video_cb
cb);
404
415
FREENECTAPI
int
freenect_set_depth_buffer
(
freenect_device
*dev,
void
*buf);
416
427
FREENECTAPI
int
freenect_set_video_buffer
(
freenect_device
*dev,
void
*buf);
428
436
FREENECTAPI
int
freenect_start_depth
(
freenect_device
*dev);
437
445
FREENECTAPI
int
freenect_start_video
(
freenect_device
*dev);
446
454
FREENECTAPI
int
freenect_stop_depth
(
freenect_device
*dev);
455
463
FREENECTAPI
int
freenect_stop_video
(
freenect_device
*dev);
464
474
FREENECTAPI
int
freenect_update_tilt_state
(
freenect_device
*dev);
475
483
FREENECTAPI
freenect_raw_tilt_state
*
freenect_get_tilt_state
(
freenect_device
*dev);
484
492
FREENECTAPI
double
freenect_get_tilt_degs
(
freenect_raw_tilt_state
*state);
493
506
FREENECTAPI
int
freenect_set_tilt_degs
(
freenect_device
*dev,
double
angle);
507
516
FREENECTAPI
freenect_tilt_status_code
freenect_get_tilt_status
(
freenect_raw_tilt_state
*state);
517
527
FREENECTAPI
int
freenect_set_led
(
freenect_device
*dev,
freenect_led_options
option);
528
540
FREENECTAPI
void
freenect_get_mks_accel
(
freenect_raw_tilt_state
*state,
double
* x,
double
* y,
double
* z);
541
547
FREENECTAPI
int
freenect_get_video_mode_count
();
548
557
FREENECTAPI
freenect_frame_mode
freenect_get_video_mode
(
int
mode_num);
558
567
FREENECTAPI
freenect_frame_mode
freenect_get_current_video_mode
(
freenect_device
*dev);
568
578
FREENECTAPI
freenect_frame_mode
freenect_find_video_mode
(
freenect_resolution
res,
freenect_video_format
fmt);
579
592
FREENECTAPI
int
freenect_set_video_mode
(
freenect_device
* dev,
freenect_frame_mode
mode);
593
599
FREENECTAPI
int
freenect_get_depth_mode_count
();
600
609
FREENECTAPI
freenect_frame_mode
freenect_get_depth_mode
(
int
mode_num);
610
619
FREENECTAPI
freenect_frame_mode
freenect_get_current_depth_mode
(
freenect_device
*dev);
620
630
FREENECTAPI
freenect_frame_mode
freenect_find_depth_mode
(
freenect_resolution
res,
freenect_depth_format
fmt);
631
641
FREENECTAPI
int
freenect_set_depth_mode
(
freenect_device
* dev,
const
freenect_frame_mode
mode);
642
651
FREENECTAPI
int
freenect_set_flag
(
freenect_device
*dev,
freenect_flag
flag,
freenect_flag_value
value);
652
653
#ifdef __cplusplus
654
}
655
#endif
Generated on Fri Nov 1 2013 19:57:08 for libfreenect by
1.8.4