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
{
69
struct
freenect_device_attributes
*
next
;
// Next device in the linked list
70
const
char
*
camera_serial
;
// Serial number of camera or audio subdevice
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
// arbitrary bitfields to support flag combination
116
FREENECT_MIRROR_DEPTH
= 1 << 16,
117
FREENECT_MIRROR_VIDEO
= 1 << 17,
118
FREENECT_NEAR_MODE
= 1 << 18,
// K4W only
119
}
freenect_flag
;
120
122
typedef
enum
{
123
FREENECT_OFF
= 0,
124
FREENECT_ON
= 1,
125
}
freenect_flag_value
;
126
130
typedef
struct
{
131
uint32_t
reserved
;
132
freenect_resolution
resolution
;
133
union
{
134
int32_t
dummy
;
135
freenect_video_format
video_format
;
136
freenect_depth_format
depth_format
;
137
};
138
int32_t
bytes
;
139
int16_t
width
;
140
int16_t
height
;
141
int8_t
data_bits_per_pixel
;
142
int8_t
padding_bits_per_pixel
;
143
int8_t
framerate
;
144
int8_t
is_valid
;
145
}
freenect_frame_mode
;
146
149
typedef
enum
{
150
LED_OFF
= 0,
151
LED_GREEN
= 1,
152
LED_RED
= 2,
153
LED_YELLOW
= 3,
154
LED_BLINK_GREEN
= 4,
155
// 5 is same as 4, LED blink Green
156
LED_BLINK_RED_YELLOW
= 6,
157
}
freenect_led_options
;
158
159
161
typedef
enum
{
162
TILT_STATUS_STOPPED
= 0x00,
163
TILT_STATUS_LIMIT
= 0x01,
164
TILT_STATUS_MOVING
= 0x04,
165
}
freenect_tilt_status_code
;
166
168
typedef
struct
{
169
int16_t
accelerometer_x
;
170
int16_t
accelerometer_y
;
171
int16_t
accelerometer_z
;
172
int8_t
tilt_angle
;
173
freenect_tilt_status_code
tilt_status
;
174
}
freenect_raw_tilt_state
;
175
176
struct
_freenect_context;
177
typedef
struct
_freenect_context
freenect_context
;
179
struct
_freenect_device;
180
typedef
struct
_freenect_device
freenect_device
;
182
// usb backend specific section
183
typedef
void
freenect_usb_context
;
184
//
185
187
#ifndef _WIN32
188
#define FREENECTAPI
189
#else
190
191
#ifdef __cplusplus
192
#define FREENECTAPI extern "C" __declspec(dllexport)
193
#else
194
// this is required when building from a Win32 port of gcc without being
195
// forced to compile all of the library files (.c) with g++...
196
#define FREENECTAPI __declspec(dllexport)
197
#endif
198
#endif
199
201
typedef
enum
{
202
FREENECT_LOG_FATAL
= 0,
203
FREENECT_LOG_ERROR
,
204
FREENECT_LOG_WARNING
,
205
FREENECT_LOG_NOTICE
,
206
FREENECT_LOG_INFO
,
207
FREENECT_LOG_DEBUG
,
208
FREENECT_LOG_SPEW
,
209
FREENECT_LOG_FLOOD
,
210
}
freenect_loglevel
;
211
221
FREENECTAPI
int
freenect_init
(
freenect_context
**ctx, freenect_usb_context *usb_ctx);
222
230
FREENECTAPI
int
freenect_shutdown
(
freenect_context
*ctx);
231
233
typedef
void (*
freenect_log_cb
)(
freenect_context
*dev,
freenect_loglevel
level,
const
char
*msg);
234
241
FREENECTAPI
void
freenect_set_log_level
(
freenect_context
*ctx,
freenect_loglevel
level);
242
250
FREENECTAPI
void
freenect_set_log_callback
(
freenect_context
*ctx,
freenect_log_cb
cb);
251
259
FREENECTAPI
int
freenect_process_events
(
freenect_context
*ctx);
260
271
FREENECTAPI
int
freenect_process_events_timeout
(
freenect_context
*ctx,
struct
timeval* timeout);
272
281
FREENECTAPI
int
freenect_num_devices
(
freenect_context
*ctx);
282
292
FREENECTAPI
int
freenect_list_device_attributes
(
freenect_context
*ctx,
struct
freenect_device_attributes
** attribute_list);
293
299
FREENECTAPI
void
freenect_free_device_attributes
(
struct
freenect_device_attributes
* attribute_list);
300
309
FREENECTAPI
int
freenect_supported_subdevices
(
void
);
310
321
FREENECTAPI
void
freenect_select_subdevices
(
freenect_context
*ctx,
freenect_device_flags
subdevs);
322
330
FREENECTAPI
freenect_device_flags
freenect_enabled_subdevices
(
freenect_context
*ctx);
331
343
FREENECTAPI
int
freenect_open_device
(
freenect_context
*ctx,
freenect_device
**dev,
int
index);
344
356
FREENECTAPI
int
freenect_open_device_by_camera_serial
(
freenect_context
*ctx,
freenect_device
**dev,
const
char
* camera_serial);
357
365
FREENECTAPI
int
freenect_close_device
(
freenect_device
*dev);
366
374
FREENECTAPI
void
freenect_set_user
(
freenect_device
*dev,
void
*user);
375
383
FREENECTAPI
void
*
freenect_get_user
(
freenect_device
*dev);
384
386
typedef
void (*
freenect_depth_cb
)(
freenect_device
*dev,
void
*depth, uint32_t timestamp);
388
typedef
void (*
freenect_video_cb
)(
freenect_device
*dev,
void
*video, uint32_t timestamp);
390
typedef
void (*
freenect_chunk_cb
)(
void
*buffer,
void
*pkt_data,
int
pkt_num,
int
datalen,
void
*user_data);
391
392
399
FREENECTAPI
void
freenect_set_depth_callback
(
freenect_device
*dev,
freenect_depth_cb
cb);
400
407
FREENECTAPI
void
freenect_set_video_callback
(
freenect_device
*dev,
freenect_video_cb
cb);
408
415
FREENECTAPI
void
freenect_set_depth_chunk_callback
(
freenect_device
*dev,
freenect_chunk_cb
cb);
416
423
FREENECTAPI
void
freenect_set_video_chunk_callback
(
freenect_device
*dev,
freenect_chunk_cb
cb);
424
435
FREENECTAPI
int
freenect_set_depth_buffer
(
freenect_device
*dev,
void
*buf);
436
447
FREENECTAPI
int
freenect_set_video_buffer
(
freenect_device
*dev,
void
*buf);
448
456
FREENECTAPI
int
freenect_start_depth
(
freenect_device
*dev);
457
465
FREENECTAPI
int
freenect_start_video
(
freenect_device
*dev);
466
474
FREENECTAPI
int
freenect_stop_depth
(
freenect_device
*dev);
475
483
FREENECTAPI
int
freenect_stop_video
(
freenect_device
*dev);
484
494
FREENECTAPI
int
freenect_update_tilt_state
(
freenect_device
*dev);
495
503
FREENECTAPI
freenect_raw_tilt_state
*
freenect_get_tilt_state
(
freenect_device
*dev);
504
512
FREENECTAPI
double
freenect_get_tilt_degs
(
freenect_raw_tilt_state
*state);
513
526
FREENECTAPI
int
freenect_set_tilt_degs
(
freenect_device
*dev,
double
angle);
527
536
FREENECTAPI
freenect_tilt_status_code
freenect_get_tilt_status
(
freenect_raw_tilt_state
*state);
537
547
FREENECTAPI
int
freenect_set_led
(
freenect_device
*dev,
freenect_led_options
option);
548
560
FREENECTAPI
void
freenect_get_mks_accel
(
freenect_raw_tilt_state
*state,
double
* x,
double
* y,
double
* z);
561
567
FREENECTAPI
int
freenect_get_video_mode_count
();
568
577
FREENECTAPI
freenect_frame_mode
freenect_get_video_mode
(
int
mode_num);
578
587
FREENECTAPI
freenect_frame_mode
freenect_get_current_video_mode
(
freenect_device
*dev);
588
598
FREENECTAPI
freenect_frame_mode
freenect_find_video_mode
(
freenect_resolution
res,
freenect_video_format
fmt);
599
612
FREENECTAPI
int
freenect_set_video_mode
(
freenect_device
* dev,
freenect_frame_mode
mode);
613
619
FREENECTAPI
int
freenect_get_depth_mode_count
();
620
629
FREENECTAPI
freenect_frame_mode
freenect_get_depth_mode
(
int
mode_num);
630
639
FREENECTAPI
freenect_frame_mode
freenect_get_current_depth_mode
(
freenect_device
*dev);
640
650
FREENECTAPI
freenect_frame_mode
freenect_find_depth_mode
(
freenect_resolution
res,
freenect_depth_format
fmt);
651
661
FREENECTAPI
int
freenect_set_depth_mode
(
freenect_device
* dev,
const
freenect_frame_mode
mode);
662
671
FREENECTAPI
int
freenect_set_flag
(
freenect_device
*dev,
freenect_flag
flag,
freenect_flag_value
value);
672
680
FREENECTAPI
int
freenect_get_ir_brightness
(
freenect_device
*dev);
681
690
FREENECTAPI
int
freenect_set_ir_brightness
(
freenect_device
*dev, uint16_t brightness);
691
699
FREENECTAPI
void
freenect_set_fw_address_nui
(
freenect_context
* ctx,
unsigned
char
* fw_ptr,
unsigned
int
num_bytes);
700
708
FREENECTAPI
void
freenect_set_fw_address_k4w
(
freenect_context
* ctx,
unsigned
char
* fw_ptr,
unsigned
int
num_bytes);
709
710
711
#ifdef __cplusplus
712
}
713
#endif
Generated on Wed Apr 29 2015 15:19:20 for libfreenect by
1.8.4