compute method
Performs tracking for the targets registered with addTarget and returns the tracked objects.
Implementation
List<AiliaTrackerObject> compute() {
if (!available) {
throw Exception("Tracker not created");
}
int status = ailiaTracker.ailiaTrackerCompute(ppAiliaTracker!.value);
if (status != ailiaStatusSuccess) {
throw Exception("ailiaTrackerCompute error $status");
}
final Pointer<UnsignedInt> count = malloc<UnsignedInt>();
count.value = 0;
status = ailiaTracker.ailiaTrackerGetObjectCount(
ppAiliaTracker!.value,
count,
);
if (status != ailiaStatusSuccess) {
malloc.free(count);
throw Exception("ailiaTrackerGetObjectCount error $status");
}
final List<AiliaTrackerObject> objects = [];
final Pointer<ailia_tracker_dart.AILIATrackerObject> obj =
malloc<ailia_tracker_dart.AILIATrackerObject>();
for (int i = 0; i < count.value; i++) {
status = ailiaTracker.ailiaTrackerGetObject(
ppAiliaTracker!.value,
obj,
i,
ailia_tracker_dart.AILIA_TRACKER_OBJECT_VERSION,
);
if (status != ailiaStatusSuccess) {
malloc.free(obj);
malloc.free(count);
throw Exception("ailiaTrackerGetObject error $status");
}
objects.add(AiliaTrackerObject(
id: obj.ref.id,
category: obj.ref.category,
prob: obj.ref.prob,
x: obj.ref.x,
y: obj.ref.y,
w: obj.ref.w,
h: obj.ref.h,
));
}
malloc.free(obj);
malloc.free(count);
return objects;
}