I have following imaged, preprocessed with certain OpenCV functions:
Now I'm trying to get the number of bricks of each color (in this case 1 for every color). These are all colors I have.
My plan was to loop through all colors, use the OpenCV function "inRange" and get the area size. My problem is to recognize the different colors. I tried the red color and struggled on finding a good range. After asking google I understood, that I have to use HSV colors, to get a good range with the hue value.
So I wrote this code (in Java for some reason):
Mat img; //img is given from previos code
Mat hsv = img.clone();
Imgproc.cvtColor(img, hsv, Imgproc.COLOR_BGR2HSV);
After this I expected to have an image, with which I can get the different colors. In fact I got this:
In this image the colors are almost destroyed...red and light green look the same and other colors are completely different too.
Now my question: Do I something wrong? Is it possible to distinguish the Lego brick colors? What can I do to achieve this? I'm using OpenCV 3.1.0 for Java.
Thanks alot, Dennis