Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

wappers/ruby: Updated to use new frame mode code.

Signed-off-by: Alex Weiss <algrs@cacography.net>
  • Loading branch information...
commit 6b21e4128414d62663ea3bfc05f927884ea61bbd 1 parent 4e6f165
Alex Weiss authored
52 wrappers/ruby/ffi-libfreenect/lib/freenect/device.rb
@@ -132,39 +132,35 @@ def stop_video
132 132 end
133 133 end
134 134
135   - def set_depth_format(fmt)
136   - l_fmt = fmt.is_a?(Numeric)? fmt : Freenect::DEPTH_FORMATS[fmt]
137   - ret = ::FFI::Freenect.freenect_set_depth_format(self.device, l_fmt)
138   - if (ret== 0)
139   - @depth_format = fmt
140   - else
141   - raise DeviceError, "Error calling freenect_set_depth_format(self, #{fmt})"
142   - end
143   - end
144   -
145   - alias depth_format= set_depth_format
146   -
  135 + def set_depth_mode(mode)
  136 + mode = Freenect.depth_mode(:medium, mode) unless mode.is_a?(Freenect::FrameMode)
  137 + raise ArgumentError, "Unkown depth mode #{mode}" if mode.nil?
  138 + ret = ::FFI::Freenect.freenect_set_depth_mode(self.device, mode)
  139 + raise DeviceError, "Error calling freenect_set_depth_mode(self, #{mode})" unless ret == 0
  140 + end
  141 + alias depth_mode= set_depth_mode
  142 +
147 143 # returns the symbolic constant for the current depth format
148   - def depth_format
149   - (@depth_format.is_a?(Numeric))? Freenect::DEPTH_FORMATS[@depth_format] : @depth_format
  144 + def depth_mode
  145 + x = ::FFI::Freenect.freenect_get_current_depth_mode(self.device)
  146 + x.frame_mode_type = :depth unless x.nil?
  147 + x
150 148 end
151 149
152 150 # Sets the video format to one of the following accepted values:
153 151 #
154   - def set_video_format(fmt)
155   - l_fmt = fmt.is_a?(Numeric)? fmt : Freenect::VIDEO_FORMATS[fmt]
156   - ret = ::FFI::Freenect.freenect_set_video_format(self.device, l_fmt)
157   - if (ret== 0)
158   - @video_format = fmt
159   - else
160   - raise DeviceError, "Error calling freenect_set_video_format(self, #{fmt})"
161   - end
162   - end
163   -
164   - alias video_format= set_video_format
165   -
166   - def video_format
167   - (@video_format.is_a?(Numeric))? ::Freenect::VIDEO_FORMATS[@video_format] : @video_format
  152 + def set_video_mode(mode)
  153 + mode = Freenect.video_mode(:medium, mode) unless mode.is_a?(Freenect::FrameMode)
  154 + raise ArgumentError, "Unkown video mode #{mode}" if mode.nil?
  155 + ret = ::FFI::Freenect.freenect_set_video_mode(self.device, mode)
  156 + raise DeviceError, "Error calling freenect_set_video_mode(self, #{mode})" unless ret == 0
  157 + end
  158 + alias video_mode= set_video_mode
  159 +
  160 + def video_mode
  161 + x = ::FFI::Freenect.freenect_get_current_video_mode(self.device)
  162 + x.frame_mode_type = :video unless x.nil?
  163 + x
168 164 end
169 165
170 166 # Sets the led to one of the following accepted values:
21 wrappers/ruby/ffi-libfreenect/spec/device_spec.rb
@@ -69,20 +69,21 @@
69 69 end
70 70
71 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
  72 + @dev.video_mode.should be_nil # at first
  73 + @dev.video_mode = Freenect.video_mode(:medium, :bayer)
  74 + @dev.video_mode.format.should == :bayer
  75 + @dev.video_mode = Freenect.video_mode(:medium, :rgb)
  76 + @dev.video_mode.format.should == :rgb
  77 + @dev.video_mode.frame_mode_type.shoud == :video
77 78 end
78 79
79 80
80 81 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
  82 + @dev.depth_mode.should be_nil # at first
  83 + @dev.depth_mode = :depth_10bit
  84 + @dev.depth_mode.should == :depth_10bit
  85 + @dev.depth_mode = Freenect::DEPTH_11BIT
  86 + @dev.depth_mode = :depth_11bit
86 87 end
87 88
88 89 it "should allow itself to be looked up by it's object reference ID" do

0 comments on commit 6b21e41

Please sign in to comment.
Something went wrong with that request. Please try again.