classificationResultFromNative function
Converts a native classification result before its owner is released.
Implementation
ClassificationResult classificationResultFromNative(bindings.MpClassificationResult value) {
final List<Classifications> heads = List<Classifications>.generate(value.classifications_count, (
int headIndex,
) {
final bindings.MpClassifications head = value.classifications[headIndex];
return Classifications(
categories: List<Category>.generate(
head.categories_count,
(int categoryIndex) => categoryFromNative(head.categories[categoryIndex]),
),
headIndex: head.head_index,
headName: nativeString(head.head_name),
);
}, growable: false);
return ClassificationResult(
classifications: heads,
timestampMs: value.has_timestamp_ms ? value.timestamp_ms : null,
);
}