File: freenect.rb

package info (click to toggle)
libfreenect 1%3A0.5.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,156 kB
  • sloc: ansic: 7,417; cpp: 7,265; cs: 2,062; python: 992; ruby: 873; java: 730; xml: 49; sh: 27; makefile: 23
file content (51 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

# we may one day have a native extension for bindings... for now only 
# ffi/freenect exists
require 'ffi/freenect'
require 'freenect/context'
require 'freenect/device'

module Freenect
  include FFI::Freenect
  FrameMode = FFI::Freenect::FrameMode

  def self.init(*args)
    Context.new(*args)
  end

  def self.num_video_modes
    ::FFI::Freenect.freenect_get_video_mode_count()
  end
  def self.video_mode(a,b=nil)
    x = if a.is_a?(Numeric)
      ::FFI::Freenect.freenect_get_video_mode(a)
    else
      ::FFI::Freenect.freenect_find_video_mode(a,b)
    end
    x.frame_mode_type = :video unless x.nil?
    x
  end
  def self.video_modes
    (0...self.num_video_modes).map do |ii|
      self.video_mode(ii)
    end
  end
  
  def self.num_depth_modes
    ::FFI::Freenect.freenect_get_depth_mode_count()
  end
  def self.depth_mode(a,b=nil)
    x = if a.is_a?(Numeric)
      ::FFI::Freenect.freenect_get_depth_mode(a)
    else
      ::FFI::Freenect.freenect_find_depth_mode(a,b)
    end
    x.frame_mode_type = :depth unless x.nil?
    x
  end
  def self.depth_modes
    (0...self.num_depth_modes).map do |ii|
      self.depth_mode(ii)
    end
  end
end