LoginSignup
13
11

More than 5 years have passed since last update.

さんじゃらっと OSX + ruby でOpenCV

Posted at

OSX + ruby でOpenCVを使ってみます。
ruby-opencvを使います

OpenCV のインストール

brew search opencv
brew tap homebrew/science
brew info opencv
brew install opencv

gemのインストール

gem install ruby-opencv

サンプルプログラム

show.rb
require 'opencv'
include OpenCV

if ARGV.size == 0
  puts "Usage: ruby #{__FILE__} ImageToLoadAndDisplay"
  exit
end

image = nil
begin
  image = CvMat.load(ARGV[0], CV_LOAD_IMAGE_COLOR) # Read the file.
rescue
  puts 'Could not open or find the image.'
  exit
end

window = GUI::Window.new('Display window') # Create a window for display.
window.show(image) # Show our image inside it.
GUI::wait_key # Wait for a keystroke in the window.

ほんで
ruby show.rb ***.jpg
とかやると、ただ画像が表示されるだけですが動作します

13
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11