# I want to detect color of vehicles ?

I am trying to make a program on recognizing color of vehicle. what method should i use?

edit retag close merge delete

Sort by ยป oldest newest most voted

Use a histogram to find the most common color in the area. The more bins you use, the harder to tell which is the most common color, but the more precise you can be as to which color.

This tutorial shows you how to use histograms to isolate colors. http://docs.opencv.org/3.1.0/da/d7f/t...

more

i manged to get a histogram for the color and it gives me H,S and V values. How can i use this value to select the color.

for an example i get H=100 ,S=29 and V=171 so how can i compare this value with a color? (how to define color ranges to compare?)

( 2016-06-09 00:02:53 -0500 )edit

This is the primary colors: https://en.wikipedia.org/wiki/Web_col...

The in-betweens get fuzzy though.

( 2016-06-09 07:41:25 -0500 )edit

how to define those colors in the code? i am stuck with that :(

( 2016-06-09 07:50:20 -0500 )edit

You see the columns on the table that have (HSV) in the description? Those are your HSV values that you are finding. Put each color in the table in as a constant, and find the one that is closest to your calculated color. For example, your color seems to be a light green.

( 2016-06-09 17:05:38 -0500 )edit

thank you!! i am actually new to this. so you are saying that make an array containing those value and find the nearest from a method like k nearest neighbor value? or is there any easy method?

( 2016-06-09 21:29:00 -0500 )edit

I would make an array with those values, and just use the sum of squared differences (c1-h1)^2+(c2-h2)^2+... to find the distance between each color and the value you get. K nearest neighbor is probably overkill.

( 2016-06-09 22:27:17 -0500 )edit

thanks mate!! :)

( 2016-06-10 10:12:49 -0500 )edit

hey, can you please give me an example code for this distance calculating. i am quite new to this.

( 2016-06-13 02:24:21 -0500 )edit

in this i have to consider multiple array as i have H,S and V values so when comparing i have to predefine colors with HSV values and compare that array with pixels color array??

( 2016-06-13 07:52:31 -0500 )edit

Official site

GitHub

Wiki

Documentation