using System.Collections.Generic;
namespace InteractiveVideo
{
///
/// All tracked object states for one video frame.
/// Loaded frames are sparse (tracking may run at a lower rate than the video); the manager
/// resolves a video frame into a frame like this by nearest lookup or interpolation.
///
public sealed class TrackingFrame
{
public long Frame;
public readonly List Objects = new List(8);
/// Linear search: frames hold a handful of objects, a dictionary would allocate on rebuild.
public bool TryGet(string trackId, out TrackedObjectInstance instance)
{
for (int i = 0; i < Objects.Count; i++)
{
if (Objects[i].TrackId == trackId)
{
instance = Objects[i];
return true;
}
}
instance = null;
return false;
}
public int IndexOf(string trackId)
{
for (int i = 0; i < Objects.Count; i++)
if (Objects[i].TrackId == trackId) return i;
return -1;
}
}
}