toMap method
Converts this YOLOResult to a map representation.
This method is used for serializing the result for platform channel communication. The returned map contains all the properties of this result in a format suitable for transmission across platform channels.
Implementation
Map<String, dynamic> toMap() {
final map = <String, dynamic>{
'classIndex': classIndex,
'className': className,
'confidence': confidence,
'boundingBox': {
'left': boundingBox.left,
'top': boundingBox.top,
'right': boundingBox.right,
'bottom': boundingBox.bottom,
},
'normalizedBox': {
'left': normalizedBox.left,
'top': normalizedBox.top,
'right': normalizedBox.right,
'bottom': normalizedBox.bottom,
},
};
if (mask != null) {
map['mask'] = mask;
}
if (keypoints != null && keypointConfidences != null) {
final keypointsData = <double>[];
for (var i = 0; i < keypoints!.length; i++) {
keypointsData.add(keypoints![i].x);
keypointsData.add(keypoints![i].y);
keypointsData.add(keypointConfidences![i]);
}
map['keypoints'] = keypointsData;
}
return map;
}