Lighting for computer vision automisation
What I learned so far that my lighting is not good. It's coming from a fluorescent lamp from that's right above the camera. Apparently I would have to diffuse the light with some sort of material. The reflections of the light are not doing us well.


A "Ring Light" type of light will cast uniform light and minimal shadows to your object. It is used regularly in photography. The link to the product is for demonstration, not to suggest that specific product.

Of course, the other thing with the ring light is that the camera shoots through the ring and it's not casting shadows.

Using diffusers is not efficient for relatively large distances (a few meters), or rather, using a diffuser means that you have to use a much stronger light behind the diffuser to flood a large area.

Now, once the light is flooding the area uniformly, place a sample tape rectangle and extract the Red, Green, Blue (RGB) values of the pixels occupied by the tape. To determine your threshold do a histogram on the RGB channels and try to characterise the modes on the R and the B channel. 

A more involved way of doing this is to scan the image once and convert the RGB values to Hue Saturation Value (HSV). You can then do one histogram on the H channel which will have two modes, one on the angle that corresponds to Red and one on the angle that corresponds to Blue. Consequently, you now have one variable (H) with two thresholds and two deviations around the thresholds.

Hope this helps.