by Guest » Mon May 23, 2005 6:02 pm
Hi Ted,
Yup, you set the entire color map each time. Each color channel (R,G,B) has 16 different values in it. Using the AVRcamVIEW PC application, you can capture an image using the "Capture" button in the GUI. Then, move the mouse over the captured image on the right. You'll see the R/G/B values at the bottom of the window update to show the RGB values of the current pixel pointed to by the mouse. Right click on the color you are interested in tracking, and then add the color to the color map. You have the option at this point to set the range of acceptable values for the three color channels, which is nice to give you some wiggle room. Then, once the color map is set, left-click on the "Send" button in the Color Map window, which will build a properly formatted command and send it to the AVRcam. This command will contain the complete color map. This color map is maintained in EEPROM on the mega8, so it doesn't need to be manually set each time at powerup.
It would probably be instructive to turn on message logging, by selecting the View->Show Log option from the main GUI menu. This will open up a window (you may need to expand the fields to the full screen's width to see everything). This log will show all the messages that are sent to the AVRcam and received from the AVRcam.
In the above scenario, say you wanted to track the color red in the first available color slot (there are 8 total color slots, so we'll use 0th slot, which is really the MSB). The command would end up looking like the following:
SM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r
(the entire line above should be sent with a single \r character at the end of the line).
The first 16 bytes correspond to the red map, the second sixteen bytes are the green map, and the third 16 bytes are the blue map. This map really translates to the following:
-If a 4-pixel region in the image has a red value between 224 and 255 &&
the 4-pixel region in the image has a green value between 0 and 16
&&
the 4-pixel region in the image has a blue value between 0 and 16
then
consider this to be a red region.
You'll receive an "ACK" to indicate that the color map has been set, and you can now enable tracking with the "ET" command. All red objects that meet the above RGB criteria will be tracked, and their bounding box will be returned.
The CMUcam mechanism is simpler because it only supports tracking a single color at a time. Thus, you only need to set a single range for red, a single range for green, and a single range for blue. The AVRcam can track up to 8 different user-defined colors simultaneously. This is accomplished by using the color map as a lookup table of sorts, and performing a logical-AND operation with the results of each color channel's lookup table to determine what color is defined by the RGB triplet. The entire map is set all at once (instead of each color individually) to ensure that the user creates a valid color map (the AVRcamVIEW application validates the map before sending it down). There are invalid combinations, where the logical-AND operation will result in more than a single bit being set, which effectively means that an RGB triplet has mapped to more than a single color, which shouldn't be allowed.
More info can be found in the appendix of the user's manual. Feel free to post more questions here as they pop up.
Incidentally, I'd like to throw you a personal word of appreciation for your fine job documenting the RoboMagellan events. The design of your bot is excellent, and I have played the different videos from the event a number of times. So thanks for supporting the community.