detectionResultFromNative function
Converts a native detection result before its owner is released.
Implementation
DetectionResult detectionResultFromNative(bindings.MpDetectionResult value, {int? timestampMs}) =>
DetectionResult(
detections: List<Detection>.generate(value.detections_count, (int index) {
final bindings.MpDetection detection = value.detections[index];
return Detection(
categories: List<Category>.generate(
detection.categories_count,
(int categoryIndex) => categoryFromNative(detection.categories[categoryIndex]),
growable: false,
),
boundingBox: BoundingBox(
left: detection.bounding_box.left,
top: detection.bounding_box.top,
width: detection.bounding_box.right - detection.bounding_box.left,
height: detection.bounding_box.bottom - detection.bounding_box.top,
),
keypoints: List<NormalizedKeypoint>.generate(detection.keypoints_count, (
int keypointIndex,
) {
final bindings.MpNormalizedKeypoint keypoint = detection.keypoints[keypointIndex];
return NormalizedKeypoint(
x: keypoint.x,
y: keypoint.y,
label: nativeString(keypoint.label),
score: keypoint.has_score ? keypoint.score : null,
);
}, growable: false),
);
}, growable: false),
timestampMs: timestampMs,
);