decodeFaceDetectorResult function
Decodes a Face Detector result. Google's boxes are float pixels; the Dart boxes are whole pixels, truncated as the C API does.
Implementation
FaceDetectorResult decodeFaceDetectorResult(VisionResultData data) =>
FaceDetectorResult(
imageWidth: data.width,
imageHeight: data.height,
timestampMilliseconds: data.timestamp,
detections: [
for (final d in data.result['detections'] as List)
Detection(
boundingBox: _box((d as Map)['boundingBox']),
categories: _categories(d['categories']),
keypoints: [
for (final k in (d['keypoints'] as List?) ?? const [])
NormalizedKeypoint(
x: _number((k as Map)['x']),
y: _number(k['y']),
label: decodeLabel(k['label']),
score: _optional(k['score']),
),
],
),
],
);