🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

opencv-color

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencv-color

1.0.3
Version published
Maintainers
1
Created

OpenCVColor

Built with :yellow_heart: and :coffee: 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

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

FAQs

Package last updated on 27 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts