Color Tracking Source 

When I was researching color tracking with Flash, there were surprisingly few examples. The examples I did find did not have any source to download. So, I am offering up my source code from  my color tracking experiment. The ColorIsolator class is based on an old AS2 algorithm by Mario Klingemann (Quasimondo) for selective color. I’ve translated it here to AS3 and applied it to video from the webcam.

It works like this. Once a color is selected from the video, using a seriess of thresholds, the ColorIsolator drops all pixels that don’t fall within the defined range of the target color. The remaining pixels are set to the target color and getColorBoundsRect is used to pinpoint the remaining blob of color. It’s really simple. I had the general idea, but I didn’t understand how to define a range of  color until I found Klingermann’s code.

I would consider this just a starting point. It actually works very well, but there are a number of things that can be done to improve it. Here are my recommendations to try out:

  1. Try using HSV color values rather than RGB.
  2. Introduce a palleteMap in place of or in addition to the saturation/contrast ColorMatrixFilter.
  3. Add blob detection to ignore anomalies/artifacts of the target color.

Download source here.

All I ask is for constructive criticism and to let me know if and where you use this. A credit to myself and Mario in your source code comments would be nice.

Thanks to Justin Windle (soulwire) for a great exchange of ideas for this.

EARTH MOVER 

Inspired by the 20th anniversary of the Loma Prieta earthquake I created this little prototype. I pull down the earthquake RSS feed from the USGS and parse the data for the longitude, latitude, magnitude and date/time of recent earthquakes. I then plot them in sequence on a Papervision3D sphere textured with an image from NASA’s Visible Earth. The quakes play to scale in time that they occurred. Each quake is assigned a musical note according to the magnitude. The higher the magnitude the lower the note. Currently I am pulling quakes with at least a 2.5M for that last 24 hours.

For plotting points, I used this blog post as a reference. The musical notes I exported from Garage Band. Also of note, the USGS does not have a cross domain policy set up for Flash, so I had to proxy the RSS feed with a PHP script. I will probably be adding more features, refining the musicality and adding a UI to this, so check back again sometime.

Click screenshot below to launch it.

UPDATE: Looks like the USGS not only moved their feed, but changed it a bit. For now, this won’t work.

earthmover