Previously in Mirror, we learnt how face tracking works and now we have to find a way to do a “faceswap filter” on max. One of the issue I faced was that the face tracking bounding box isn’t as accurate as I want it to be, thus the image is not exactly at the right coordinates.
So for this project, I’ve learnt that we can send and receive objects simply by using “s” or “r” and it makes everything so much more organised!
But first, we have to put in our image. Simply use read imagename.jpg, don’t forget to press bang! to load the image up.
clear, usedstdim 1, dstdimstart $1 $2, distdimend $3 $4
To refresh our memory, dstdimstart and dstdimend is set the start and end position of where we want the image to be. This matches the x & y coordinates of the detected face.
jit.fastblur @mode 1 @range 2
To soften the image and its edges, we have to use “jit.fastblur @mode 1 @range 2”. If you want the image to be clearer, you have to reduce the value of @mode, to blur it simply increase the value. For range, it soften the edges.
jit.alphablend @mode 1
This merges the masked image and the camera capture. For mode 1, it displays both the mask image and camera capture. If you were to use mode 0, it will just display the masked image.
As you can see here, I tried using different values for jit.fastblur to see its effects.
For jit.fastblur @mode 1 @range 2: The face is much clearer and defined, edges however need to be softer.
For jit.fastblur @mode 2 @range 3: The face is slightly blurred but we can still see her features, adjusted the range to 3 to make edges softer . This might be a better option.
I felt that my masked image could have been blended even better, as I can still see some of the harsh lines of the image. But when I tried to softened the edges even more, the mask image would lose its features. Anyhow, this was a fun project as I understood the mechanism behind those face swap filters hahaha. Here is the video!