Ejemplo n.º 1
0
 private void updatePreviousProportions(Face face) {
   for (Landmark landmark : face.getLandmarks()) {
     PointF position = landmark.getPosition();
     float xProp = (position.x - face.getPosition().x) / face.getWidth();
     float yProp = (position.y - face.getPosition().y) / face.getHeight();
     mPreviousProportions.put(landmark.getType(), new PointF(xProp, yProp));
   }
 }
Ejemplo n.º 2
0
  /**
   * Finds a specific landmark position, or approximates the position based on past observations if
   * it is not present.
   */
  private PointF getLandmarkPosition(Face face, int landmarkId) {
    for (Landmark landmark : face.getLandmarks()) {
      if (landmark.getType() == landmarkId) {
        return landmark.getPosition();
      }
    }

    PointF prop = mPreviousProportions.get(landmarkId);
    if (prop == null) {
      return null;
    }

    float x = face.getPosition().x + (prop.x * face.getWidth());
    float y = face.getPosition().y + (prop.y * face.getHeight());
    return new PointF(x, y);
  }