Ask Your Question
-1

I want to detect color of vehicles ?

asked 2016-06-08 22:16:57 -0600

damiya14 gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-06-08 23:34:16 -0600

Tetragramm gravatar image

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...

edit flag offensive delete link more

Comments

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?)

damiya14 gravatar imagedamiya14 ( 2016-06-09 00:02:53 -0600 )edit

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

The in-betweens get fuzzy though.

Tetragramm gravatar imageTetragramm ( 2016-06-09 07:41:25 -0600 )edit

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

damiya14 gravatar imagedamiya14 ( 2016-06-09 07:50:20 -0600 )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.

Tetragramm gravatar imageTetragramm ( 2016-06-09 17:05:38 -0600 )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?

damiya14 gravatar imagedamiya14 ( 2016-06-09 21:29:00 -0600 )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.

Tetragramm gravatar imageTetragramm ( 2016-06-09 22:27:17 -0600 )edit

thanks mate!! :)

damiya14 gravatar imagedamiya14 ( 2016-06-10 10:12:49 -0600 )edit

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

damiya14 gravatar imagedamiya14 ( 2016-06-13 02:24:21 -0600 )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??

damiya14 gravatar imagedamiya14 ( 2016-06-13 07:52:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-08 22:16:57 -0600

Seen: 1,797 times

Last updated: Jun 08 '16