Processing: Clean up

Currently I’m very happy with the stage my face swapping project is at, and at the moment it is a matter of cleaning up my code while I think of further developments and improvements I can make on it.

Before my setup I have 4 lines similar to this ‘PImage face0 = createImage(0, 0, RGB);’ which is the PImages used to store the captured faces from the face tracking. I’ve now learned that it doesn’t require a blank image to store it in and therefore can be simplified to just ‘PImage face0;’.

I’ve also re-ordered the swapping for when there are 4 detected faces on screen. In a previous post I drew a table to keep track of my swapping while writing it but I now realise that the order doesn’t make sense for the 4 face swap. The faces are swapped with the next one along in the array (i.e face 1 in place of, 2 moved to 3 etc.) with the exception of the last face which is moved to the beginning of the array to be swapped with the first face (hopefully this description makes sense). This is a first progression to a rather confusing idea I had to try to streamline my code a bit more.

I want to try to store the captured faces in an array rather than 4 individual PImages, as it would hopefully eliminate a lot of the repeated lines of code which have very small differences. I could then capture the faces and swap them using for loops to access various faces in the array and work from there. I’ve tried to get my head around doing this but having the masking and resizing has made it significantly harder than I originally expected so I’m yet to blog about any progress until/ if I work it out.

These small changed might not seem that significant but I feel it is good practice to keep the code as simple as possible without any excess clutter to confuse things or slow them down.

%d bloggers like this: