ruby-freenect 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gems +12 -0
- data/.rvmrc +1 -0
- data/LICENSE.txt +23 -0
- data/README.rdoc +204 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/examples/depth.rb +31 -0
- data/examples/ir.rb +31 -0
- data/examples/kinect.rb +29 -0
- data/examples/led.rb +21 -0
- data/examples/tilt.rb +17 -0
- data/examples/tools.rb +69 -0
- data/examples/video.rb +32 -0
- data/freenect4r.gemspec +61 -0
- data/lib/freenect.rb +4 -0
- data/lib/freenect/driver.rb +477 -0
- data/lib/freenect/freenect.rb +149 -0
- data/ruby-freenect.gemspec +56 -0
- metadata +80 -0
data/examples/video.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib")) << File.expand_path(File.dirname(__FILE__))
|
2
|
+
require 'rubygems'
|
3
|
+
require 'freenect'
|
4
|
+
require 'tools'
|
5
|
+
require 'opengl'
|
6
|
+
include Gl,Glu,Glut
|
7
|
+
|
8
|
+
puts "#{Freenect.get_device_count} Kinect found"
|
9
|
+
video_mode = Freenect.find_video_mode(:freenect_video_rgb)
|
10
|
+
|
11
|
+
display = lambda do
|
12
|
+
video_buffer = Freenect.get_video(video_mode)
|
13
|
+
glPixelZoom(1.0, -1.0)
|
14
|
+
glRasterPos2i(-1, 1)
|
15
|
+
glDrawPixels(video_mode[:width], video_mode[:height], GL_RGB, GL_UNSIGNED_BYTE, video_buffer)
|
16
|
+
glutSwapBuffers()
|
17
|
+
end
|
18
|
+
|
19
|
+
glutInit
|
20
|
+
glutInitWindowSize(video_mode[:width], video_mode[:height])
|
21
|
+
glutInitWindowPosition(100, 100)
|
22
|
+
glutCreateWindow($0)
|
23
|
+
|
24
|
+
glutDisplayFunc(display)
|
25
|
+
glutIdleFunc(display)
|
26
|
+
glutKeyboardFunc(sync_keyboard)
|
27
|
+
|
28
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
29
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
30
|
+
|
31
|
+
glutMainLoop
|
32
|
+
|
data/freenect4r.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "freenect4r"
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Troy Stribling"]
|
12
|
+
s.date = "2011-12-19"
|
13
|
+
s.description = "Ruby bindings for the libfreenect Kinect driver"
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE.txt",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".rvmrc",
|
20
|
+
"History.txt",
|
21
|
+
"LICENSE.txt",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"examples/glview.rb",
|
26
|
+
"examples/ir_view.rb",
|
27
|
+
"examples/record.rb",
|
28
|
+
"examples/tilt_led.rb",
|
29
|
+
"examples/tilt_nod.rb",
|
30
|
+
"examples/video_opengl.rb",
|
31
|
+
"examples/video_snapshot.rb",
|
32
|
+
"lib/freenect.rb",
|
33
|
+
"lib/freenect/context.rb",
|
34
|
+
"lib/freenect/device.rb",
|
35
|
+
"lib/freenect/freenect.rb",
|
36
|
+
"lib/freenect/sync.rb",
|
37
|
+
"spec/context_spec.rb",
|
38
|
+
"spec/device_spec.rb",
|
39
|
+
"spec/freenect_spec.rb",
|
40
|
+
"spec/spec.opts",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
s.homepage = "https://github.com/troystribling/freenect4r"
|
44
|
+
s.rdoc_options = ["--title", "FFI Freenect", "--main", "README.rdoc", "--line-numbers"]
|
45
|
+
s.require_paths = ["lib"]
|
46
|
+
s.rubygems_version = "1.8.10"
|
47
|
+
s.summary = "Ruby bindings for the libfreenect Kinect driver"
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<ffi>, [">= 1.0.11"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<ffi>, [">= 1.0.11"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<ffi>, [">= 1.0.11"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
data/lib/freenect.rb
ADDED
@@ -0,0 +1,477 @@
|
|
1
|
+
module Freenect
|
2
|
+
module Driver
|
3
|
+
|
4
|
+
extend FFI::Library
|
5
|
+
ffi_lib 'freenect', 'freenect_sync'
|
6
|
+
|
7
|
+
# Ticks per G for accelerometer as set per http://www.kionix.com/Product%20Sheets/KXSD9%20Product%20Brief.pdf
|
8
|
+
FREENECT_COUNTS_PER_G = 819
|
9
|
+
|
10
|
+
# Flags representing devices to open when freenect_open_device() is called.
|
11
|
+
# In particular, this allows libfreenect to grab only a subset of the devices
|
12
|
+
# in the Kinect, so you could (for instance) use libfreenect to handle audio
|
13
|
+
# and motor support while letting OpenNI have access to the cameras.
|
14
|
+
# If a device is not supported on a particular platform, its flag will be ignored.
|
15
|
+
FREENECT_DEVICE_FLAGS = enum(
|
16
|
+
:freenect_device_motor, 0x01,
|
17
|
+
:freenect_device_camaers, 0x02,
|
18
|
+
:freenect_device_audio, 0x04
|
19
|
+
)
|
20
|
+
|
21
|
+
# Enumeration of available resolutions.
|
22
|
+
# Not all available resolutions are actually supported for all video formats.
|
23
|
+
# Frame modes may not perfectly match resolutions. For instance,
|
24
|
+
# FREENECT_RESOLUTION_MEDIUM is 640x488 for the IR camera.
|
25
|
+
FREENECT_RESOLUTION = enum(
|
26
|
+
:freenect_resolution_low, 0, # QVGA - 320x240
|
27
|
+
:freenect_resolution_medium, 1, # VGA - 640x480
|
28
|
+
:freenect_resolution_high, 2, # SXGA - 1280x1024
|
29
|
+
:freenect_resolution_dummy, 2147483647 # Dummy value to force enum to be 32 bits wide
|
30
|
+
)
|
31
|
+
|
32
|
+
# Enumeration of video frame information states.
|
33
|
+
# See http://openkinect.org/wiki/Protocol_Documentation#RGB_Camera for more information.
|
34
|
+
FREENECT_VIDEO_FORMAT = enum(
|
35
|
+
:freenect_video_rgb, 0, # Decompressed RGB mode (demosaicing done by libfreenect)
|
36
|
+
:freenect_video_bayer, 1, # Bayer compressed mode (raw information from camera)
|
37
|
+
:freenect_video_ir_8bit, 2, # 8-bit IR mode
|
38
|
+
:freenect_video_ir_10bit, 3, # 10-bit IR mode
|
39
|
+
:freenect_video_ir_10bit_packed, 4, # 10-bit packed IR mode
|
40
|
+
:freenect_video_yuv_rgb, 5, # YUV RGB mode
|
41
|
+
:freenect_video_yuv_raw, 6, # YUV Raw mode
|
42
|
+
:freenect_video_dummy, 2147483647 # Dummy value to force enum to be 32 bits wide
|
43
|
+
)
|
44
|
+
|
45
|
+
# Enumeration of depth frame states
|
46
|
+
# See http://openkinect.org/wiki/Protocol_Documentation#RGB_Camera for more information.
|
47
|
+
FREENECT_DEPTH_FORMAT = enum(
|
48
|
+
:freenect_depth_11bit, 0, # 11 bit depth information in one uint16_t/pixel
|
49
|
+
:freenect_depth_10bit, 1, # 10 bit depth information in one uint16_t/pixel
|
50
|
+
:freenect_depth_11bit_packed, 2, # 11 bit packed depth information
|
51
|
+
:freenect_depth_10bit_packed, 3, # 10 bit packed depth information
|
52
|
+
:freenet_depth_dummy, 2147483647 # Dummy value to force enum to be 32 bits wide
|
53
|
+
)
|
54
|
+
|
55
|
+
# Structure to give information about the width, height, bitrate,
|
56
|
+
# framerate, and buffer size of a frame in a particular mode, as
|
57
|
+
# well as the total number of bytes needed to hold a single frame.
|
58
|
+
class FreenectFormat < FFI::Union
|
59
|
+
layout :dummy, :int16_t,
|
60
|
+
:video_format, FREENECT_VIDEO_FORMAT,
|
61
|
+
:depth_format, FREENECT_DEPTH_FORMAT
|
62
|
+
end
|
63
|
+
class FreenectFrameMode < FFI::Struct
|
64
|
+
layout :reserved, :uint32, # unique ID used internally. The meaning of values may change without notice.
|
65
|
+
# Don't touch or depend on the contents of this field. We mean it.
|
66
|
+
:resolution, FREENECT_RESOLUTION, # Resolution this freenect_frame_mode describes, should you want to find it again with freenect_find_*_frame_mode().
|
67
|
+
:format, FreenectFormat, # The video or depth format that this freenect_frame_mode describes. The caller should know which of video_format or
|
68
|
+
# depth_format to use, since they called freenect_get_*_frame_mode()
|
69
|
+
:bytes, :int32_t, # Total buffer size in bytes to hold a single frame of data. Should be equivalent to width * height *
|
70
|
+
# (data_bits_per_pixel+padding_bits_per_pixel) / 8
|
71
|
+
:width, :int16_t, # Width of the frame, in pixels
|
72
|
+
:height, :int16_t, # Height of the frame, in pixels
|
73
|
+
:data_bits_per_pixel, :int8_t, # Number of bits of information needed for each pixel
|
74
|
+
:padding_bits_per_pixel, :int8_t, # Number of bits of padding for alignment used for each pixel
|
75
|
+
:framerate, :int8_t, # Approximate expected frame rate, in Hz
|
76
|
+
:is_valid, :int8_t # If 0, this freenect_frame_mode is invalid and does not describe a supported mode. Otherwise, the frame_mode is valid.
|
77
|
+
end
|
78
|
+
|
79
|
+
# Enumeration of LED states
|
80
|
+
# See http://openkinect.org/wiki/Protocol_Documentation#Setting_LED for more information.
|
81
|
+
FREENECT_LED_OPTIONS = enum(
|
82
|
+
:led_off, 0, # Turn LED off
|
83
|
+
:led_green, 1, # Turn LED to Green
|
84
|
+
:led_red, 2, # Turn LED to Red
|
85
|
+
:led_yellow, 3, # Turn LED to Yellow
|
86
|
+
:led_blink_green, 4, # Make LED blink Green
|
87
|
+
:led_blink_red_yellow, 6 # Make LED blink Red/Yellow
|
88
|
+
)
|
89
|
+
|
90
|
+
# Enumeration of tilt motor status
|
91
|
+
FREENECT_TILT_STATUS_CODE = enum(
|
92
|
+
:tilt_status_stopped, 0x00, # Tilt motor is stopped
|
93
|
+
:tilt_status_limit, 0x01, # Tilt motor has reached movement limit
|
94
|
+
:tilt_status_moving, 0x04 # Tilrequire 'ffi't motor is currently moving to new position
|
95
|
+
)
|
96
|
+
|
97
|
+
class FreenectRawTiltState < FFI::Struct
|
98
|
+
layout :accelerometer_x, :int16_t, # Raw accelerometer data for X-axis, see FREENECT_COUNTS_PER_G for conversion
|
99
|
+
:accelerometer_y, :int16_t, # Raw accelerometer data for Y-axis, see FREENECT_COUNTS_PER_G for conversion
|
100
|
+
:accelerometer_z, :int16_t, # Raw accelerometer data for Z-axis, see FREENECT_COUNTS_PER_G for conversion
|
101
|
+
:tilt_angle, :int8_t, # Raw tilt motor angle encoder information
|
102
|
+
:tilt_status, FREENECT_TILT_STATUS_CODE # State of the tilt motor (stopped, moving, etc...)
|
103
|
+
end
|
104
|
+
|
105
|
+
typedef :pointer, :freenect_context # Holds information about the usb context
|
106
|
+
typedef :pointer, :freenect_device # Holds device information.
|
107
|
+
typedef :pointer, :freenect_usb_context # Holds libusb-1.0 specific information
|
108
|
+
|
109
|
+
# Enumeration of message logging levels
|
110
|
+
FREENECT_LOGLEVEL = enum(
|
111
|
+
:freenect_log_fatal, 0, # Log for crashing/non-recoverable errors
|
112
|
+
:freenect_log_error, 1, # Log for major errors
|
113
|
+
:freenect_log_warning, 2, # Log for warning messages
|
114
|
+
:freenect_log_notice, 3, # Log for important messages
|
115
|
+
:freenect_log_info, 3, # Log for normal messages
|
116
|
+
:freenect_log_debug, 5, # Log for useful development messages
|
117
|
+
:freenect_log_spew, 6, # Log for slightly less useful messages
|
118
|
+
:freenect_log_flood, 7 # Log EVERYTHING. May slow performance.
|
119
|
+
)
|
120
|
+
|
121
|
+
# Initialize a freenect context and do any setup required for
|
122
|
+
# platform specific USB libraries.
|
123
|
+
#
|
124
|
+
# @param ctx Address of pointer to freenect context struct to allocate and initialize
|
125
|
+
# @param usb_ctx USB context to initialize. Can be NULL if not using multiple contexts.
|
126
|
+
#
|
127
|
+
# @return 0 on success, < 0 on error
|
128
|
+
attach_function :freenect_init, [:freenect_context, :freenect_usb_context], :int
|
129
|
+
|
130
|
+
# Closes the device if it is open, and frees the context
|
131
|
+
#
|
132
|
+
# @param ctx freenect context to close/free
|
133
|
+
#
|
134
|
+
# @return 0 on success
|
135
|
+
attach_function :freenect_shutdown, [:freenect_context], :int
|
136
|
+
|
137
|
+
# Set the log level for the specified freenect context
|
138
|
+
#
|
139
|
+
# @param ctx context to set log level for
|
140
|
+
# @param level log level to use (see freenect_loglevel enum)
|
141
|
+
attach_function :freenect_set_log_level, [:freenect_context, FREENECT_LOGLEVEL], :void
|
142
|
+
|
143
|
+
# Callback for log messages (i.e. for rerouting to a file instead of
|
144
|
+
# stdout)
|
145
|
+
#
|
146
|
+
# @param ctx context to set log callback for
|
147
|
+
# @param cb callback function pointer
|
148
|
+
callback :freenect_log_cb, [:freenect_context, FREENECT_LOGLEVEL, :string], :void
|
149
|
+
attach_function :freenect_set_log_callback, [:freenect_context, :freenect_log_cb], :void
|
150
|
+
|
151
|
+
# Calls the platform specific usb event processor
|
152
|
+
#
|
153
|
+
# @param ctx context to process events for
|
154
|
+
#
|
155
|
+
# @return 0 on success, other values on error, platform/library dependant
|
156
|
+
attach_function :freenect_process_events, [:freenect_context], :int
|
157
|
+
|
158
|
+
# Return the number of kinect devices currently connected to the
|
159
|
+
# system
|
160
|
+
#
|
161
|
+
# @param ctx Context to access device count through
|
162
|
+
#
|
163
|
+
# @return Number of devices connected, < 0 on error
|
164
|
+
attach_function :freenect_num_devices, [:freenect_context], :int
|
165
|
+
|
166
|
+
# Set which subdevices any subsequent calls to freenect_open_device()
|
167
|
+
# should open. This will not affect devices which have already been
|
168
|
+
# opened. The default behavior, should you choose not to call this
|
169
|
+
# function at all, is to open all supported subdevices - motor, cameras,
|
170
|
+
# and audio, if supported on the platform.
|
171
|
+
#
|
172
|
+
# @param ctx Context to set future subdevice selection for
|
173
|
+
# @param subdevs Flags representing the subdevices to select
|
174
|
+
attach_function :freenect_select_subdevices, [:freenect_context, FREENECT_DEVICE_FLAGS], :void
|
175
|
+
|
176
|
+
# Opens a kinect device via a context. Index specifies the index of
|
177
|
+
# the device on the current state of the bus. Bus resets may cause
|
178
|
+
# indexes to shift.
|
179
|
+
#
|
180
|
+
# @param ctx Context to open device through
|
181
|
+
# @param dev Device structure to assign opened device to
|
182
|
+
# @param index Index of the device on the bus
|
183
|
+
#
|
184
|
+
# @return 0 on success, < 0 on error
|
185
|
+
attach_function :freenect_open_device, [:freenect_context, :freenect_device, :int], :int
|
186
|
+
|
187
|
+
# Closes a device that is currently open
|
188
|
+
#
|
189
|
+
# @param dev Device to close
|
190
|
+
#
|
191
|
+
attach_function :freenect_close_device, [:freenect_device], :int
|
192
|
+
|
193
|
+
# Set the device user data, for passing generic information into
|
194
|
+
# callbacks
|
195
|
+
#
|
196
|
+
# @param dev Device to attach user data to
|
197
|
+
# @param user User data to attach
|
198
|
+
attach_function :freenect_set_user, [:freenect_device, :pointer], :void
|
199
|
+
|
200
|
+
# Retrieve the pointer to user data from the device struct
|
201
|
+
#
|
202
|
+
# @param dev Device from which to get user data
|
203
|
+
#
|
204
|
+
# @return Pointer to user data
|
205
|
+
attach_function :freenect_get_user, [:freenect_device], :pointer
|
206
|
+
|
207
|
+
# Set callback for depth information received event
|
208
|
+
#
|
209
|
+
# @param dev Device to set callback for
|
210
|
+
# @param cb Function pointer for processing depth information
|
211
|
+
callback :freenect_depth_cb, [:freenect_device, :pointer, :uint32], :void
|
212
|
+
attach_function :freenect_set_depth_callback, [:freenect_device, :freenect_depth_cb], :void
|
213
|
+
|
214
|
+
# Set callback for video information received event
|
215
|
+
#
|
216
|
+
# @param dev Device to set callback for
|
217
|
+
# @param cb Function pointer for processing video information
|
218
|
+
callback :freenect_video_cb, [:freenect_device, :pointer, :uint32], :void
|
219
|
+
attach_function :freenect_set_video_callback, [:freenect_device, :freenect_video_cb], :void
|
220
|
+
|
221
|
+
# Set the buffer to store depth information to. Size of buffer is
|
222
|
+
# dependant on depth format. See FREENECT_DEPTH_*_SIZE defines for
|
223
|
+
# more information.
|
224
|
+
#
|
225
|
+
# @param dev Device to set depth buffer for.
|
226
|
+
# @param buf Buffer to store depth information to.
|
227
|
+
attach_function :freenect_set_depth_buffer, [:freenect_device, :pointer], :int
|
228
|
+
|
229
|
+
# Set the buffer to store depth information to. Size of buffer is
|
230
|
+
# dependant on video format. See FREENECT_VIDEO_*_SIZE defines for
|
231
|
+
# more information.
|
232
|
+
#
|
233
|
+
# @param dev Device to set video buffer for.
|
234
|
+
# @param buf Buffer to store video information to.
|
235
|
+
#
|
236
|
+
# @return 0 on success, < 0 on error
|
237
|
+
attach_function :freenect_set_video_buffer, [:freenect_device, :pointer], :int
|
238
|
+
|
239
|
+
# Start the depth information stream for a device.
|
240
|
+
#
|
241
|
+
# @param dev Device to start depth information stream for.
|
242
|
+
#
|
243
|
+
# @return 0 on success, < 0 on error
|
244
|
+
attach_function :freenect_start_depth, [:freenect_device], :int
|
245
|
+
|
246
|
+
# Start the video information stream for a device.
|
247
|
+
#
|
248
|
+
# @param dev Device to start video information stream for.
|
249
|
+
#
|
250
|
+
# @return 0 on success, < 0 on error
|
251
|
+
attach_function :freenect_start_video, [:freenect_device], :int
|
252
|
+
|
253
|
+
# Stop the depth information stream for a device
|
254
|
+
#
|
255
|
+
# @param dev Device to stop depth information stream on.
|
256
|
+
#
|
257
|
+
# @return 0 on success, < 0 on error
|
258
|
+
attach_function :freenect_stop_depth, [:freenect_device], :int
|
259
|
+
|
260
|
+
# Stop the video information stream for a device
|
261
|
+
#
|
262
|
+
# @param dev Device to stop video information stream on.
|
263
|
+
#
|
264
|
+
# @return 0 on success, < 0 on error
|
265
|
+
attach_function :freenect_stop_video, [:freenect_device], :int
|
266
|
+
|
267
|
+
# Updates the accelerometer state using a blocking control message
|
268
|
+
# call.
|
269
|
+
#
|
270
|
+
# @param dev Device to get accelerometer data from
|
271
|
+
#
|
272
|
+
# @return 0 on success, < 0 on error. Accelerometer data stored to
|
273
|
+
# device struct.
|
274
|
+
attach_function :freenect_update_tilt_state, [:freenect_device], :int
|
275
|
+
|
276
|
+
# Retrieve the tilt state from a device
|
277
|
+
#
|
278
|
+
# @param dev Device to retrieve tilt state from
|
279
|
+
#
|
280
|
+
# @return The tilt state struct of the device
|
281
|
+
attach_function :freenect_get_tilt_state, [:freenect_device], FreenectRawTiltState
|
282
|
+
|
283
|
+
# Return the tilt state, in degrees with respect to the horizon
|
284
|
+
#
|
285
|
+
# @param state The tilt state struct from a device
|
286
|
+
#
|
287
|
+
# @return Current degree of tilt of the device
|
288
|
+
attach_function :freenect_get_tilt_degs, [FreenectRawTiltState], :double
|
289
|
+
|
290
|
+
# Set the tilt state of the device, in degrees with respect to the
|
291
|
+
# horizon. Uses blocking control message call to update
|
292
|
+
# device. Function return does not reflect state of device, device
|
293
|
+
# may still be moving to new position after the function returns. Use
|
294
|
+
# freenect_get_tilt_status() to find current movement state.
|
295
|
+
#
|
296
|
+
# @param dev Device to set tilt state
|
297
|
+
# @param angle Angle the device should tilt to
|
298
|
+
#
|
299
|
+
# @return 0 on success, < 0 on error.
|
300
|
+
attach_function :freenect_set_tilt_degs, [:freenect_device, :double], :int
|
301
|
+
|
302
|
+
# Return the movement state of the tilt motor (moving, stopped, etc...)
|
303
|
+
#
|
304
|
+
# @param state Raw state struct to get the tilt status code from
|
305
|
+
#
|
306
|
+
# @return Status code of the tilt device. See
|
307
|
+
# freenect_tilt_st:freenect_get_tilt_statusatus_code enum for more info.
|
308
|
+
attach_function :freenect_get_tilt_status, [FreenectRawTiltState], FREENECT_TILT_STATUS_CODE
|
309
|
+
|
310
|
+
# Set the state of the LED. Uses blocking control message call to
|
311
|
+
# update device.
|
312
|
+
#
|
313
|
+
# @param dev Device to set the LED state
|
314
|
+
# @param option LED state to set on device. See freenect_led_options enum.
|
315
|
+
#
|
316
|
+
# @return 0 on success, < 0 on error
|
317
|
+
attach_function :freenect_set_led, [:freenect_device, FREENECT_LED_OPTIONS], :int
|
318
|
+
|
319
|
+
# Get the frame descriptor of the current video mode for the specified
|
320
|
+
# freenect device.
|
321
|
+
#
|
322
|
+
# @param dev Which device to return the currently-set video mode for
|
323
|
+
#
|
324
|
+
# @return A freenect_frame_mode describing the current video mode of the specified device
|
325
|
+
attach_function :freenect_get_current_video_mode, [:freenect_device], FreenectFrameMode.by_value
|
326
|
+
|
327
|
+
# Get the frame descriptor of the current depth mode for the specified
|
328
|
+
# freenect device.
|
329
|
+
#
|
330
|
+
# @param dev Which device to return the currently-set depth mode for
|
331
|
+
#
|
332
|
+
# @return A freenect_frame_mode describing the current depth mode of the specified device
|
333
|
+
attach_function :freenect_get_current_depth_mode, [:freenect_device], FreenectFrameMode.by_value
|
334
|
+
|
335
|
+
# Sets the current video mode for the specified device. If the
|
336
|
+
# freenect_frame_mode specified is not one provided by the driver
|
337
|
+
# e.g. from freenect_get_video_mode() or freenect_find_video_mode()
|
338
|
+
# then behavior is undefined. The current video mode cannot be
|
339
|
+
# changed while streaming is active.
|
340
|
+
#
|
341
|
+
# @param dev Device for which to set the video mode
|
342
|
+
# @param mode Frame mode to set
|
343
|
+
#
|
344
|
+
# @return 0 on success, < 0 if error
|
345
|
+
attach_function :freenect_set_video_mode, [:freenect_device, FreenectFrameMode.by_value], :int
|
346
|
+
|
347
|
+
# Sets the current depth mode for the specified device. The mode
|
348
|
+
# cannot be changed while streaming is active.
|
349
|
+
#
|
350
|
+
# @param dev Device for which to set the depth mode
|
351
|
+
# @param mode Frame mode to set
|
352
|
+
#
|
353
|
+
# @return 0 on success, < 0 if error
|
354
|
+
attach_function :freenect_set_depth_mode, [:freenect_device, FreenectFrameMode.by_value], :int
|
355
|
+
|
356
|
+
# Get the axis-based gravity adjusted accelerometer state, as laid
|
357
|
+
# out via the accelerometer data sheet, which is available at
|
358
|
+
#
|
359
|
+
# http://www.kionix.com/Product%20Sheets/KXSD9%20Product%20Brief.pdf
|
360
|
+
#
|
361
|
+
# @param state State to extract accelerometer data from
|
362
|
+
# @param x Stores X-axis accelerometer state
|
363
|
+
# @param y Stores Y-axis accelerometer state
|
364
|
+
# @param z Stores Z-axis accelerometer state
|
365
|
+
attach_function :freenect_get_mks_accel, [FreenectRawTiltState, :pointer, :pointer, :pointer], :void
|
366
|
+
|
367
|
+
# Get the number of video camera modes supported by the driver. This includes both RGB and IR modes.
|
368
|
+
#
|
369
|
+
# @return Number of video modes supported by the driver
|
370
|
+
attach_function :freenect_get_video_mode_count, [], :int
|
371
|
+
|
372
|
+
# Get the frame descriptor of the nth supported video mode for the
|
373
|
+
# video camera.
|
374
|
+
#
|
375
|
+
# @param n Which of the supported modes to return information about
|
376
|
+
#
|
377
|
+
# @return A freenect_frame_mode describing the nth video mode
|
378
|
+
attach_function :freenect_get_video_mode, [:int], FreenectFrameMode.by_value
|
379
|
+
|
380
|
+
# Get the number of depth camera modes supported by the driver. This includes both RGB and IR modes.
|
381
|
+
#
|
382
|
+
# @return Number of depth modes supported by the driver
|
383
|
+
attach_function :freenect_get_depth_mode_count, [], :int
|
384
|
+
|
385
|
+
# Get the frame descriptor of the nth supported depth mode for the
|
386
|
+
# depth camera.
|
387
|
+
#
|
388
|
+
# @param n Which of the supported modes to return information about
|
389
|
+
#
|
390
|
+
# @return A freenect_frame_mode describing the nth depth mode
|
391
|
+
attach_function :freenect_get_depth_mode, [:int], FreenectFrameMode.by_value
|
392
|
+
|
393
|
+
# Convenience function to return a mode descriptor matching the
|
394
|
+
# specified resolution and video camera pixel format, if one exists.
|
395
|
+
#
|
396
|
+
# @param res Resolution desired
|
397
|
+
# @param fmt Pixel format desired
|
398
|
+
#
|
399
|
+
# @return A freenect_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect_frame_mode.
|
400
|
+
attach_function :freenect_find_video_mode, [FREENECT_RESOLUTION, FREENECT_VIDEO_FORMAT], FreenectFrameMode.by_value
|
401
|
+
|
402
|
+
# Convenience function to return a mode descriptor matching the
|
403
|
+
# specified resolution and depth camera pixel format, if one exists.
|
404
|
+
#
|
405
|
+
# @param res Resolution desired
|
406
|
+
# @param fmt Pixel format desired
|
407
|
+
#
|
408
|
+
# @return A freenect_frame_mode that matches the arguments specified, if such a valid mode exists; otherwise, an invalid freenect_frame_mode.
|
409
|
+
attach_function :freenect_find_depth_mode, [FREENECT_RESOLUTION, FREENECT_DEPTH_FORMAT], FreenectFrameMode.by_value
|
410
|
+
|
411
|
+
# Synchronous video function, starts the runloop if it isn't running
|
412
|
+
#
|
413
|
+
# The returned buffer is valid until this function is called again, after which the buffer must not
|
414
|
+
# be used again. Make a copy if the data is required.
|
415
|
+
#
|
416
|
+
# Args:
|
417
|
+
# video: Populated with a pointer to a video buffer with a size of the requested type
|
418
|
+
# timestamp: Populated with the associated timestamp
|
419
|
+
# index: Device index (0 is the first)
|
420
|
+
# fmt: Valid format
|
421
|
+
#
|
422
|
+
# Returns:
|
423
|
+
# Nonzero on error.
|
424
|
+
attach_function :freenect_sync_get_video, [:pointer, :pointer, :int, FREENECT_VIDEO_FORMAT], :int
|
425
|
+
|
426
|
+
# Synchronous depth function, starts the runloop if it isn't running
|
427
|
+
#
|
428
|
+
# The returned buffer is valid until this function is called again, after which the buffer must not
|
429
|
+
# be used again. Make a copy if the data is required.
|
430
|
+
#
|
431
|
+
# Args:
|
432
|
+
# depth: Populated with a pointer to a depth buffer with a size of the requested type
|
433
|
+
# timestamp: Populated with the associated timestamp
|
434
|
+
# index: Device index (0 is the first)
|
435
|
+
# fmt: Valid format
|
436
|
+
#
|
437
|
+
# Returns:
|
438
|
+
# Nonzero on error.
|
439
|
+
attach_function :freenect_sync_get_depth, [:pointer, :pointer, :int, FREENECT_VIDEO_FORMAT], :int
|
440
|
+
|
441
|
+
# Tilt function, starts the runloop if it isn't running
|
442
|
+
#
|
443
|
+
# Args:
|
444
|
+
# angle: Set the angle to tilt the device
|
445
|
+
# index: Device index (0 is the first)
|
446
|
+
#
|
447
|
+
# Returns:
|
448
|
+
# Nonzero on error.
|
449
|
+
attach_function :freenect_sync_set_tilt_degs, [:int, :int], :int
|
450
|
+
|
451
|
+
# Tilt state function, starts the runloop if it isn't running
|
452
|
+
#
|
453
|
+
# Args:
|
454
|
+
# state: Populated with an updated tilt state pointer
|
455
|
+
# index: Device index (0 is the first)
|
456
|
+
#
|
457
|
+
# Returns:
|
458
|
+
# Nonzero on error.
|
459
|
+
attach_function :freenect_sync_get_tilt_state, [:pointer, :int], :int
|
460
|
+
|
461
|
+
# Led function, starts the runloop if it isn't running
|
462
|
+
#
|
463
|
+
# Args:
|
464
|
+
# led: The LED state to set the device to
|
465
|
+
# index: Device index (0 is the first)
|
466
|
+
#
|
467
|
+
# Returns:
|
468
|
+
# Nonzero on error.
|
469
|
+
attach_function :freenect_sync_set_led, [FREENECT_LED_OPTIONS, :int], :int
|
470
|
+
|
471
|
+
# Stops the runloop if it is running
|
472
|
+
attach_function :freenect_sync_stop, [], :void
|
473
|
+
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
|