Giter VIP home page Giter VIP logo

color-detector's Introduction

SVM Color Detector

This is an OpenCV program that can detect the color of objects in an image. It was part of a school project where we had classify the color of cars in the streets, but you can also train it on your own dataset.

Installation:

You can build this project using CMake by the following commands:

mkdir build
cd build
cmake ..
make

This will compile the code into the build folder. The programs 'train' and 'test' can be simply run by

./test

The 'test' app will load a pretrained SVM modell ("modell.xml") which is already trained on identifying the color of a car. It will load a test image ("data/test.jpg") and classifies the color. Due to copyright reasons I cannot publish the training data set unfortunately.

Training your own model:

If you want to train your own model for detecting the color of an object you need to do two steps: First, you need to adjust the initClasses() method in "colorDetector.cpp". Here you need to put the names of the colors you want to train (e.g. "blue, "black"... etc.). Second, you need to put your training images into the folder data with one subfolder per class.

Then you can train the SVM by running

./train

which will save a "modell.xml". You can adjust many parameters of the algorithm and the SVM training in "colorDetector.cpp".

Algorithm:

Here you can find a short overview of how the color classification algorithm is working:

  • loading and resizing the image
  • applying contrast limited adaptive histogram equalisation (CLAHE) to the image. The yields better contrast on various illuminations
  • cropping a ROI (middle part of the image) to reduce incfluence of the background
  • color space conversion to HSV (colors are better to distinguish in this color space)
  • calculation of histogram for each color channel
  • reshaping three channel histogram to onedimensional vector
  • making the feature vector zero mean and unit variance
  • feeding the feature vector into SVM to classify color
  • the SVM was trained using a Polynomial kernel of degree two

If you have any questions feel free to write me a message :)

color-detector's People

Contributors

stefanbo92 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.