Kinectaby
ruby bindings to libfreenect
Install / Use
/learn @schacon/KinectabyREADME
Kinectaby - libfreenect Ruby bindings
Kinectaby is a first pass at Ruby bindings to the amazing Kinect libfreenect driver.
INSTALLING AND RUNNING
First you need a Kinect.
Then you need to install libfreenect.
Next, you need to install rake-compiler:
$ sudo gem install rake-compiler
Then you need to get and compile this.
$ git clone git://github.com/schacon/kinectaby.git
$ cd kinectaby
$ rake compile
$ rake test
API
require 'kinectaby'
context = Kinectaby::Context.new
context.num_devices
context.shutdown
device = context.open_device(0)
# OR #
device = Kinectaby.device # will just get the first one
device.led = Kinectaby::LED_RED
device.tilt = 30 # degree tilt, from -30 to 30
device.close
# synchronous video/depth capture (i can get about 30fps)
dframe = Kinectaby::Frame.new
vframe = Kinectaby::Frame.new
while true do
puts "depth"
Kinectaby.get_depth(dframe)
puts frame.point(x, y) # 0 to 2047
puts "video"
Kinectaby.get_video(vframe)
puts frame.point(x, y)
end
OUTPUT
I'm still playing with the values I'm getting back (sorry, I'm kind of new at this), but for now the get_depth() call returns a frame with 640x480 data points, each an 11 bit value (0 to 2047, where 2047 is far away and 0 is close to the camera).
example output from the examples/viewer.rb opengl ruby script looking at the depth data:
<img src="https://img.skitch.com/20101222-ctrtp9ihkyt19rpxygpqrsh98f.jpg">and this is how to properly mount the device for optimal image capture:
<img width="400px" src="https://img.skitch.com/20101222-csk8jrt3appq2refxtnk3trc6u.jpg">That opengl script is horribly slow, once I figure out what kind of data I need from each frame, I can do it in C and process them a lot faster.
I'm still playing with the video data, but it's similar. It returns a 32-bit RGB integer value, I believe. I'll try to get an example gl script to show that off too.
TODO
So for now only synchronous data capture is possible - eventually I would like to get the async callbacks implemented as well. There are also some log calls and a log callback that should be bound. Finally, there is tilt and accelerometer data you can capture that we should be able to get. I've marked all the calls I haven't bound as 'TODO' in the kinectaby.c file. Eventually I should probably also split that out into seperate files.
CONTRIBUTING
Fork schacon/kinectaby on GitHub, make it awesomer (preferably in a branch named for the topic), send me a pull request.
AUTHORS
- Scott Chacon schacon@gmail.com
LICENSE
MIT. See LICENSE file.
Related Skills
node-connect
352.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
