SimpleHead is a simple program that analyzes movement and a few other things in video (offline) or from a camera (real-time). It runs on Macs, and Field can use either its analysis product files or talk to it live. Installation instructions are at the bottom of the page.
Field can initiate a
SimpleHead with the following code:
As you can see, Field needs a path to wherever you’ve put the binary that you’ve downloaded. The path is the folder.
Run that (once) and you’ll see something like this:
Those two windows can be safely hidden.
Having started a
SimpleHead you can now ask for parts of its analysis:
SimpleHead.now contains the current set of values for the last frame that was analyzed. These include:
vy— ‘velocities’. Average amounts of motion (in ‘pixels’) in the x and the y direction. This is correctly oriented for Field (positive
vxis right, positive
brightness. Average brightness (note that almost all webcams auto expose, so this is only useful over the short-term).
red, green, blue. Average red, green and blue.
meanv_yare the ‘position’ of where the motion is occurring. That is, the average ‘x’ and ‘y’ position weighted by the amount of motion there. This only makes any sense at all if there’s a relatively compact object that’s doing most of the moving.
meanb_yare the ‘position’ of where the brightness is occurring. That is, the average ‘x’ and ‘y’ position weighted by the amount of brightness there. This only makes any sense at all if there’s a relatively compact object that’s brighter than the background.
_.stage.withImageDirectory now looks for
.simpleHead files in parallel with it. Given that you can ask a layer for a
.head and get the same kind of object as
SimpleHead.now returns for the frame (or mix of frames) that they layer is currently showing. For example, this code here, which combines some standard code for playing out a video on a Stage with some code that draws a line in the direction of motion:
If you want to process your own files, or run
SimpleHead in real-time, there’s a three stage process.
First you’ll need to install some command line tools called Homebrew. You can read all about that here. Copy and paste this into a new terminal window:
Next enter your password when prompted. That should install Homebrew and the Apple Developer Tools. Don’t, in general, trust websites that download random things to your machines and ask for your password…
Now that you have Homebrew installed you can install other things easily. We need
ffmpeg which is a command line program for manipulating video.
That was easy!
Download SimpleHead. If you are using Safari, get it out of the all-too-special Downloads folder and put it somewhere else (like your desktop).
The magic command in the terminal for analyzing a movie, turning it into a .simpleHead file, looks like this:
You’ll have to stare at that carefully though (like anything else from the command line). There’s three parts — the command
simpleHead, your movie file and then the name of your simpleHead file that you want to create, which should be the same name as your
.dir directory for Field, but with
.simpleHead rather than
.dir. One way to make sure you spell everything right is to exploit the fact that you can drag things from the finder into Terminal and have them written out for you. So, drag the
simpleHead executable into Terminal, drag your
mp4, write the
> and so on.