For this second NMNT-lab Sieta and myself created The Random Facializer. This page explains in brief what The Random Facializer is, how the product was created and in what form it was presented.
What is The Random Facializer?
The Random Facializer is a computer program which overlays two pictures of faces for the user to edit into one. The combining of the two often results in a hilarious caricature.
The original idea
The idea for the project is based on one of the stock examples which comes with the openFrameworks software package, AlphaMaskingShader. This example overlays two pictures of artworks and gradually shows the back image as the front image is erased using the mouse. Following this technique we imagined what would happen using two faces instead of the artworks. A small test and fifteen minutes of giggles later we decided that this would become our project.
In order to build an image library and make the project more appealing to the audience of classmates, we've taken pictures of most of their faces for use in The Random Facializer.
Added functionality
The Random Facializer is based on the AlphaMaskingShader example. We've added several functionalities to make it our own program:
Random face selector
When launching the program two faces are randomly picked from the library. These two images, the front and back face, can then be randomized again separately in order to change the initial image combination.
Image saver
Once you're happy with the results it is possible to save the image to .JPG format in order to send, for instance, as an e-card! On the image it will show the names of the people's faces you've combined.
Change brush size
Using the up and down arrow key, it is now possible to change the diameter of the brush. This gives increased control over the editing accuracy.
How was it created?
The Random Facializer was created within Microsoft Visual Studio 2015 (MVS) using openFrameworks (OF). An example project posed as the base after which functionalities have both been added and expanded.
The idea behind the project was to evoke both creativity and laughter on the user side.
Step 1: Analyzing the code
We've started off by analyzing the existing code used in the example project. Since neither of us is an experienced programmer and this was our first time working with MVS/OF, this approach of reverse engineering worked well.
Fiddling with the code, we used trail and error to notice what changing certain values would do to the (functioning of the) program.
In order to know how certain additions worked, we repeated this process for several other online and offline examples.
Step 2: Adding & expanding
After getting a grasp of the program and the different functionalities we wanted to add, it was time to start coding.
Random face selector
In order to have the program work with an dynamic amount of images instead of the static two, code has been added to load a whole directory of images and load a random one as shown below.
dir.allowExt("jpg"); //makes sure to only use .JPG files
dir.listDir("FacesNames/"); //reads the image directory
dir.sort(); //sorts the files in the image directory
if (dir.size() > 0) //executed when files are in the directory
{
dirSize = dir.size(); //value set to match directory size
srcIndex = ofRandom(0, dirSize); //set to random value
dstIndex = ofRandom(0, dirSize); //set to random value
srcImg.load(dir.getPath(srcIndex)); //loads front image
dstImg.load(dir.getPath(dstIndex)); //loads back image
}
Elsewhere, code has been added to make sure the front and back image can never be the same.
Image saver
To be able to save created images, a image save function has been added. The code for this function was taken from another stock OF example called ImageSaverExample and implemented in the program.
if (bSnapshot == true) //executed when boolean equals true
{
img.grabScreen(0, 0, 800, 600); //sets screenshot size
string fileName = "screenshot_" +
ofToString(snapCounter) + ".png"; //sets file name
img.save(fileName); //saves the image to set file name
snapString = "saved screen to:\n" + fileName; //feedback
snapCounter++; //adds one to counter for file name
bSnapshot = false; //resets boolean
}
This piece of code was executed when the boolean turned true which was done by hitting a specific key on the keyboard. After saving, the files could be retrieved from the data folder of the project.
Change brush size
In order to make small adjustments, the size of the brush toll has been made dynamic.
if (key == OF_KEY_UP) //execute when UP is pressed
{
if (brushDia <= 100) //sets the max. brush size
{
brushDia += 10;
brushStr = brushDia / 2;
}
}
if (key == OF_KEY_DOWN) //execute when DOWN is pressed
{
if (brushDia >= 11) //sets the min. brush size
{
brushDia -= 10;
brushStr = brushDia / 2;
}
}
Final product
The final product contains all these and some more additions. It works quite well and differs proportionally from it's original.
How was it presented?
On Friday May 29th 2016 the different NMNT-lab projects have been presented during class.
As can be seen on Video 1, the presentation of the project was interactive. Several students tried out the product in order to change some faces. In the background you hear giggles as the product makes for hilarious results.
The product was received quite well by the audience.
Examples of resulting combinations
[CLICK ON IMAGE TO ENLARGE]
(source: selfmade using the program)
[CLICK ON IMAGE TO ENLARGE]
(source: selfmade using the program)
[CLICK ON IMAGE TO ENLARGE]
(source: selfmade using the program)
[CLICK ON IMAGE TO ENLARGE]
(source: selfmade using the program)
[CLICK ON IMAGE TO ENLARGE]
Image 5: Riccardo & Daisy
(source: selfmade using the program)
[CLICK ON IMAGE TO ENLARGE]
(source: selfmade using the program)
[CLICK ON IMAGE TO ENLARGE]
(source: selfmade using the program)
[CLICK ON IMAGE TO PLAY]
Video 1: The interactive project presentation
(source: selfmade / iPhone 5S)
Added is a .RAR file containing all files that were either created or borrowed for the realization of this project. The copyrights belong to their respective creators.
The picture library has been left out because of privacy reasons.