从ruby中的网络摄像头抓取快照 [英] Grabbing snapshots from webcams in ruby

查看:105
本文介绍了从ruby中的网络摄像头抓取快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从ruby的网络摄像头拍摄快照?我知道网络摄像头设备位于/dev/video0上,但是如何从中获取图片?

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?

推荐答案

我是 Hornetseye的开发人员.您可以使用HornetsEye的V4L2接口捕获图像,如下所示.

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'

当前支持的色彩空间是UYVY,YUYV,YUV420,GREY和RGB24.请注意,目前尚不支持其他色彩空间,例如MJPEG.

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

这篇关于从ruby中的网络摄像头抓取快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆