Max Assignment: Fragmentation – technical implementation (part 1)
by adrianpark on June 23, 2011
So, moving on from thinking about the Max assignment, I set about figuring out how I might implement such a sketch and then seeing how I might do it in Max.
When learning new tools, I get bored very quickly just following tutorials through from start to finish. Instead, I usually start by quickly scanning through a few tutorials of varying complexity just to get a feel for what is possible. I’m not so concerned with actually understanding how to do things but more with what possibilites and limitations of the tool. I figure out the how later, when I know what I’m trying to achieve.
Back to the task, I very quickly figured it was natural to somehow use face detection and tracking to plot the viewing position relative to my virtual ‘window’. Added bonus: I’ve never done face detection/tracking before so new thing to learn. Yay!
Fellow course mate, Allessandro, pointed me in the direction of Jean-Marc Pelletier’s awesome cv.jit computer vision library for jitter. The library includes an object called cv.jit.faces and the object reference that comes with the download includes an example patch. The documentation states that the object’s output is a “4-plane single row-32″. This, I eventually figured out, is a matrix describing the x and y positions of the top left and bottom right corners of a rectangular bounding box of any face it finds. Once I’d figured out how to grab the first face in the list of faces it finds, I unpacked these coordinates and spat them out as individual send messages to be used elsewhere.
With this done I set about figuring out how to use these values to manipulate the view through a virtual window. The ‘fragmentation’ topic actually inspired my solution: I decided to set up 4 individual jit.pwindows arranged into a block. I then chose one of my own landscape photographs and sliced it up into a 10×10 grid so that I ended up with 100 individual image files in a numbered sequence. The plan was to display a grid of 4 slices in the jit.pwindows in the correct order. I started trying to build the logic to match face tracking values to images slices and quickly grew frustrated that what was becoming a very complex Max patch could be achieved in a few lines of code! Remembering that someone had mentioned that Javascript may be used in Max patches, I investigated this route. Pretty swiftly I had the rudiments of some Javascript to work out what slices to display. I pushed the file names of 4 image slices through the outlets of the Javascript object and used them as sources for the pwindows. With a few tweaks I had it working satisfactorily.
Having tried it out, I was satisfied the result was interesting enough to present in the final Doing exhibition but decided I wanted to work with the implementation and aesthetics a bit more and explore how they might better reflect the theory that had originally led to the idea. That’s the topic of the next post.
Below are a few screen shots of the sketch in action. As I was working on it, I noticed the nice bit of serendipity that, if I left gaps between my pwindows, it created the archetypal window with 4 panes of glass!
Note that the webcam feed is reversed so when my head appears on the right in the image, I’m actually leaning left. I’ve included little diagrams to show my view in relationship to the virtual window.









Pingback: Max Assignment: Fragmentation – technical implementation (part 2) « Adrian Park