Posted tagged ‘tracking’

Detection with Processing

March 14, 2010

Right I’ve been going around in circles but I am now hoping this is the last time. I’ve decided to go back to Processing as it allows me to use the feed from the web cam and manipulate it using little code which I am told is more reliable in this context compared to Flash. Soo even though I found this really cool example (try the demo if you have a web cam): http://blog.soulwire.co.uk/code/actionscript-3/webcam-motion-detection-tracking which uses Flash, I am going to actually use Processing which is actually easier to understand (now that I look at it properly) and that will probably take less learning to adjust.

The official info on Processing can be found on their web site: http://processing.org/
And here are a couple lines from their home page:

“Processing is an open source programming language and environment for people who want to program images, animation, and interactions.”

I will be using OpenCV (a library which is imported into Processing) to get a basic black and white image of the floor area to project onto my work which will be mounted on the wall. This way the viewer can literally move around on this floor  in order to alter the areas that are illuminated and try and play around with manipulating the shadows and reflections that are projected from that. Obviously it may not work as well with just heads and shoulders in view (remember it will be an aerial view) but that’s something I need to test in the next couple of weeks.

Here are a couple of test images from the camera view as processed using OpenCV and the blobs() method which by the looks of it calculates where whole ‘blobs’ are in the image, and constantly checks for where lines merge or disconnect in objects, so if one object comes in front of another then it would change where the edges are detected (I think).

I changed the contrast and colour from the default which is grey and white and used a book cover and a cd for the following to give a better idea of how it cuts out things that don’t have whole areas defined and focuses on those that do:

Image of book cover with Blob() function using OpenCV in Processing

Image of an intricate book cover as seen using the blobs() method with OpenCV in Processing

Image of CD processed with OpenCV using the blobs() method

The results aren’t as predictable as they appear in the above images though. They constantly change and it’s hard to pinpoint exactly how movements and changes in the view affect what is then displayed. I will need to play around with this quite a bit to make it less sporadic and more intuitive so that it works better in the show.

The code is really short and simple and there are quite a few examples on the OpenCV resource page: http://ubaa.net/shared/processing/opencv/

You don’t need to even be able to understand this stuff to try it out. You can simply download the necessary software and additional libraries from the two links I’ve provided. After installing you can either try out the examples already in the Processing library (really cool ways of producing generative art with this) or by pasting in code found on the two sites to view and play around with the results. There’s also loads of examples where you can interact with a cursor or movement through a web cam to change the visuals. There is much fun to be had!