Close

Ideas for Further Development/Code Explanation

A project log for Beer Goggles

Augmented Reality --Moronic Humor Whats not to Love

daxmoonjuiceDaxMoonJuice 04/26/2016 at 16:440 Comments

Ideas for expansion.

-Swapping the face detection function for a body detection function. OpenCV provides Haar-cascade files for this. Implementation should be as simple as swapping the files

-Randomizing the image which is placed over the detected face

-Experimenting with face-swapping. In OpenCV detected faces are stored as a NumPy array within a rectangle. Overlaying images on this face is made simple thanks to OpenCV library. You simply scale the image to match the size of the face box and then move all the pixels (NumPy array) into the face box.

//Code to Overlay smaller image over the main image

s_img=cv2.imread("smileyface.jpg")
s_img=cv2.cvtColor(s_img, cv2,COLOR_BGR2GRAY)

// w and h are two of the four co-ordinates of the facebox
dim=(w,h)

//resizes s_img by moving two-coordinates of s_img to the position of w,h on the facebox, interpolation is set to cv2.INTER_AREA
 
s_img=cv2.resize(s_img,dim, interpolation =cv2.INTER_AREA)

c1=y
r1=x

//sets the area defined by c1 and r1 in the mainImage to equal the contents of s_img.

offset1=s_img.shape[0]
mainImage[c1 : c1+offset1, r1 : r1+offset1]=s_img
So if inserting a new image over the main image is easy and faces are stored as numpy arrays then face swapping would just involve copying the first face storing it then pasting the second face over the first face and then finally placing the store face over the second face.

Discussions