YOLODetectionResults.fromMap constructor
YOLODetectionResults.fromMap(
- Map map
Creates YOLODetectionResults from a map representation.
This factory constructor deserializes results received from the platform channel. The map should contain:
- 'detections': List of detection maps
- 'annotatedImage': (optional) Uint8List of image data
- 'semanticMask': (optional) semantic class map data
- 'processingTimeMs': double representing processing time
Implementation
factory YOLODetectionResults.fromMap(Map<dynamic, dynamic> map) {
final detectionsData = map['detections'] as List<dynamic>?;
final detections = detectionsData != null
? detectionsData
.map((detection) => YOLOResult.fromMap(detection))
.toList()
: <YOLOResult>[];
final annotatedImage = MapConverter.safeGetUint8List(map, 'annotatedImage');
final semanticMaskRaw = map['semanticMask'];
final semanticMask = semanticMaskRaw is Map
? YOLOSemanticMask.fromMap(semanticMaskRaw)
: null;
final depthMapRaw = map['depthMap'];
final depthMap = depthMapRaw is Map
? YOLODepthMap.fromMap(depthMapRaw)
: null;
final processingTimeMs = MapConverter.safeGetDouble(
map,
'processingTimeMs',
);
return YOLODetectionResults(
detections: detections,
annotatedImage: annotatedImage,
semanticMask: semanticMask,
depthMap: depthMap,
processingTimeMs: processingTimeMs,
);
}