I'm thinking of building a quick and dirty script to help a friend out. It will need to take webcam input and perform very simple computation on it (think delta brightness of the pixels over time, relatively computationally simple).
I am currently leaning towards c++ like so along with opencv but I was wondering, since it's such a computationally inexpensive task, (relatively speaking of course) if there was a way to simply use ruby-opencv or some other techniques to keep it in a scripting language.
I haven't been able to find any way to import realtime webcamera images into a ruby script since I've been looking but I'd be more than happy to have my search skills proven inadequate by the wonderful SO community!
Places I've looked so far:
hornetseye
c++ script (what I'm leaning towards)
using an ffi
In summary; Is there a way to import realtime webcamera images into a ruby script to perform simple computation on them? (I was thinking with opencv but am not tied to any particular idea.
Using ruby-opencv you can capture and display camera images as follows
#!/usr/bin/env ruby
require 'opencv'
include OpenCV
FPS = 30
input = CvCapture.open
win = GUI::Window.new 'video'
loop do
img = input.query
win.show img
key = GUI.wait_key 1000 / FPS
break if key and key.chr == "\e"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With