2017-02-08 1 views
1

Ich erkunde wunderbare mobile Vision Apis, ich arbeite an Face Tracker Beispiel und auf der Suche nach einer Lösung, wo ich herausfinden kann, ob der Mund offen ist oder nicht. z.B. Person gähnt. Es gibt keinen direkten Weg wie face.getIsLeftEyeOpenProbability();Android Mobile Vision API erkennen Mund ist offen

Also denke ich, dass ich herausfinden muss x, y Koordinaten der linken und rechten Mund den Unterschied herauszufinden und herauszufinden, ob die Maus offen ist oder nicht. Ich bin mir nicht sicher, ob das funktioniert oder nicht.

Aber können wir anders herausfinden, ob der Mund offen oder geschlossen ist?

Antwort

1

Leider unterstützt die Mobile Vision-API die Mundöffnungs-Erkennung nicht.

4

Die Mobile Vision-API bietet keine direkte Unterstützung für die Mouth-Erkennung. Aber dieser Code kann Ihnen helfen. Ich habe Charme auf meinem Gerät getestet und funktioniert.

@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 "); 
      } 
     } 
    } 

Und hier ist eine andere Methode.

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 - Dieser Code wird finden Mittelpunkt cordinates von linkem und rechtem Mund und finden die Differenz zwischen Bottom Mund cordinates und Mittelpunkte cordinates finden.

+0

Hallo @KulsDroid kann ich wissen, wo Sie diese Aussage mIsFrontFacing-Methode erhalten. Ich bekomme Fehler hier .. if (FaceTrackerActivity.mIsFrontFacing) { – Shadow

Verwandte Themen