ffi-libfreenect 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/LICENSE.txt +23 -0
- data/README.rdoc +86 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/examples/record.rb +76 -0
- data/examples/tilt_led.rb +105 -0
- data/examples/tilt_nod.rb +28 -0
- data/examples/video_snapshot.rb +61 -0
- data/lib/ffi/freenect.rb +170 -0
- data/lib/freenect.rb +40 -0
- data/lib/freenect/context.rb +66 -0
- data/lib/freenect/device.rb +210 -0
- data/lib/freenect/sync.rb +93 -0
- data/spec/context_spec.rb +61 -0
- data/spec/device_spec.rb +97 -0
- data/spec/freenect_spec.rb +90 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +11 -0
- metadata +113 -0
data/spec/device_spec.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Freenect::Device do
|
5
|
+
before(:all) do
|
6
|
+
@ctx = Freenect.init()
|
7
|
+
@dev = @ctx.open_device(0)
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
@dev.set_tilt_degrees(0) if @dev
|
12
|
+
@dev.set_led(:off) if @dev
|
13
|
+
@dev.close if @dev
|
14
|
+
@ctx.close if @ctx
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should indicate whether it is in a closed state" do
|
18
|
+
@dev.should_not be_closed
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should retain a reference to its parent context" do
|
22
|
+
ctx = @dev.context()
|
23
|
+
ctx.should_not be_nil
|
24
|
+
ctx.should be_kind_of(Freenect::Context)
|
25
|
+
ctx.should == @ctx
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should indicate its current tilt state" do
|
29
|
+
tilt_state = @dev.tilt_state
|
30
|
+
tilt_state.should be_kind_of(Freenect::RawTiltState)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should indicate it's current tilt angle" do
|
34
|
+
tilt_angle = @dev.tilt
|
35
|
+
((-30)..(30)).should be_include tilt_angle
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
it "should allow the tilt angle to be set" do
|
40
|
+
@dev.tilt = 0
|
41
|
+
sleep 1
|
42
|
+
@dev.tilt.should == 0
|
43
|
+
|
44
|
+
@dev.tilt = 10
|
45
|
+
pending "calibration reversing?"
|
46
|
+
sleep 1
|
47
|
+
@dev.tilt.should > 0
|
48
|
+
@dev.tilt = 0
|
49
|
+
sleep 1
|
50
|
+
@dev.tilt.should == 0
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should allow the led to be set using symbols or numeric constants" do
|
54
|
+
(@dev.led = :off).should be_true
|
55
|
+
(@dev.led = :red).should be_true
|
56
|
+
(@dev.led = :yellow).should be_true
|
57
|
+
(@dev.led = :green).should be_true
|
58
|
+
(@dev.led = :blink_green).should be_true
|
59
|
+
(@dev.led = :blink_yellow).should be_true
|
60
|
+
(@dev.led = :blink_red_yellow).should be_true
|
61
|
+
|
62
|
+
(@dev.led = Freenect::LED_OFF).should be_true
|
63
|
+
(@dev.led = Freenect::LED_GREEN).should be_true
|
64
|
+
(@dev.led = Freenect::LED_RED).should be_true
|
65
|
+
(@dev.led = Freenect::LED_YELLOW).should be_true
|
66
|
+
(@dev.led = Freenect::LED_BLINK_YELLOW).should be_true
|
67
|
+
(@dev.led = Freenect::LED_BLINK_GREEN).should be_true
|
68
|
+
(@dev.led = Freenect::LED_BLINK_RED_YELLOW).should be_true
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should allow the video_format to be set and retrieved" do
|
72
|
+
@dev.video_format.should be_nil # at first
|
73
|
+
@dev.video_format = :bayer
|
74
|
+
@dev.video_format.should == :bayer
|
75
|
+
@dev.video_format = Freenect::VIDEO_RGB
|
76
|
+
@dev.video_format.should == :rgb
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
it "should allow the depth_format to be set and retrieved" do
|
81
|
+
@dev.depth_format.should be_nil # at first
|
82
|
+
@dev.depth_format = :depth_10bit
|
83
|
+
@dev.depth_format.should == :depth_10bit
|
84
|
+
@dev.depth_format = Freenect::DEPTH_11BIT
|
85
|
+
@dev.depth_format = :depth_11bit
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should allow itself to be looked up by it's object reference ID" do
|
89
|
+
# this isn't really on us. the test is to see if misc ruby vers behave
|
90
|
+
ObjectSpace._id2ref(@dev.object_id).should == @dev
|
91
|
+
|
92
|
+
ObjectSpace._id2ref(@dev.reference_id).should == @dev
|
93
|
+
|
94
|
+
Freenect::Device.by_reference(@dev.device).should == @dev
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Freenect do
|
4
|
+
context "singleton methods" do
|
5
|
+
|
6
|
+
it "should create a new context" do
|
7
|
+
ctx = Freenect.init()
|
8
|
+
ctx.should be_kind_of(Freenect::Context)
|
9
|
+
lambda { ctx.close }.should_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should lookup video format values" do
|
13
|
+
Freenect.lookup_video_format(:rgb).should == Freenect::VIDEO_RGB
|
14
|
+
Freenect.lookup_video_format(0).should == Freenect::VIDEO_RGB
|
15
|
+
|
16
|
+
|
17
|
+
Freenect.lookup_video_format(:bayer).should == Freenect::VIDEO_BAYER
|
18
|
+
Freenect.lookup_video_format(1).should == Freenect::VIDEO_BAYER
|
19
|
+
|
20
|
+
Freenect.lookup_video_format(:ir_8bit).should == Freenect::VIDEO_IR_8BIT
|
21
|
+
Freenect.lookup_video_format(2).should == Freenect::VIDEO_IR_8BIT
|
22
|
+
|
23
|
+
Freenect.lookup_video_format(:ir_10bit).should == Freenect::VIDEO_IR_10BIT
|
24
|
+
Freenect.lookup_video_format(3).should == Freenect::VIDEO_IR_10BIT
|
25
|
+
|
26
|
+
Freenect.lookup_video_format(:ir_10bit_packed).should == Freenect::VIDEO_IR_10BIT_PACKED
|
27
|
+
Freenect.lookup_video_format(4).should == Freenect::VIDEO_IR_10BIT_PACKED
|
28
|
+
|
29
|
+
Freenect.lookup_video_format(:yuv_rgb).should == Freenect::VIDEO_YUV_RGB
|
30
|
+
Freenect.lookup_video_format(5).should == Freenect::VIDEO_YUV_RGB
|
31
|
+
|
32
|
+
Freenect.lookup_video_format(:yuv_raw).should == Freenect::VIDEO_YUV_RAW
|
33
|
+
Freenect.lookup_video_format(6).should == Freenect::VIDEO_YUV_RAW
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should lookup video format size values" do
|
37
|
+
Freenect.lookup_video_size(:rgb).should == Freenect::RGB_SIZE
|
38
|
+
Freenect.lookup_video_size(0).should == Freenect::RGB_SIZE
|
39
|
+
|
40
|
+
Freenect.lookup_video_size(:bayer).should == Freenect::BAYER_SIZE
|
41
|
+
Freenect.lookup_video_size(1).should == Freenect::BAYER_SIZE
|
42
|
+
|
43
|
+
Freenect.lookup_video_size(:ir_8bit).should == Freenect::IR_8BIT_SIZE
|
44
|
+
Freenect.lookup_video_size(2).should == Freenect::IR_8BIT_SIZE
|
45
|
+
|
46
|
+
Freenect.lookup_video_size(:ir_10bit).should == Freenect::IR_10BIT_SIZE
|
47
|
+
Freenect.lookup_video_size(3).should == Freenect::IR_10BIT_SIZE
|
48
|
+
|
49
|
+
Freenect.lookup_video_size(:ir_10bit_packed).should == Freenect::IR_10BIT_PACKED_SIZE
|
50
|
+
Freenect.lookup_video_size(4).should == Freenect::IR_10BIT_PACKED_SIZE
|
51
|
+
|
52
|
+
Freenect.lookup_video_size(:yuv_rgb).should == Freenect::YUV_RGB_SIZE
|
53
|
+
Freenect.lookup_video_size(5).should == Freenect::YUV_RGB_SIZE
|
54
|
+
|
55
|
+
Freenect.lookup_video_size(:yuv_raw).should == Freenect::YUV_RAW_SIZE
|
56
|
+
Freenect.lookup_video_size(6).should == Freenect::YUV_RAW_SIZE
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should lookup depth format values" do
|
61
|
+
Freenect.lookup_depth_format(:depth_11bit).should == Freenect::DEPTH_11BIT
|
62
|
+
Freenect.lookup_depth_format(0).should == Freenect::DEPTH_11BIT
|
63
|
+
|
64
|
+
Freenect.lookup_depth_format(:depth_10bit).should == Freenect::DEPTH_10BIT
|
65
|
+
Freenect.lookup_depth_format(1).should == Freenect::DEPTH_10BIT
|
66
|
+
|
67
|
+
Freenect.lookup_depth_format(:depth_11bit_packed).should == Freenect::DEPTH_11BIT_PACKED
|
68
|
+
Freenect.lookup_depth_format(2).should == Freenect::DEPTH_11BIT_PACKED
|
69
|
+
|
70
|
+
Freenect.lookup_depth_format(:depth_10bit_packed).should == Freenect::DEPTH_10BIT_PACKED
|
71
|
+
Freenect.lookup_depth_format(3).should == Freenect::DEPTH_10BIT_PACKED
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should lookup depth format size values" do
|
75
|
+
Freenect.lookup_depth_size(:depth_11bit).should == Freenect::DEPTH_11BIT_SIZE
|
76
|
+
Freenect.lookup_depth_size(0).should == Freenect::DEPTH_11BIT_SIZE
|
77
|
+
|
78
|
+
Freenect.lookup_depth_size(:depth_10bit).should == Freenect::DEPTH_10BIT_SIZE
|
79
|
+
Freenect.lookup_depth_size(1).should == Freenect::DEPTH_10BIT_SIZE
|
80
|
+
|
81
|
+
Freenect.lookup_depth_size(:depth_11bit_packed).should == Freenect::DEPTH_11BIT_PACKED_SIZE
|
82
|
+
Freenect.lookup_depth_size(2).should == Freenect::DEPTH_11BIT_PACKED_SIZE
|
83
|
+
|
84
|
+
Freenect.lookup_depth_size(:depth_10bit_packed).should == Freenect::DEPTH_10BIT_PACKED_SIZE
|
85
|
+
Freenect.lookup_depth_size(3).should == Freenect::DEPTH_10BIT_PACKED_SIZE
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ffi-libfreenect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Josh Grunzweig
|
14
|
+
- Eric Monti
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-12-22 00:00:00 -06:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: ffi
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 11
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 5
|
34
|
+
- 0
|
35
|
+
version: 0.5.0
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
description: FFI bindings for the libfreenect OpenKinect library
|
39
|
+
email:
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- LICENSE.txt
|
46
|
+
- README.rdoc
|
47
|
+
files:
|
48
|
+
- History.txt
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- VERSION
|
53
|
+
- examples/record.rb
|
54
|
+
- examples/tilt_led.rb
|
55
|
+
- examples/tilt_nod.rb
|
56
|
+
- examples/video_snapshot.rb
|
57
|
+
- lib/ffi/freenect.rb
|
58
|
+
- lib/freenect.rb
|
59
|
+
- lib/freenect/context.rb
|
60
|
+
- lib/freenect/device.rb
|
61
|
+
- lib/freenect/sync.rb
|
62
|
+
- spec/context_spec.rb
|
63
|
+
- spec/device_spec.rb
|
64
|
+
- spec/freenect_spec.rb
|
65
|
+
- spec/spec.opts
|
66
|
+
- spec/spec_helper.rb
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://github.com/jgrunzweig/ffi-libfreenect
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options:
|
73
|
+
- --title
|
74
|
+
- FFI Freenect
|
75
|
+
- --main
|
76
|
+
- README.rdoc
|
77
|
+
- --line-numbers
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.3.7
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: FFI bindings for the libfreenect OpenKinect library
|
105
|
+
test_files:
|
106
|
+
- examples/record.rb
|
107
|
+
- examples/tilt_led.rb
|
108
|
+
- examples/tilt_nod.rb
|
109
|
+
- examples/video_snapshot.rb
|
110
|
+
- spec/context_spec.rb
|
111
|
+
- spec/device_spec.rb
|
112
|
+
- spec/freenect_spec.rb
|
113
|
+
- spec/spec_helper.rb
|