Color Tracking W/ CMUcam and MATLAB





description of how to use my MATLAB code to get MATLAB to talk to a CMUcam to do simple color tracking.

Step 1: How to Do Use the Code

connect the CMUcam to the computer via serial cable as mentioned inthe documentation (the grey serial adapter should be attached so that the ribbon cable sticks away from the camera).

connect the power to the white power socket on the CMUcam.

run the java GUI from their website to make sure the camera works
do a screen dump, click on a color you want to track (in the screen dump) click the color tab

write down the min and max color values (1st#=Redmin 2nd#=GreenMin 3rd#=BlueMin 4th#=RedMax 5th#=GreenMax 6th#=BlueMax)

Close the java GUI and open the MATLAB code (MATLABtoCMUcam.m) in the MATLAB mfile editor
change the Track Color (TC) values appropriately (format: Rmin Rmax Gmin Gmax Bmin Bmax)

change the COM# according to which COM port you're using to talk to your CMUcam (I was using a USB to Serial Adapter and it worked very well).

Run the program, you'll see 100 sets of coordinates stream down the screen, as you move your object around the coordinates will change.

NOTES: I attached the cmucam2 gui and manuals for your convenience. They were created by carnegie melon, not me, don't sue me. I didn't take that photo either. Only the MATLAB code was written by me. Not knowing matlab, I worked for a while to get the serial itnerface to work correctly and thought it would be helpful to others.



    • Faux-Real Contest

      Faux-Real Contest
    • Safe and Secure Challenge

      Safe and Secure Challenge
    • Comfort Food Challenge

      Comfort Food Challenge

    7 Discussions


    Reply 8 years ago on Introduction

    not sure, maybe cause I guess you could make a servo controlled nerfe gun that would track people/objects and shoot at them (I think there was a project like that on instructables)


    10 years ago on Step 1

    Hello, I am facing a problem in connecting the USB to Serial cable, I can see that the camera is recognized bu laptop but it is not acknowledging that ? Do you have any suggestions?

    1 reply

    Reply 8 years ago on Introduction

    make sure you're using a good serial to usb adapter, I used this one (IOGear USB 2.0 to Serial/PDA Converter Cable GUC232A):

    but other ones might work too: use amazon and read the reviews of different models to make sure you buy a good one.


    12 years ago

    We tried to use a version of this camera for FIRST robotics, but failed miserably...

    1 reply

    Reply 12 years ago

    it's a great camera, nothing else like it. it's definately worth learning how to use. Can be interfaced with anything, PICs, computers, basicstamps, etc.