Sumo Player: Image Processing?

Hi,

I was going through the Source code of Sample SumoPlayer, and did not understand the below mentioned things:

Code Snippet
int threshold = 220 * 3;

Code Snippet

if (b + g + r > threshold)

Code Snippet

_state.LineThreshHoldLow = 600;
_state.LineThreshHoldHigh = 5001;

1. In the first snippets i think it is looking for the White Color in the image? Am i right? Can i change this to any RGB combination? (Let's say my opponent is having Blue color)

2. I quite did not understood this statement. Can any of you please elaborate?

3. Are this values in Hex? and Second thing Are they for the Red Color in the Ring?

Regards,

Jadeja Dushyantsinh Anopsinh.

[1088 byte] By [Jadeja_Dushyantsinh_c01c57] at [2008-1-4]
# 1

The sum (r + g + b) / 3 is commonly called the Intensity of an image pixel. It measures how bright it is. Obviously, a value of zero would be black and a value of 255 (assuming rgb values are bytes) would mean white. However, pure yellow would be (255, 255, 0) in rgb, giving an intensity value of only 170 and it looks like

I assume that the threshold is initalized to 220 * 3 simply because the desired intensity is 220 and the programmer wanted to make this clear. This saves a division by three every time that the code is called. The value is not in hex. An intensity this high is close to white, but not pure white. In fact, it is more of a grey colour. Here is what it looks like but this is a long way from black!

You can examine the values of r, g and b separately if you are looking for red, green or blue. For other colours you need to have combinations, e.g. yellow is red plus green.

I don't understand the LineThreshHoldHigh because the maximum possible value of r + g + b is 765. The Low threshold of 600 is equivalent to 200 * 3 which is also very bright. If you consider that the range for r, g and b is only 0-255, then getting a total of 600 means that all the values must be high. For instance, pure red would be (255,0,0) so the sum is only 255.

To get a total of 600, each of the colours must contribute a fairly large amount. An extreme case would be (255,255,90) which totals to 600. Here is a sample:

To the human eye, this probably looks similar to the pure yellow above. (Look very closely and you might see that it is brighter.) However, cameras see even small differences in colour. Hence what we think is white will not always be pure white at the pixel level, which is why there is a threshold in the program for colours that are close enough to white.

Trevor

TrevorTaylor at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...
# 2

The LineThreshold has nothing to do with RGB colors. The IR sensors on the bottom of the iRobot Create return a single intensity value which represents the reflected IR light hitting the sensor. This is often used to sense distance because the reflected IR light value is often high if a surface is near and very low if a surface is far away. We use the IR sensors in the Sumo competition to detect the edge of the ring. Our Sumo ring has a non-reflective black interior and a very reflective orange exterior. The IR values read by the sensors are low when they are sensing the inner part of the ring and very high when they sense the outer part of the ring. That is how the robot figures out that it needs to turn around before it goes out of the ring.

-Kyle

KyleJ-MSFT at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...
# 3

Sorry, I should have looked at the Sumo code first. I did not realise that it had a simulated IR sensor. The code snippet in the original post seems to be for the webcam because it uses r + g + b. Is this for locating the opponent?

Trevor

TrevorTaylor at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...

Microsoft Robotics Studio

Site Classified