I created this little puppy a while back, maybe 2004. Just found it on my hard drive and thought I’d add a post with it in. It dynamically updates the stats based on daily averages I set up at the beginning. It also takes the year from the current system clock, so should just tick over into the next year on New Year. The bit in-between will go a bit strange, but I’m not that fussed about fixing it. Feel free to do it yourself.
The source is here, but it’s a bit old skool. It’ll give you a few ideas though if you’re brave enough to open it.
Looks like those penguins down at Club Penguin are being put to good use. Just noticed this little Easter egg… Go to the homepage of Club Penguin, click Play Now and zoom into the lower part of the screen (expand your browser window). Looks like they are using AS2 though… god help us when they figure out HTML5! Still, I assume they are working on Linux :)
Another strange webcam experiment! Click the image to launch it.
I take the raw cam feed, find what changes between frames and add a threshold filter to colour the bits that change to a solid red. I then simply loop through the pixels to see if any are red then use the pixel position to draw lines to and from, sampling the original image to get the correct line colour. Completely no use to anyone… but looks nice enough.
Just trawling through a few old Flash folders on my mac and found this little fella’ sitting there all unloved. Came up with the 3D engine in 1998 using Director and made a quick hack to get it into Flash. It’s not particularly neat, hence why there’s no source posted, but suffice to say the heart of he 3D bit is that old ‘fake-doodle-dandy’ equation…
var x = (worldLens*pointX)/(pointZ+worldScale)+xOffset;
var y = (worldLens*pointY)/(pointZ+worldScale)+yOffset;
If you’re a fan of the EyeToy or you’ve just got You’re In the Movies on Xbox 360, you’ll know what this is all about. How to remove yourself from a web cam image and superimpose you on another background.
The mighty Jop had a bit of a testbed working and I thought I’d get the old brain working again and have a tinker. It’s not pretty code but it’s available below if you’re interested in a few pointers. It’s also not that good, but if it inspires you to do it better (I.e. properly) then it’s done its job.
3: Use a ‘difference’ filter on them both to fighure out which pixels have changed the most
4: Use a ‘threshold’ filter to remove all the pixels that haven’t changed much
5: ColourTransform the resulting pixels to black
6: Apply a slight blur to help make it less jagged
7: Cache the resulting image as a bitmap (so it can be used as a mask) and put it over a copy of the live feed
8: Cache the live feed as a bitmap and apply the mask
9: And repeat using an interval or similar
Here’s the main function:
function takeSnapshot() { //grab the cam and render it into a snapshot bitmapData obj
snapshot.draw(output_vid);
}
function checkVid() { //grab live cam
liveData.draw(output_vid); // grab snapshot maskData.draw(snapshot); // apply difference to 2 images
maskData.draw(liveData, new Matrix(), new ColorTransform(), ‘difference’); // remove all unchanged pixels. Make them transparent
maskData.threshold(maskData, new Rectangle(0, 0, output_vid.width, output_vid.height), new Point(0, 0), “<=”, (threshVal/100)*0x00ffffff, 0×00000000, 0x00ffffff, true); // colour what’s left black
maskData.draw(maskData, new Matrix(), new ColorTransform(0, 0, 0, 1, 0, 0, 0, 0)) // Blur to improve quality
maskData.applyFilter(maskData, maskData.rectangle, new Point(0, 0), blurFiltr);
resultData.draw(liveData); // cache the resulting mask and apply it to the live feed
mask_mc.cacheAsBitmap = result_mc.cacheAsBitmap = true;
result_mc.setMask(mask_mc);