Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grabbing snapshots from webcams in ruby

Tags:

linux

ruby

webcam

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?

like image 894
Malfist Avatar asked Dec 23 '22 06:12

Malfist


2 Answers

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 = V4L2Input.new '/dev/video0'
img = X11Display.show { input.read }
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.

like image 152
wedesoft Avatar answered Dec 24 '22 20:12

wedesoft


I've never actually used it but hornetseye looks good. This question has also already been asked here

like image 24
Jamie Avatar answered Dec 24 '22 20:12

Jamie