70 lines
1.7 KiB
Dart
70 lines
1.7 KiB
Dart
class DetectionResult {
|
|
final String label;
|
|
final double score;
|
|
final double left;
|
|
final double top;
|
|
final double right;
|
|
final double bottom;
|
|
|
|
/// 轨迹已确认(多帧稳定/高分/活动确认),false = 候选,渲染为虚线
|
|
final bool confirmed;
|
|
|
|
/// 类别索引:0 = 目标物种(红色框),>0 = suspect(黄色框);-1 = 未知
|
|
final int classId;
|
|
|
|
/// 产出该框的模型(数据集 id 与名称;无来源为 -1/空)
|
|
final int modelId;
|
|
final String modelName;
|
|
|
|
const DetectionResult({
|
|
required this.label,
|
|
required this.score,
|
|
required this.left,
|
|
required this.top,
|
|
required this.right,
|
|
required this.bottom,
|
|
this.confirmed = true,
|
|
this.classId = -1,
|
|
this.modelId = -1,
|
|
this.modelName = '',
|
|
});
|
|
|
|
double get width => right - left;
|
|
double get height => bottom - top;
|
|
double get centerX => (left + right) / 2;
|
|
double get centerY => (top + bottom) / 2;
|
|
|
|
DetectionResult copyWith({
|
|
double? score,
|
|
double? left,
|
|
double? top,
|
|
double? right,
|
|
double? bottom,
|
|
bool? confirmed,
|
|
}) =>
|
|
DetectionResult(
|
|
label: label,
|
|
score: score ?? this.score,
|
|
left: left ?? this.left,
|
|
top: top ?? this.top,
|
|
right: right ?? this.right,
|
|
bottom: bottom ?? this.bottom,
|
|
confirmed: confirmed ?? this.confirmed,
|
|
classId: classId,
|
|
modelId: modelId,
|
|
modelName: modelName,
|
|
);
|
|
}
|
|
|
|
class MotionRegion {
|
|
final double left;
|
|
final double top;
|
|
final double right;
|
|
final double bottom;
|
|
|
|
const MotionRegion(this.left, this.top, this.right, this.bottom);
|
|
|
|
double get centerX => (left + right) / 2;
|
|
double get centerY => (top + bottom) / 2;
|
|
}
|