Giter VIP home page Giter VIP logo

colordetection's Introduction

ColorDetection

This simple app allows you to create your own color detector!

I`ve watched a couple of videos on YouTube about color detection in OpenCV. Most of them were about detecting one specific color or about tracking colored objects on the video. But I've decided to make my own app to detect several colors on the video.

As an example I took traffic.mp4 from videos/ folder.

The following steps are pretty standart and you can find them in many other projects

  • Each frame if resized
  • The frame is blurred to lower the noise
  • The frame if converted from BGR to HSV format
  • Using color_range_detector (run it from command line!) I've figured out the boundaries for each of 7 colors:
    • red
    • green
    • blue
    • yellow
    • white
    • black
    • grey
  • Morphological transformation (erosion, dilation, opening, closing more about those here) is used to, again, remove all the noise from frame.
  • A color-mask is applied on the frame. As a result we get bright areas of a specific color (blue, for example) and all other colors turn black. Imagine having a picture of a blue bowling ball on the floor. After proccessing it with all the steps above, you'll get a black&white image where the ball is white and all the rest is black.
  • This is done for every color
  • The contours of the colored area are grabbed (then you can draw them of the frame, just un-comment line 31)
  • The name of the color is printed above the colored area on the frame
  • The proccessed frame is displayed to the user

IMPORTANT! Those boundaries are specific only for traffic.mp4. When using on another video you will need to search for those boundaries yourself via color_range_detector.py.

Yes, I know this is a strange way to make it work, but I couldn't find any other though. That can take you quite a long time to find correct boundaries, so be patient!

That works pretty fast even on not such powerful computers, but the accuracy is not that high (due to boundaries)


So, if you want, you can modify this code for your own needs. Good luck!


(the result)

Image alt

colordetection's People

Contributors

creestl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

colordetection's Issues

About 2 repository ColorDetection and CarCounterYolov3

Hello, your project are amazing. I really liked it and working on same. Actually I am trying to build a model which detects vehicle and its colour. You have built it separately. Can you please guide me how can I combine this two project of yours ?
Thank you.

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.