0.0
No release in over a year
Allows for capturing images easily
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 4.0
 Project Readme

Framegrabber

This gem uses OpenCV to grab an image from a camera.

It's meant to replace a dozen of difficult to execute setups for grabbing images and uses much newer OpenCV than ruby-opencv.

Prerequisites

Framegrabber relies only on OpenCV, however it can use RMagick's Image format if it is included, which in turn uses ImageMagick.

OpenCV

macOS:

$ brew install opencv

Ubuntu/Debian:

$ sudo apt install libopencv-dev

It should work with other *nix systems if OpenCV is available.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add framegrabber

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install framegrabber

Usage

def grab_a_nice_image
  # Open a camera, camera ids are numbered starting with 0.
  # We support only one camera at a time.
  # You can call this once and grab multiple frames 
  # before you close it.
  Framegrabber.open(0)

  # Array of arrays of RGB values for pixels
  @rgb = Framegrabber.grab_frame

  # RMagick's Image object
  @image = Framegrabber.grab_image

rescue RuntimeError => e
  
  # Camera may be unavailable or frame might be empty
  # At this point we don't have nice error handling
  puts "Oh no! #{e.message}"
ensure
  
  # Camera will stay active until it is released
  Framegrabber.release 
end

Development

Clone this repo, run bundle and rake compile.

Use bin/console to poke around and see what you can improve.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/khasinski/framegrabber. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Framegrabber project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.