Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Determine If Object Is Present In An Image

Background:

We are planning to use cameras on a conveyor system to count objects. In this specific case, we can't use sensors. All of my objects are pretty consistent, and will be easy to detect if they are present in the picture. I have been looking at Aforge and some other libraries, and it seems easy enough. This is what I want to do.

That being said, I do have some concerns. The filtering process, you have to specify a color you are searching for. My object is a solid color, but we all know there could be 100+ different rgb values on the specific point im looking at.

Is there some way to search a range of colors, or to see if a color is "like" a specific color?

This is my first go at any sort of image processing. I haven't tried anything yet, just about to get started and this was a concern before I even got started.

Any help would be greatly appreciated.

like image 230
CSharpDev Avatar asked Nov 03 '22 17:11

CSharpDev


1 Answers

Instead of using the RGB color model, you can use the HSL one (Hue Saturation Light) where you can ignore the saturation and light and only check the hue parameter:

http://en.wikipedia.org/wiki/HSL_and_HSV

Here is a way to do it using c# (thanks to how to change rgb color to hsv) :

System.Drawing.Color color = System.Drawing.Color.FromArgb(red, green, blue);
float hue = color.GetHue();
float saturation = color.GetSaturation();
float lightness = color.GetBrightness();
like image 82
YohannP Avatar answered Nov 12 '22 20:11

YohannP