Face.from constructor
Face.from(
- Map json
Implementation
factory Face.from(Map json) {
Map<FaceLandmarkType, FaceLandmark> landmarks = {};
Map<FaceContourType, FaceContour> contours = {};
if (json.containsKey('landmarks')) {
Map lmap = json['landmarks'];
for (String key in lmap.keys) {
FaceLandmarkType? type = toFaceLandmarkType(key);
Map point = lmap[key];
if (type != null) {
landmarks[type] = FaceLandmark(
type: type,
point: toPoint(point),
);
}
}
}
if (json.containsKey('contours')) {
Map cmap = json['contours'];
for (String key in cmap.keys) {
FaceContourType? type = toFaceContourType(key);
List points = cmap[key];
if (type != null) {
contours[type] = FaceContour(
type: type,
points: toPoints(points),
);
}
}
}
return Face(
boundingBox: toRect(json['bound']),
headAngleY: json['headAngleY'] as double,
headAngleZ: json['headAngleZ'] as double,
trackingId:
json.containsKey('trackingId') ? json['trackingId'] as int : null,
smilingProbability: json.containsKey('smilingProbability')
? json['smilingProbability'] as double
: null,
leftEyeOpenProbability: json.containsKey('leftEyeOpenProbability')
? json['leftEyeOpenProbability'] as double
: null,
rightEyeOpenProbability: json.containsKey('rightEyeOpenProbability')
? json['rightEyeOpenProbability'] as double
: null,
landmarks: landmarks,
countours: contours,
);
}