A few months ago I was commissioned to create some background subtraction technology in flash. The project fell through at the time. The final product wasn't as stable as I'd hoped it might be. I thought that since the project fell through I would share some of my findings to see if the collective flash community might have any ideas or suggestions as to how one might implement this kind of technology.
The idea of background subtraction is to separate two parts of an image, the foreground and a "static" background. Here is an example. Given the two images on the left, how does one extract the image on the right. You might think this is fairly easy, just look at the difference in color between the two you might say. Unfortunately it isn't as simple as this.
Firstly illumination and varying camera brightness cause a problem, not only does the foreground constantly change color, but also the background. Most web cams automatically adjust to a white point. You'll notice this if you hold a white sheet of paper against the web-cam, the background will dim. This means that in measuring the difference in RGB color for each pixel it is likely that the whole screen will be completely different from one frame to the next, not ideal if you want to separate out smaller regions!
The method I chose to incorporate was to use multiple color spaces, combined in order to create a new color space which was optimum for this kind of a background subtraction scenario. Here is the program I used to determine the optimum subtraction for each color space. Just click on the image to launch it:
Initially a background is captured, the user steps out of the frame, and a still bitmap image is taken, then for each color space a comparison is made. If the difference between given pixels is greater than a threshold for any color component (or a combination of the three) then the pixel is deemed to be in the foreground. The three color spaces used in this case where YUV, normalized RGB and normalized YUV. The latter of these I haven't seen in use before, but it gives reasonable results.
Once the image has been thresholded an alpha mask is applied to the current web-cam frame, and this image is used as the foreground. This allows some very impressive things to be done. The background can be replaced by an image, or another video (apple make use of this in their software Photo Booth), but more excitingly we now have two image planes, which means 3D!
Here is an example of background replacement:
In the image below you'll see 3D in action (excuse the poor lighting conditions), click to launch it but remember, it probably won't work fantastically. Just click to launch it:
The 3D angle can be controlled by head position (motion tracking) allowing you to look around the person in front of the camera which is quite an interesting effect.
The main issues with the project were that lighting conditions are constantly changing, and can vary hugely from web-cam to web-cam. There are other more computationally intensive approaches which flash may just about be able to handle, but unfortunately my brain cannot. Enjoy the experiment, and let me know how it works with your web-cams!
Showing posts with label augmented reality. Show all posts
Showing posts with label augmented reality. Show all posts
Wednesday, 19 January 2011
Multi-Color-Space-Thresholding
Labels:
3D,
AS3,
augmented reality,
webcam
Tuesday, 3 August 2010
FLAR Toolkit - First Go
I thought I'd finally get round to having a go with the FLAR toolkit (an augmented reality toolkit for flash). I made a marker which will be used in any AR experiments I do on the site, then quickly made a test program. All I can say is it works quite nicely and I'll be playing around with it in the near future. Click the second image to run the test!

Labels:
3D,
AS3,
augmented reality,
webcam
Saturday, 17 July 2010
Real Time Feature Point Tracking in AS3
Its a bit late, so instead of posting a long informative post about how feature point tracking works I thought I'd just upload some of my results from this evening. I think its quite exciting stuff. The image shows feature point tracking working relatively well on my pupils, and also on other facial features (the last two images). I am very pleased with the result.
A related project I have also been working on this evening is optical flow which I am close to getting
working, here is a preview of what is to come:
Both methods are used in tracking objects in moving images and have been implemented in real time. I will post sample movies and some explanations shortly so you can play around with them yourself.
Labels:
AS3,
augmented reality,
face recognition,
shape recognition,
webcam
Tuesday, 9 February 2010
Three Dimensional Projection
I came across a very interesting video recently. A design agency from the Netherlands called NuFormer Media have mapped various famous buildings in 3 dimensions. Using the three dimensional data, images can be projected onto the building, with amazing accuracy. The results are amazing and quite hypnotising, I especially like the crumbling building at about 36 seconds in. Just watch the video below!
Labels:
3D,
augmented reality,
fun
Thursday, 22 October 2009
Augmented Reality - Some examples
Hey everyone - I've been playing around with some of my own augmented reality functions - they don't use the FLAR toolkit - but I plan on looking into this sometime soon!
Here are a few images of what I have so far!
Here are a few images of what I have so far!
I'll post an update with some example files for you to play around with!
Update: put some examples up on the server -
Click here for some simple motion tracking
Click here for green object tracking (you'll need something green and don't wear a green jumper!)
or click here for the 3d monkey head example.
Enjoy!
Labels:
AS3,
augmented reality,
Flash,
webcam
Subscribe to:
Posts (Atom)