Giter VIP home page Giter VIP logo

ruby-opencv's Introduction

OpenCV

The initial Open Computer Vision library was originally developed by Intel Corporation. Recent development has been headed by Willow Garage, Inc.

DESCRIPTION:

OpenCV wrapper for Ruby

FEATURES/PROBLEMS:

  • Some OpenCV functions are wrapped.

  • Ruby 1.8.7, 1.9.3 and OpenCV 2.3.1 are supported.

DEPENDENCIES:

  • OpenCV (required)

Ruby/OpenCV relies on the OpenCV library.

See opencv.willowgarage.com/wiki/InstallGuide

INSTALLATION:

Install Ruby/OpenCV manually

Unix/Linux/Mac

$ git clone git://github.com/ser1zw/ruby-opencv.git
$ cd ruby-opencv
$ git checkout master  # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead
$ ruby extconf.rb --with-opencv-dir=/path/to/opencvdir
$ make
$ make install

Windows (mswin32)

Use “nmake” instead of “make”.

In mswin32, OpenCV include folder and library folder are not installed in the same folder by default. You may need to specify OpenCV include folder and library folder respectively when you run extconf.rb.

$ git clone git://github.com/ser1zw/ruby-opencv.git
$ cd ruby-opencv
$ git checkout master  # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead
$ ruby extconf.rb --with-opencv-include=C:\path\to\opencvdir\build\include --with-opencv-lib=C:\path\to\opencvdir\build\x86\vc10\lib
$ nmake
$ nmake install

/path/to/opencvdir is the path you installs OpenCV library (default: /usr/local).

For example, if you install OpenCV library to /opt/local/ like:

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/local/ ./OpenCV-2.3.1
$ make
$ make install

Install Ruby/OpenCV with the following command:

$ ruby extconf.rb --with-opencv-dir=/opt/local
$ make
$ make install

Create Ruby/OpenCV Gem

You can also install this library creating a gem like:

$ git clone git://github.com/ser1zw/ruby-opencv.git
$ cd ruby-opencv
$ git checkout master  # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead
$ bundle install
$ rake gem
$ gem install pkg/opencv-*.gem -- --with-opencv-dir=/path/to/opencvdir

To add ruby-opencv in your Gemfile:

$ echo -e "\n"'gem "opencv", :git => "https://github.com/ser1zw/ruby-opencv"' >> Gemfile
$ bundle config build.opencv --with-opencv-dir=/path/to/opencvdir
$ bundle install  # or bundle update

SYNOPSIS:

Show Image using GUI Component

#!/usr/bin/env ruby
require "opencv"

image = OpenCV::IplImage.load("sample.jpg")
window = OpenCV::GUI::Window.new("preview")
window.show(image)
OpenCV::GUI::wait_key

Face Detection

Here is a sample face detection program that doesn’t rely on the GUI components. In order for this to work you must copy the OpenCV haarcascades data into a subfolder called data.

#!/usr/bin/env ruby
require "opencv"

if ARGV.length < 2
  puts "Usage: your_app_name source dest"
  exit
end

data = "./data/haarcascades/haarcascade_frontalface_alt.xml"
detector = OpenCV::CvHaarClassifierCascade::load(data)
image = OpenCV::IplImage.load(ARGV[0])
detector.detect_objects(image).each do |region|
  color = OpenCV::CvColor::Blue
  image.rectangle! region.top_left, region.bottom_right, :color => color
end
image.save_image(ARGV[1])

For more samples, see examples/*.rb

LICENSE:

The BSD Liscense

see LICENSE.txt

ruby-opencv's People

Contributors

pcting avatar ryanfb avatar ser1zw avatar thenoseman avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.