2017-02-08 1 views
1

J'explore merveilleuse apis de vision mobile, je travaille sur Face Tracker exemple et à la recherche d'une solution où je peux savoir si la bouche est ouverte ou non. par exemple. la personne bâille. Donc je pense que j'ai besoin de trouver les coordonnées x, y de la bouche gauche et droite pour trouver la différence et savoir si la souris est ouverte ou non. Je ne suis pas sûr que cela fonctionnera ou non.Android Mobile Vision API détecter la bouche est ouverte

Mais y a-t-il un autre moyen de savoir si la bouche est ouverte ou fermée?

Répondre

1

Malheureusement, l'API Mobile Vision ne prend pas en charge la détection d'ouverture de bouche.

4

L'API Mobile Vision ne prend pas directement en charge la détection d'ouverture/fermeture de bouche. Mais ce code peut vous aider. J'ai testé et travaillé le charme sur mon appareil.

@Override 
    public void draw(Canvas canvas) { 

     Face face = mFace; 

     if (face == null) { 
      return; 
     } 

     if ((contains(face.getLandmarks(), 11) != 99) 
       && (contains(face.getLandmarks(), 5) != 99) 
       && (contains(face.getLandmarks(), 6) != 99) 
       ) { 

      Log.i(TAG, "draw: Mouth Open >> found all the points"); 

      /** 
      * for bottom mouth 
      */ 
      int cBottomMouthX; 
      int cBottomMouthY; 
      if (FaceTrackerActivity.mIsFrontFacing) { 
       cBottomMouthX = (int) translateX(face.getLandmarks().get(contains(face.getLandmarks(), 0)).getPosition().x); 
       cBottomMouthY = (int) translateY(face.getLandmarks().get(contains(face.getLandmarks(), 0)).getPosition().y); 

       Log.i(TAG, "draw: Condition Bottom mouth >> cBottomMouthX >> " + cBottomMouthX + " cBottomMouthY >> " + cBottomMouthY); 


      } else { 
       cBottomMouthX = (int) translateX(face.getLandmarks().get(contains(face.getLandmarks(), 0)).getPosition().x); 
       cBottomMouthY = (int) translateY(face.getLandmarks().get(contains(face.getLandmarks(), 0)).getPosition().y); 
      } 
      canvas.drawCircle(cBottomMouthX, cBottomMouthY, 10, mPaint); 

      /** 
      * for left mouth 
      */ 
      int cLeftMouthX; 
      int cLeftMouthY; 
      if (FaceTrackerActivity.mIsFrontFacing) { 
       cLeftMouthX = (int) translateX(face.getLandmarks().get(contains(face.getLandmarks(), 5)).getPosition().x); 
       cLeftMouthY = (int) translateY(face.getLandmarks().get(contains(face.getLandmarks(), 5)).getPosition().y); 

       Log.i(TAG, "draw: Condition LEft mouth >> cLeftMouthX >> " + cLeftMouthX + " cLeftMouthY >> " + cLeftMouthY); 


      } else { 
       cLeftMouthX = (int) translateX(face.getLandmarks().get(contains(face.getLandmarks(), 5)).getPosition().x); 
       cLeftMouthY = (int) translateY(face.getLandmarks().get(contains(face.getLandmarks(), 5)).getPosition().y); 
      } 
      canvas.drawCircle(cLeftMouthX, cLeftMouthY, 10, mPaint); 

      /** 
      * for Right mouth 
      */ 
      int cRightMouthX; 
      int cRightMouthY; 
      if (FaceTrackerActivity.mIsFrontFacing) { 
       cRightMouthX = (int) translateX(face.getLandmarks().get(contains(face.getLandmarks(), 11)).getPosition().x); 
       cRightMouthY = (int) translateY(face.getLandmarks().get(contains(face.getLandmarks(), 11)).getPosition().y); 

       Log.i(TAG, "draw: Condition Right mouth >> cRightMouthX >> " + cRightMouthX + " cRightMouthY >> " + cRightMouthY); 


      } else { 
       cRightMouthX = (int) translateX(face.getLandmarks().get(contains(face.getLandmarks(), 11)).getPosition().x); 
       cRightMouthY = (int) translateY(face.getLandmarks().get(contains(face.getLandmarks(), 11)).getPosition().y); 
      } 
      canvas.drawCircle(cRightMouthX, cRightMouthY, 10, mPaint); 

      float centerPointX = (cLeftMouthX + cRightMouthX)/2; 
      float centerPointY = ((cLeftMouthY + cRightMouthY)/2) - 20; 

      canvas.drawCircle(centerPointX, centerPointY, 10, mPaint); 

      float differenceX = centerPointX - cBottomMouthX; 
      float differenceY = centerPointY - cBottomMouthY; 

      Log.i(TAG, "draw: difference X >> " + differenceX + "  Y >> " + differenceY); 

      if (differenceY < (-60)) { 
       Log.i(TAG, "draw: difference - Mouth is OPENED "); 
      } else { 
       Log.i(TAG, "draw: difference - Mouth is CLOSED "); 
      } 
     } 
    } 

Et voici une autre méthode.

int contains(List<Landmark> list, int name) { 
    for (int i = 0; i < list.size(); i++) { 
     if (list.get(i).getType() == name) { 
      return i; 
     } 
    } 
    return 99; 
} 

P.S - Ce code trouverez de trouver le point centre cordinates de la bouche à gauche et à droite et trouver la différence entre la bouche et fond cordinates points centraux cordinates.

+0

Bonjour @KulsDroid puis-je savoir où vous obtenez cette méthode mIsFrontFacing déclaration. Je reçois erreur ici .. if (FaceTrackerActivity.mIsFrontFacing) { – Shadow