Thursday 2 December 2010

Color Recognition

Starting up:
Participants: Johan & Jakob
Date: 2/12-2010
Duration: 3 Hours
Goal: Investigate the light sensor and determine whether the sensor can be used to detect more colors than merely black and white.
Plan: First we will try and determine how precise the sensor can differentiate between black, white and green. Next we will try to utilize this to create a program which can detect which of the three colors the surface is.

Experiments:
Our initial experiments were designed to give us a better insight into the sensitivity of the light sensor. We placed the sensor over the different colored surfaces (black, white and green) and took readings from the sensor using the BlackWhiteSensor class. The sensor readings were fairly consistent with an error margin of approximately +/- 2-3. This error margin is mainly due to the sensor vibrating, thereby making the sensor get closer and farther away from the surface.
The sensor reading also gave us an impression of what the different colors' value were and it was evident that the readings from black and green were very close to each other, however we still believed that by choosing a small enough error margin we would be able to interpret the reading correctly and choose the correct color.

Line follower:
We tried the LineFollower class and it worked as expected. Next we looked at the code to try and come up with a method to extend the BlackWhiteSensor class to incorporate the color green. We decided that a simple addition of the color green in the calibration routine and a method for returning whether the current color is green would be sufficient to be able to use all three colors. The method green (to determine whether the surface is green) is implemented in a way so that it has an error margin of +/- 2. Meaning that if the sensor reading is within +/- 2 of the reading from the calibration routine, the surface would be interpreted as being green. A fairly basic approach which we believed would be sufficient for the job.

We the implemented a test program called ColorTest based on the LineFollower class. The only significant alteration is the behaviour when confronted with a color. The robot moves forward continuously and analyzes the color of the surface. If the color is green the robot makes a buzzing noise and writes green on the LCD, if the color is white it beeps twice and writes white on the LCD and if the color is black the robot beeps once and writes black on the LCD.
Since the sensor reading of green is within the threshold of black it is important to start out checking if the color is green, otherwise it would default to black each time. This is because we didn't want to make major changes to the class and we felt this approach would be sufficient.

Tests and results:
The test program was run several times and while there were a few anomalies it worked fairly well. The biggest anomaly was the fact that the transition from a black surface to a white surface and vice versa was often interrupted with a reading of green in between. We concluded that this was due to the sensor reading half white half black and thereby triggering a green interpretation because it is between black and white in the light spectrum. Another small anomaly was the occasional black reading while on a green surface. This was concluded to be caused by the vibrations in the robot making the sensor get closer to the surface and thereby reading a darker color than in the calibration. We attempted to fix this with the green error margin, but found that increasing it only caused the problem to migrate to the black surface.
All in all the tests were successful besides the few anomalies. the robot was able to interpret the surface correctly the majority of the time.

Conclusion:
The experiments showed that it was possible with a low probability of error to detect other colors than merely black and white. By making further experiments it might also be possible to add another color closer to the white spectrum and identifying this color as well. This, however, remains untested.

References:
1.
http://www.daimi.au.dk/~bubbi/lego/ColorSensor.java - ColorSensor class for detecting black, white and green.
2.
http://www.daimi.au.dk/~bubbi/lego/ColorTest.java - Test program for detecting surface colors.

No comments:

Post a Comment