faceInfoLabelText function
Builds the compact per-face info text drawn by drawFaceInfoLabel: detection confidence (plus mesh confidence when available) on the first line, head pose Euler angles on the second. In fast mode (no mesh) only roll is shown, since pitch/yaw are not estimated there.
When showClassification is true and the face carries blendshape scores
(full mode), a third line shows the smile and per-eye open probabilities.
Implementation
String faceInfoLabelText(Face face, {bool showClassification = false}) {
final StringBuffer buf = StringBuffer(
'score ${face.score.toStringAsFixed(2)}',
);
final double? meshScore = face.meshScore;
if (meshScore != null) {
buf.write(' mesh ${meshScore.toStringAsFixed(2)}');
}
final HeadEulerAngles? angles = face.headEulerAngles;
if (angles != null) {
buf.write('\n');
if (face.mesh != null) {
buf
..write('P ${angles.x.toStringAsFixed(0)}° ')
..write('Y ${angles.y.toStringAsFixed(0)}° ')
..write('R ${angles.z.toStringAsFixed(0)}°');
} else {
buf.write('R ${angles.z.toStringAsFixed(0)}°');
}
}
if (showClassification) {
final double? smile = face.smilingProbability;
if (smile != null) {
buf
..write('\nsmile ${smile.toStringAsFixed(2)} ')
..write('eyeL ${face.leftEyeOpenProbability!.toStringAsFixed(2)} ')
..write('eyeR ${face.rightEyeOpenProbability!.toStringAsFixed(2)}');
}
}
return buf.toString();
}