0.0
No commit activity in last 3 years
No release in over 3 years
OpenCV is a great library for writing Computer Vision software, However, OpenCV's HSV format is different than what you would expect! This gem trys to learn HSV color range from sample images for your OpenCV program to detect color.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

~> 0.0.13
~> 1.4.0
 Project Readme

OpenCVColor

Built with 💛 and ☕ in San Francisco

OpenCV is a great library for writing Computer Vision software. However, OpenCV's HSV format is different than what you would expect! This gem trys to learn HSV color range from sample images for your OpenCV program to detect color.

Installation

Add this line to your application's Gemfile:

gem 'opencv-color'

And then execute:

$ bundle

Or install it yourself as:

$ gem install opencv-color

Usage

Usage: opencv-color [options] <sample images directory path>
    -f, --format [FORMAT]            Output format 'yaml' or 'objc', default is yaml
    -h, --help                       Show this message

Put your color sample images into the following structure:

  • color samples root directory
    • color name
      • color sample image files

See color-samples directory as example.

Run opencv-color command to extract color range data:

opencv-color <color samples root directory> > color-data.yml

The output data is a YAML dump of a Ruby Hash object:

{color name => {low: HSV color CvScalar array format, high: HSV color CvScalar array format}}

Use the data in your application, the following example uses ruby-opencv gem:

include OpenCV

colors = YAML.load(File.read('color-data.yml'))
low = CvScalar.new(*colors['blue']['low'])
high = CvScalar.new(*colors['blue']['high'])

image = IplImage.load('picture.png', CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
image.BGR2HSV.in_range(low, high)
....

Contributing

  1. Fork it ( https://github.com/xli/opencv-color/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request