Microsoft Face API を使用して、Android で顔と感情を検出しています。キーがTreeMap感情属性の確率であり、値が次のような属性名です。
TreeMap<Double, String> treeMap = new TreeMap<>();
treeMap.put(person.faceAttributes.emotion.happiness, "Happiness");
treeMap.put(person.faceAttributes.emotion.anger, "Anger");
treeMap.put(person.faceAttributes.emotion.disgust, "Disgust");
treeMap.put(person.faceAttributes.emotion.sadness, "Sadness");
treeMap.put(person.faceAttributes.emotion.neutral, "Neutral");
treeMap.put(person.faceAttributes.emotion.surprise, "Surprise");
treeMap.put(person.faceAttributes.emotion.fear, "Fear");
( person は 型のオブジェクトですFace)
私がやりたいのは、これらの 7 つの感情を最も可能性が高いものから最も可能性が低いものにランク付けすることですが、問題はのサイズがtreeMapさまざまであることです。たとえば、笑顔の顔の感情属性を取得することを選択すると、2treeMap.size()が返されます。主にニュートラルな顔の感情属性を取得することを選択すると、3が返されます。treeMap.size()
treeMapusingに 7 つのキーと値のペアを追加したにもかかわらず、この動作が発生する理由を知っている人はいますtreeMap.put()か? に存在するキーと値のペアがtreeMap最も可能性の高い感情であることがわかりましたが、他の属性が 0 であったとしても、それらがまだ に追加されていないのはなぜですかtreeMap。