Class: Rupi::Camera

Inherits:
Object
  • Object
show all
Defined in:
lib/rupi/camera.rb

Constant Summary collapse

CONFIGURATION =
{
  :width      => 640,
  :height     => 480,
  :gain       => 80,
  :brightness => 80,
  :contrast   => 80,
  :saturation => 80
}

Class Method Summary collapse

Class Method Details

.capture(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rupi/camera.rb', line 18

def self.capture(options = {})
  cfg = CONFIGURATION.merge(options)

  path = options[:path]

  if path.nil?
    file = Tempfile.new('snap')
    path = file.path
  end

  command = "uvccapture -S#{cfg[:saturation]} -B#{cfg[:brightness]} -C#{cfg[:contrast]} -G#{cfg[:gain]} -x#{cfg[:width]} -y#{cfg[:height]}"

  system("#{command} -o#{path}")

  file || File.new(path)
end

.configure(options = {}) ⇒ Object



14
15
16
# File 'lib/rupi/camera.rb', line 14

def self.configure(options = {})
  CONFIGURATION.merge!(options)
end