
Flow (working title) V1
Flow (working title only), was initially developed to solve a problem, but seems to have resolved quite successfully. “Stories about You” requires a camera to capture images of faces from people in the gallery. I had initially set up a web cam using the OpenCV Haar face detector. I found unless people stopped and looked directly into the camera the images were blurry and indistinct - not very usable. My solution is instead of using a separate web cam, is to use an iMac with a small built in web cam, and create another piece of work which encouraged people to be still and stare into the camera. I’d also been interested in doing something with the optical flow demo that comes with the OpenCV package. Optical flow can be used to calculate a vector stream field which tracks how objects are moving in a video stream. This is far less noisy than simply calculating normals to gradients from the difference of successive images.
Starting with the animation engine in quote, my initial vision was of a series of quotations which would come towards the camera viewpoint, and as they came closer they would be disturbed by the optical flow. I chose as a source text, a collection of quotations compiled by Jason Newquist focusing on the history of ideas and art. The project developed to incorporate the background image of my son and I, and it the latter stages incorporated the colour.
Technical issues arose in including the optical flow and face detector. The OpenCV vision processing of the webcam put too great an overhead and slowed down the event loop of openscenegraph to the point where it was unwatchable. As all iMacs are dual processor these days, the standard solution would be to do the vision processing on one processor and the animation on the other. Unfortunately python doesn’t multiprocess or thread particularly well. It uses a thing called the GIL (Global Interpreter Lock) which allows only one python thread to run at one time. There are a number of python multi/parallel processing solutions. I had previously tried out pp (parallel python ), but had found the job overhead to high to effectively use with OpenSceneGraph. My solution in the end was to use the Unix System V IPC (Inter Process Communications) share memory model, via a python module called shm and shm_wrapper. Using shm allows me to share numpy arrays between two processes. The animation process is launched by the ‘master’ vision processing stream. It appears to incur very little overheads, but I still have some concerns as to how the iMac will stand up to such heavy processor usage.
The final component is a simple server based on twisted using a package called pygnet, a bit more work on the how the ribbons get attached to the data points to draw the image of the face, and this project should be finished.