arturoc / FaceSubstitution

Face substitution experiments using ofxFacetracker
Other
436 stars 120 forks source link

Create a custom mask without eyes and mouth #34

Closed Javingka closed 8 years ago

Javingka commented 8 years ago

Hello,

I need a little bit of orientation

I am trying to achieve a face substitution, using a 'mask' that is a 'faceless' image. I mean, replace my actual face with a face without eyes, mouth and nose.

The first problem was, if I passed an image without face, the ofxFaceTracker object didn't recognize any face obviously!.

So I thought, I can have two version of my mask image. one with the face so I can get the source points, and another faceless to use it as the texture.

So within loadFace, I pass the face image to the srcTracker as usual, and then I update the src variable.

void ofApp::loadFace(string face){
     src.loadImage(face); 
     if(src.getWidth() > 0) {
        srcTracker.update(toCv(src));
        srcPoints = srcTracker.getImagePoints();
    }

    /* Replace the src image to get the faceless texture */    
    vector<string> splitString = ofSplitString( face, "/");
    vector<string> splitString2 = ofSplitString( splitString[1], ".");
    string faceless = "faceless/"+splitString2[0]+ "_.jpg";
    src.loadImage(faceless);
 }

Then, inside the update function I set the clone strength to a high number to make my face less prominent in the image, this is more or less working, but I need help with the mask. my questions:

How modify the mask mesh??, so avoid holes in the eyes and mouth. Do I need to modify the srcPoints vector ??.

Maybe there are some better approach to achieve what I want?

Thanks for the help in advance!

Javingka commented 8 years ago

Well, finally I made a seam in the mask to avoid the holes. It is not the cleanest solution, but makes the job by now.

I saw on the getFeatureIndex() method from ofxFaceTracker.cpp file that I can know what are the ids of the different parts of the mesh, so I implemented within the template <class T> ofMesh ofxFaceTracker::getMesh(vector<T> points) const {....} method in ofxFaceTracker.h, a 'filter' to set the 'seam' of the eyes and mouth closing its holes.

Anyway, any other idea or approach is very welcome.