Skip to content

Important bug - static box when we lose track #124

Description

I found and validated a bug from my side.

Have a look at this part of the code:

        for trk in reversed(self.trackers):
            if trk.last_observation.sum() > 0:
                d = trk.last_observation[:4]
            else:
                d = trk.get_state()[0]

The self.last_observation is set to "-1" values only during the def __init__:
self.last_observation = np.array([-1, -1, -1, -1, -1]) # placeholder
This means in the code I have pasted above, the if statement
if trk.last_observation.sum() > 0:, will never be true.

In my local side, I observed that once we loose track of an object, we use always d = trk.last_observation[:4], and this means that the tracked box is always the same. I could see this in a video I generated. When we lose the track, I can see that the box remains static, which is not ideal.

I did this hack to make it work, but I am not sure if it is optimal, you can also suggest a fix please:

    def update(self, bbox):
        """
        Updates the state vector with observed bbox.
        """
        if bbox is not None:
            if self.last_observation.sum() >= 0:  # no previous observation
                previous_box = None
                for i in range(self.delta_t):
                    dt = self.delta_t - i
                    if self.age - dt in self.observations:
                        previous_box = self.observations[self.age-dt]
                        break
                if previous_box is None:
                    previous_box = self.last_observation
                """
                  Estimate the track speed direction with observations \Delta t steps away
                """
                self.velocity = speed_direction(previous_box, bbox)
            
            """
              Insert new observations. This is a ugly way to maintain both self.observations
              and self.history_observations. Bear it for the moment.
            """
            self.last_observation = bbox
            self.observations[self.age] = bbox
            self.history_observations.append(bbox)

            self.time_since_update = 0
            self.history = []
            self.hits += 1
            self.hit_streak += 1
            self.kf.update(convert_bbox_to_z(bbox))
        else:
            self.last_observation = np.array([-1, -1, -1, -1, -1])
            self.kf.update(bbox)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions