Giter VIP home page Giter VIP logo

Comments (5)

emilianavt avatar emilianavt commented on May 23, 2024

Hi! You are correct in that there are issues with the eye open/closed features. I am currently doing some ugly threshold things in C# to actually work with those values for avatar animation. You can see the code here:

if (openSeeData != null && lastBlink < openSeeData.time) {
lastBlink = openSeeData.time;
blinkInterpolate.UpdateTime(lastBlink);
float openThreshold = eyeOpenedThreshold;
float closedThreshold = eyeClosedThreshold;
if (openSeeData.rawEuler.y < turnLeftBoundaryAngle || openSeeData.rawEuler.y > turnRightBoundaryAngle)
openThreshold = Mathf.Lerp(eyeOpenedThreshold, eyeClosedThreshold, 0.4f);
if (lookDownCompensation && upDownAngle > turnDownBoundaryAngle - lookDownAdjustment - wasLookingDown) {
openThreshold = Mathf.Lerp(eyeOpenedThreshold, eyeClosedThreshold, 0.85f);
closedThreshold = Mathf.Lerp(eyeClosedThreshold, 0f, 0.6f);
if (upDownAngle > turnDownBoundaryAngle - lookDownAdjustment + 10f) {
openThreshold = 0.1f;
closedThreshold = 0f;
}
wasLookingDown = 1.5f;
} else {
wasLookingDown = 0f;
}
if (openSeeData.rightEyeOpen > openThreshold)
right = 0f;
else if (openSeeData.rightEyeOpen < closedThreshold)
right = 1f;
else
right = 1f - (openSeeData.rightEyeOpen - closedThreshold) / (openThreshold - closedThreshold);
if (openSeeData.leftEyeOpen > openThreshold)
left = 0f;
else if (openSeeData.leftEyeOpen < closedThreshold)
left = 1f;
else
left = 1f - (openSeeData.leftEyeOpen - closedThreshold) / (openThreshold - closedThreshold);
if (openSeeData.rawEuler.y < turnLeftBoundaryAngle)
left = right;
if (openSeeData.rawEuler.y > turnRightBoundaryAngle)
right = left;
if (linkBlinks) {
if (Mathf.Abs(right - left) < 0.95 || !allowWinking) {
float v = Mathf.Max(left, right);
left = v;
right = v;
}
}
lastBlinkLeft = Mathf.Lerp(lastBlinkLeft, currentBlinkLeft, t);
lastBlinkRight = Mathf.Lerp(lastBlinkRight, currentBlinkRight, t);
currentBlinkLeft = Mathf.Lerp(currentBlinkLeft, left, 1f - blinkSmoothing);
currentBlinkRight = Mathf.Lerp(currentBlinkRight, right, 1f - blinkSmoothing);
if (left < 0.00001f)
currentBlinkLeft = 0f;
if (right < 0.00001f)
currentBlinkRight = 0f;
if (left > 0.99999f)
currentBlinkLeft = 1f;
if (right > 0.99999f)
currentBlinkRight = 1f;
}

I'm not exactly sure where the issues are and how to fix them though.

from openseeface.

marzi9696 avatar marzi9696 commented on May 23, 2024

Hi.I figured why the ratios were so variant and it's because the landmarks x,y coordinates are based on the whole frame not the detected face frame so when someone is closer to the camera the ratio gets larger and vice versa so I mapped the landmarks to the detected face frame and it got so much better but still it's variant depending on the different individuals understandably.
it's my code:

def lms_on_face (f,frame):
    height, width, channels = frame.shape
    lms = f.lms
    face_bbox = f.bbox
    face_x = face_bbox[0]
    face_y = face_bbox[1]
    face_w = face_bbox[2] + face_x
    face_h = face_bbox[3] + face_y
    face = frame[int(face_y):int(face_h),int(face_x):int(face_w)]
    face_h,face_w,_ = frame[int(face_y):int(face_h),int(face_x):int(face_w)].shape
    face_x = 0
    face_y = 0
    frame_bbox = (0,0,width,height)
    fx = 0
    fy = 0
    fw = width
    fh = height
    points = [36,37,38,39,40,41]

    for i , (x,y,c) in enumerate(lms):
        if i in points:
            x = translate(x,0,fw,0,face_w)
            y = translate(y,0,fh,0,face_h)
            lms[i] = (x,y,c)
    return lms

then I use the ratio formula and get an average based on both eyes.hope it helps someone.

from openseeface.

emilianavt avatar emilianavt commented on May 23, 2024

Interesting, that makes sense! Thank you for posting your solution to this issue!

Thinking about it some more, if this was the cause, you could also try using f.pts_3d for your calculation as it should be somewhat pose invariant.

from openseeface.

marzi9696 avatar marzi9696 commented on May 23, 2024

from openseeface.

emilianavt avatar emilianavt commented on May 23, 2024

The order of landmarks is the same. There are additional points for the guesstimated eyeball centers in pts_3d.

from openseeface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.