Color Map Confusion...

This forum is used for discussing hardware, software, and technical details of the AVRcam embedded system.

Color Map Confusion...

Postby TedLarson » Mon May 23, 2005 2:41 pm

I have just started fooling around with the 1.4 AVRcam, and I have some confusion about how to do color tracking. I am very familiar with the CMUcams...it is done differently with the AVRcam, so I am stuck.

If I want to track only one color range say, a reddish ball, what is the easiest way to do it?

For example in the CMUcam I would do this:
tc 80 240 5 80 5 30\r

I am assuming in the AVRcam, I would set the color map using SM, and then do an ET to start tracking. However, do I have to reset the ENTIRE color map in order to just set one color range?

Any hints on this would be great.

Thanks,

-Ted
TedLarson
 
Posts: 6
Joined: Mon May 23, 2005 2:36 pm

Postby 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.
Guest
 

Postby TedLarson » Tue May 24, 2005 10:30 am

I think I understand it now. I didn't realize the color map was discretized until I went back and started fooling with it again in the AVRview. I think I understand your AND logic, but it definitely seems easiest to just go into AVRview, set the range you want, and copy the SM command right into my program. I am getting ready to do some tests using this robot:

http://www.tedlarson.com/robots/tracker.htm

I overhauled his head to carry the AVRcam instead of the CMUcam. I will post my results once I have some.

Thanks for your kind remarks on the RoboMagellan. I am really excited about that competition, and I think it is one of those things that has the potential to bring the hobby robotics people, and academia robot people together to compete on the same task...which for some silly reason always seems so segmented. Your camera seems like an ideal cone-finding device, if its performance out-does the CMUcam2. Especially since it seems like it wouldn't be too difficult to add outdoor lighting filters to the AVRcam code, which is where the CMUcam really falls down. Have the cone in bright light, and the robot in shadow, or visa versa, and it just won't see it.

Thanks for your help,

-Ted
TedLarson
 
Posts: 6
Joined: Mon May 23, 2005 2:36 pm


Return to AVRcam Embedded System

Who is online

Users browsing this forum: No registered users and 22 guests

cron