Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Face texture. #19

Open
SurrealNautilus opened this issue Jun 3, 2019 · 5 comments
Open

Face texture. #19

SurrealNautilus opened this issue Jun 3, 2019 · 5 comments

Comments

@SurrealNautilus
Copy link

Hi! I'm very surprised by the quality of your work! I wonder if it is possible to put a more abstract texture on the face ?. It's possible?.

@MarekKowalski
Copy link
Owner

Hi,
In order to map a different texture you will need to provide the texture coordinates to textureCoords in line 41 in zad2.py file. Altenatively, if the texture you want to use resembles a face, but is too hard for the landamark detector to work you can modify the getTextureCoords function to work with manually specified facial landmarks.

Marek

@wangbo9426
Copy link

Hi,Can you explain the function getTextureCoords?

@MarekKowalski
Copy link
Owner

MarekKowalski commented Dec 17, 2019

Hi,
given an imagee, this function detects the face and its landmarks.
It then fits the 3D model to the landmarks and outputs the image coordinates to which the vertices of the 3D model project to.
Marek

@wangbo9426
Copy link

Hi ,Thanks for your response!Actually I don't know the code details.Could you note with english?hhhhh

 def fun(self,x,params):
    #skalowanie
    s = params [0]
    #rotacja
    r = params [1:4]
    #przesuniecie(translacja)
    t = params [4:6]
    w = params [6: ]
    mean3DShape = x[0]
    blendshapes = x[1]
    #macierz rotacji z wektora rotacji, wzor Rodriguesa
    R = cv2.Rodrigues(r)[0]
    P = R[:2]
    shape3D = mean3DShape + np.sum(w[:, np.newaxis, np.newaxis] * blendshapes, axis=0)

    projected = s * np.dot(P, shape3D) + t[:, np.newaxis]

    return projected

@MarekKowalski
Copy link
Owner

Her eit is:

 def fun(self,x,params):
    #scale
    s = params [0]
    #rotation
    r = params [1:4]
    #translation
    t = params [4:6]
    w = params [6: ]
    mean3DShape = x[0]
    blendshapes = x[1]
    # going from rotation vector to rotation matrix, Rodrigues formula
    R = cv2.Rodrigues(r)[0]
    P = R[:2]
    # 3D shape is sum of mean shape and weighted sum of blendshapes
    shape3D = mean3DShape + np.sum(w[:, np.newaxis, np.newaxis] * blendshapes, axis=0)
    # Orthographic projection
    projected = s * np.dot(P, shape3D) + t[:, np.newaxis]

    return projected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants