|
@@ -22,10 +22,10 @@ namespace bbiwarg.Recognition.Tracking
|
|
private bool wasTrackedBefore;
|
|
private bool wasTrackedBefore;
|
|
|
|
|
|
public int ID { get; private set; }
|
|
public int ID { get; private set; }
|
|
- public List<T> DetectedObjects;
|
|
|
|
- public T CurrentObject { get { return DetectedObjects[DetectedObjects.Count - 1]; } }
|
|
|
|
- public List<TrackingState> States;
|
|
|
|
- public TrackingState CurrentState { get { return States[States.Count - 1]; } }
|
|
|
|
|
|
+ public T CurrentObject { get; private set; }
|
|
|
|
+ public T LastObject { get; private set; }
|
|
|
|
+ public TrackingState CurrentState { get; private set; }
|
|
|
|
+ public TrackingState PreviousState { get; private set; }
|
|
public int NumFramesInCurrentState { get; private set; }
|
|
public int NumFramesInCurrentState { get; private set; }
|
|
|
|
|
|
public TrackedObject(int id, T detectedObject, int numFramesDetectedUntilTracked, int numFramesLostUntilDeleted)
|
|
public TrackedObject(int id, T detectedObject, int numFramesDetectedUntilTracked, int numFramesLostUntilDeleted)
|
|
@@ -34,11 +34,11 @@ namespace bbiwarg.Recognition.Tracking
|
|
this.numFramesDetectedUntilTracked = numFramesDetectedUntilTracked;
|
|
this.numFramesDetectedUntilTracked = numFramesDetectedUntilTracked;
|
|
this.numFramesLostUntilDeleted = numFramesLostUntilDeleted;
|
|
this.numFramesLostUntilDeleted = numFramesLostUntilDeleted;
|
|
wasTrackedBefore = false;
|
|
wasTrackedBefore = false;
|
|
- DetectedObjects = new List<T>();
|
|
|
|
- States = new List<TrackingState>();
|
|
|
|
|
|
|
|
- DetectedObjects.Add(detectedObject);
|
|
|
|
- States.Add(TrackingState.Detected);
|
|
|
|
|
|
+ CurrentObject = detectedObject;
|
|
|
|
+ LastObject = detectedObject;
|
|
|
|
+ CurrentState = TrackingState.Detected;
|
|
|
|
+ PreviousState = TrackingState.Undefined;
|
|
NumFramesInCurrentState = 1;
|
|
NumFramesInCurrentState = 1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -47,18 +47,21 @@ namespace bbiwarg.Recognition.Tracking
|
|
public virtual void updateFrame(T detectedObject)
|
|
public virtual void updateFrame(T detectedObject)
|
|
{
|
|
{
|
|
if (detectedObject != null)
|
|
if (detectedObject != null)
|
|
|
|
+ {
|
|
detectedObject.setTracked(ID);
|
|
detectedObject.setTracked(ID);
|
|
|
|
+ LastObject = detectedObject;
|
|
|
|
+ }
|
|
|
|
|
|
- TrackingState previousState = CurrentState;
|
|
|
|
TrackingState newState = getNewState(detectedObject);
|
|
TrackingState newState = getNewState(detectedObject);
|
|
|
|
|
|
if (!wasTrackedBefore && newState == TrackingState.Tracked)
|
|
if (!wasTrackedBefore && newState == TrackingState.Tracked)
|
|
wasTrackedBefore = true;
|
|
wasTrackedBefore = true;
|
|
|
|
|
|
- DetectedObjects.Add(detectedObject);
|
|
|
|
- States.Add(newState);
|
|
|
|
|
|
+ PreviousState = CurrentState;
|
|
|
|
+ CurrentState = newState;
|
|
|
|
+ CurrentObject = detectedObject;
|
|
|
|
|
|
- if (previousState == newState)
|
|
|
|
|
|
+ if (PreviousState == newState)
|
|
NumFramesInCurrentState++;
|
|
NumFramesInCurrentState++;
|
|
else
|
|
else
|
|
NumFramesInCurrentState = 1;
|
|
NumFramesInCurrentState = 1;
|
|
@@ -66,12 +69,11 @@ namespace bbiwarg.Recognition.Tracking
|
|
|
|
|
|
private TrackingState getNewState(T detectedObject)
|
|
private TrackingState getNewState(T detectedObject)
|
|
{
|
|
{
|
|
- TrackingState previousState = CurrentState;
|
|
|
|
TrackingState newState = TrackingState.Undefined;
|
|
TrackingState newState = TrackingState.Undefined;
|
|
|
|
|
|
if (detectedObject != null)
|
|
if (detectedObject != null)
|
|
{
|
|
{
|
|
- switch (previousState)
|
|
|
|
|
|
+ switch (CurrentState)
|
|
{
|
|
{
|
|
case TrackingState.Lost:
|
|
case TrackingState.Lost:
|
|
if (wasTrackedBefore)
|
|
if (wasTrackedBefore)
|
|
@@ -90,7 +92,7 @@ namespace bbiwarg.Recognition.Tracking
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if (previousState == TrackingState.Lost && NumFramesInCurrentState >= numFramesLostUntilDeleted)
|
|
|
|
|
|
+ else if (CurrentState == TrackingState.Lost && NumFramesInCurrentState >= numFramesLostUntilDeleted)
|
|
newState = TrackingState.Deleted;
|
|
newState = TrackingState.Deleted;
|
|
else
|
|
else
|
|
newState = TrackingState.Lost;
|
|
newState = TrackingState.Lost;
|