Malfist Malfist - 3 months ago 27
Ruby Question

Grabbing snapshots from webcams in ruby

How can I take snapshots from a webcam in ruby? I know the webcam device is on /dev/video0, but how do I get a picture from it?


I'm the developer of Hornetseye. You can capture images with the V4L2-interface of HornetsEye as follows.

require 'rubygems'
require 'hornetseye_v4l2'
require 'hornetseye_xorg'
require 'hornetseye_rmagick'
include Hornetseye
input = '/dev/video0'
img = { }
img.to_ubytergb.save_ubytergb 'test.png'

Currently supported colourspaces are UYVY, YUYV, YUV420, GREY, RGB24. Note that other colourspaces such as MJPEG are not supported at the moment.