2011-01-01 07:45:24 -05:00
|
|
|
= OpenCV
|
2010-02-27 12:33:53 -05:00
|
|
|
|
|
|
|
The initial Open Computer Vision library was originally developed by Intel
|
|
|
|
Corporation. Recent development has been headed by Willow Garage, Inc.
|
|
|
|
|
2011-01-01 07:45:24 -05:00
|
|
|
OpenCV Sourceforge Project
|
2010-02-27 12:33:53 -05:00
|
|
|
http://opencv.willowgarage.com/wiki/
|
|
|
|
|
2011-01-01 07:45:24 -05:00
|
|
|
Sourceforge
|
2010-02-27 12:33:53 -05:00
|
|
|
http://sourceforge.net/projects/opencvlibrary/
|
|
|
|
|
|
|
|
Ruby/OpenCV Author's Web Page
|
|
|
|
http://blueruby.mydns.jp/opencv
|
|
|
|
|
|
|
|
== DESCRIPTION:
|
|
|
|
|
|
|
|
OpenCV Ruby Wrapper
|
|
|
|
|
|
|
|
== FEATURES/PROBLEMS:
|
|
|
|
|
|
|
|
* First release rubygems, Some OpenCV functions wrapped.
|
2011-07-04 09:16:08 -04:00
|
|
|
* Ruby 1.8.7, 1.9.2 and OpenCV 2.3 are supported.
|
2010-02-27 12:33:53 -05:00
|
|
|
|
|
|
|
== DEPENDENCIES:
|
|
|
|
|
2011-01-01 07:45:24 -05:00
|
|
|
This library relies on the OpenCV project. The following page shows how to install it:
|
2010-02-27 12:33:53 -05:00
|
|
|
|
2011-01-01 08:21:38 -05:00
|
|
|
http://opencv.willowgarage.com/wiki/InstallGuide
|
2010-02-27 12:33:53 -05:00
|
|
|
|
|
|
|
== INSTALLATION:
|
|
|
|
|
|
|
|
You can install by cloning this repository:
|
|
|
|
|
2010-12-29 13:39:15 -05:00
|
|
|
git clone git://github.com/ser1zw/ruby-opencv.git
|
2010-02-27 12:33:53 -05:00
|
|
|
|
|
|
|
Then inside the ruby-opencv folder run:
|
|
|
|
|
2011-04-07 01:25:08 -04:00
|
|
|
rake install_gem
|
|
|
|
|
2011-05-03 04:24:27 -04:00
|
|
|
Or
|
|
|
|
|
|
|
|
ruby extconf.rb
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
2011-04-07 01:25:08 -04:00
|
|
|
You can also add ruby-opencv in your Gemfile:
|
|
|
|
|
2011-04-22 12:33:21 -04:00
|
|
|
echo -e "\n"'gem "opencv", :git => "https://github.com/ser1zw/ruby-opencv"' >> Gemfile
|
2011-04-07 01:25:08 -04:00
|
|
|
bundle install # or bundle update
|
2010-02-27 12:33:53 -05:00
|
|
|
|
2011-05-31 05:03:31 -04:00
|
|
|
=== Installing ruby-opencv with all dependencies on Mac OS X using macports
|
|
|
|
|
|
|
|
sudo port install ffcall
|
|
|
|
sudo port install opencv
|
|
|
|
|
|
|
|
Follow INSTALLATION but use this command when compiling the gem:
|
|
|
|
ruby extconf.rb --with-opencv-lib=/opt/local/lib --with-opencv-include=/opt/local/include/opencv2
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
2011-06-04 04:16:45 -04:00
|
|
|
Installing ffcall might not work (that's because ffcall at the moment can't be compiled on 64bit systems).
|
2011-06-02 09:37:14 -04:00
|
|
|
That's ok.
|
|
|
|
|
2010-02-27 12:33:53 -05:00
|
|
|
== SYNOPSIS:
|
|
|
|
|
|
|
|
require "opencv"
|
|
|
|
|
|
|
|
image = OpenCV::IplImage.load("sample.jpg")
|
|
|
|
window = OpenCV::GUI::Window.new("preview")
|
|
|
|
window.show(image)
|
|
|
|
OpenCV::GUI::wait_key
|
|
|
|
|
|
|
|
For more samples, see examples/*.rb
|
|
|
|
|
|
|
|
== 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) do |region|
|
|
|
|
color = OpenCV::CvColor::Blue
|
|
|
|
image.rectangle! region.top_left, region.bottom_right, :color => color
|
|
|
|
end
|
|
|
|
image.save_image(ARGV[1])
|
|
|
|
|
|
|
|
== REQUIREMENTS:
|
|
|
|
|
2011-07-04 09:16:08 -04:00
|
|
|
* OpenCV 2.3 or later
|
2010-02-27 12:33:53 -05:00
|
|
|
http://opencv.willowgarage.com/wiki/
|
|
|
|
* ffcall (optional)
|
|
|
|
http://www.haible.de/bruno/packages-ffcall.html
|
|
|
|
|
|
|
|
== LICENSE:
|
|
|
|
|
|
|
|
The BSD Liscense
|
|
|
|
|
|
|
|
see LICENSE.txt
|