I'm always looking for something new to do for the yearly slide show. As I mentioned before I've got a script that can be used render the same file over and over again replacing the pictures in it to make a whole show (viewtopic.php?f=93&t=11347 - wow was that really 2012...). Recently I used this with some gradient fades based on noise textures.
These worked well but were just randomly applied at the transitions. However sometimes the fade would start with a point of interest in the picture - say a person or place - and that looked good. So it got me thinking and I've built a python script to automatically create a gradient based on the position of the face(s) in a photo. A video is worth a million words so here's an example:
You can see that the fade is centred on the face or faces in the photos. The gradient for the change from the first to second face is this:
The black part, where the fade starts, is offset in the image to the position of the second face.
Now for the science bit...
Technically what I've done is use a package called MTCNN (https://github.com/ipazc/mtcnn) which uses the tensorflow machine learning platform to do the face recognition. This returns a list of bounding boxes that are what it detects as faces within the photo. I've then written a routine to generate a circular gradient that centres around these boxes and adds a little bit of "noise" to it to make the fade more interesting. Whilst it sounds complicated all of the heavy lifting is done using a library so once it's set up (which is quite a fussy process) there is actually quite a small amount of code required. Rinse and repeat for the entire slide show