Skip to content


Color Tracking

This examples shows how to track a color from the live video feed.
The default color is a blue tone, you can change that by clicking on any pixel in the video feed and the application will now track that color.

There are 4 parameters for the ColorTracker object's constructor; width, height, color to track and a treshold. treshold is obselete and optional.

This movie requires Flash Player 9

 
package examples
{
	import flash.display.Sprite;
	import playground.src.video.ColorTracker;
	import playground.src.video.LiveCamera;
 
	public class ColorTracking extends Sprite
	{
 
		private var _cam:ColorTracker;
 
		public function ColorTracking()
		{
			_cam = new ColorTracker(320, 240, 0x44ddff, 10);
			addChild(_cam);
                        //this is how you can get the x and y coordinates of the pixel you are
                        //tracking as a Point object
                        trace(_cam.publicpos);
 
		}
 
	}
 
}
 

4 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. George says

    Hi, nice example of color tracking.
    What colorspace to you use to match the colors (RGB, HSV, CIELab, … ). Are you using getColorBoundsRect() to extract the final region?

    Greetings

  2. emedesing says

    Hello my name is Luis Rodriguez, I have been researching the detection of movement and now I’m researching the detection of color and movement, I would like you to see my work:

    http://emedesing.wordpress.com/2010/09/13/pruebatelo-con-realidad-aumentada-y-deteccion-de-movimiento/

    I wonder if you want to share your library as3 in this example with me so I can further my research, I would greatly appreciate

  3. Servet says

    Hi Luis, I like what you got so far. How do you handle the movement detection? Difference in pixel matrix?

    You can get all the files from here
    http://servetulas.com/blog/playground_library/download/

    It should be among one of the examples in there.

  4. Servet says

    George, sorry for not replying earlier, just seeing your comment. I am using RGB and running through the image’s pixels to seek the color every frame.



Some HTML is OK

or, reply to this post via trackback.