Even though this is the version of my project that I will submit for the Masters, this is by no means the final version of my project’s application. For the submission to the BBC, I will do some more changes and optimisations. I’ll discuss this in details in the “Further Development” section.
All videos of my prototypes can be found at my vimeo page here.
Below are the source files of prototype 03 written in pseudo code for easier understanding.
main.cpp
include stuff// Main
//--------------------------------------------------------------
open window of size 720,576
run main c++ file (testApp.cpp)
testApp.h
Include addons like ofxOpenCv, ofxVectorMath, ofxBox2d, ofxContourUtil and ofxBlobTrackername the blob tracker for the history of contours and blobs
name the physics world
name the happy face circlename video grabber for the webcam or video player for movie
name colour images to store the video pixels in
name grayscale images to store the foreground and background pixels inname contour finders to store the contours in
name variables for blur, threshold and video sizes
testApp.cpp
// Setup //-------------------------------------------------------------- Make background blackSetup the physics world
Create happy face
Set dimensions of video
Set dimensions of video on which operations are performedSet the blob tracker to work within our physics world so blobs and the happy face can interact
Setup video (or live feed)
Allocate memory for video and operations video (which is going to be smaller than the original
to improve performance)Setup Gaussian mixture model and allocate memory for its drawing
Initialise blur and threshold
// Update
//--------------------------------------------------------------
For each new frame of the video (or live feed) we do:Print frames per second, blur and threshold values into the window title bar
Scale video to our operations size
Update gaussian mixture model to learn background and save it in our foreground video
We apply our blur and threshold to the foreground videoGenerate contours
We track the generated blobsDraw
//--------------------------------------------------------------
Draw original video in original sizeDraw blob history:
Draw the filled contour from 20 frames ago in half transparent white
Draw the outline of the last 20 frames’ contours. Adjust transparency slightly to let the final
contour appear the clearest and the earliest almost invisible.Add the current contour of each blob to a linestrip in the physics world
Draw our happy face with a random colour in each frame
Happy Face Draw
//--------------------------------------------------------------
Draw the main filled circle of the face
Draw the outline of the face
Draw the filled white circles for the right and left eye
Draw the black outline of the eyes
Draw the pupils