Swap Faces Using OpenCV

Generated Image

Time to swap faces!

  • haarcascade_frontalface_default.xml is the pre-trained model that I have used which helps me find the coordinates of the face. You can find the same here
  • p1x1, p2x2 etc. are all the coordinates of the faces of photo 1 and 2.
  • cphoto1 and cphoto2 are the cropped photos. tcphoto2 is kind of a temporary image which accompanies us in the swap.
  • In the for loops then the cropped photos are swapped, so that the faces can be swapped.

Unlisted

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store