Today we are going to create an image, swap some part of the two photos and then combine them side to side using OpenCV library in python, so let's start:
Creating Image:
As we know that an image can be represented as an array of numbers (2D/3D) depending on color scheme. To create our image we will first create an image of white background as (255,255,255) is a color scheme for white by using an array of dimension 1200*900 then we will assign certain parts of this white background image with colors.
Output Image:
Swapping & Combining Images:
Now, we will swap faces of two different people with each other on similar size images and after swapping we will combine them by concatenating them on same window. For this we used 2 libraries and one face detection model :
-open-cv
-numpy
-haarcascade_frontalface_default
How we get this done can be seen as follows:
As we fit these faces in each others body, we then concatenate them in one image and show them in one window as follows:
Output: