dideler
3/28/2012 - 12:36 AM

ruby-processing: video capture processing example

ruby-processing: video capture processing example

#!/usr/bin/env ruby

# this is a test of ruby-processing (https://github.com/jashkenas/ruby-processing) with video capture

# use "rp5 unpack library" at a command line to install the video library, among others

# tested with Ruby 1.9.2 on OSX with built in web cam

class VideoCaptureTest < Processing::App

  load_library :video
  include_package "processing.video"
  
  def setup    
    smooth
    size(720, 576, P2D)
    @video = Capture.new(self, width, height, 30)     
  end

  def draw    
    tint(*Array.new(3) { rand(256) })
    @video.read if @video.available?
    image(@video, 0, 0)
  end
  
end