The problems of color recognition
As I stated earlier that even though getting started with color tracking and recognition was relatively easy, having it accurate is completely something else. Much of the problems I have stated below have to do with the poor camera quality and the auto-correction software which goes with it.
The webcam makes excessive amount of color correction while trying to keep the white balance within reasonable levels. Now if there are mixed lighting conditions - for example a "warm" indoor light mixing with "cold" sun light coming through windows - the white balance algorithm of the webcam doesn't know what to do subsequently confusing my color recognition as well. Unfortunately many times there's even no need for a mixed lighting conditions, yet the camera yields inconsistent color values.
While a good camera could help to limit the problem, to really overcome it, the defined color values should be dynamic in relation to the white balance in question, and the light source should be well controlled.
Even though something is blue, not all blue is the same even when looked under consistent white balance conditions. To overcome this we need an appropriate tolerance level which states how close to the defined blue color the color has to be in order to be recognized as a blue color. The higher the value, the less accurate it is, while the lower the value, the lower chance there are to recognize the intended color at all.
It came apparent that it would be ideal to have a dynamically changing tolerance value. The idea is that if no color match is found, it is safe to assume that the tolerance level should be higher; if a matching color is found, it is safe to gradually lower the value until there's a moment when we don't find colors anymore.
The problem of detecting the dominant color from the video feed is also something which needs to be considered. Not everyone is wearing a plain colored shirt. There could be several colors, which the program may or may not recognize, and from the available colors it should decide which one should it pick, or should it pick several colors.
One solution to this problem could be that the program simply "records" all the color picks it's able to find within a time period of a second or two, and only after that it decides on the color while checking which color was found the most. The larger the sample, the more accurate it would be, yet the longer it is "calculating" and waiting, the more likely it is that the situation has passed already.
After we have solved all the above problems, there are of course the interference of the background and surroundings. The program should recognize the "object" - a person - of which it is supposed to recognize the color from. This problem could be overcome in a way that as the camera is ideally still, it would only find the color of the pixels which have changed within the video feed effectively limiting the possibility of recognizing the color of a background wall or other unrelated objects.
Let's see if I have the resources and time to tackle this problem. At this point it's all mostly just fine tuning and perfecting the recognition.