1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00
Versioned fork of the OpenCV gem for Ruby
Find a file
2011-11-19 00:14:34 +09:00
examples added a SURF sample (examples/find_obj.rb) 2011-08-22 23:59:19 +09:00
ext/opencv replaced rb_str_new_cstr() with rb_str_new2() for 1.8.7 2011-11-19 00:14:34 +09:00
images
setup
test fixed for Ruby 1.9.3 2011-11-03 22:25:45 +09:00
.gitignore fixed an installation problem when using bundler 2011-07-26 21:53:33 +09:00
extconf.rb modified extconf.rb for environments that OpenCV is installed in non-default directory 2011-07-11 00:32:39 +09:00
Gemfile
Gemfile.lock updated Gemfile.lock 2011-08-12 16:23:26 +09:00
History.txt
License.txt
Manifest.txt removed CvSet 2011-08-12 16:13:03 +09:00
opencv.gemspec removed CvSet 2011-08-12 16:13:03 +09:00
Rakefile
README.rdoc fixed for Ruby 1.9.3 2011-11-03 22:25:45 +09:00

= OpenCV

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

* OpenCV project home http://opencv.willowgarage.com/wiki/
  * Download http://sourceforge.net/projects/opencvlibrary/
* Ruby/OpenCV original author's web page http://blueruby.mydns.jp/opencv

== DESCRIPTION:

OpenCV wrapper for Ruby

== FEATURES/PROBLEMS:

* Some OpenCV functions are wrapped.
* Ruby 1.8.7, 1.9.3 and OpenCV 2.3 are supported.

== DEPENDENCIES:

* OpenCV (required)
Ruby/OpenCV relies on the OpenCV library.

See http://opencv.willowgarage.com/wiki/InstallGuide


* ffcall (optional)
ffcall is needed to use GUI trackbar component.
Other GUI components work without ffcall.

See http://www.haible.de/bruno/packages-ffcall.html


== INSTALLATION:
=== Install Ruby/OpenCV manually

  $ 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

*/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 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