Skip to content

Adding input shift #240

@BartvanMarrewijk

Description

@BartvanMarrewijk

Dear Roboflow,

First of all many thanks for making this github open source.
I am using the trackers in a conveyor setting to track objects over time. However, since the conveyor belt speed is not constant both and it is full of objects >200 Bytetrack and SortTracker fail. It incorrectly matches the objects.

However, by adding a simple input U vector, the shift in x or y position both trackers work fine. The shift of the conveyor can be easily determined by for example opencv matched (cv2.matchTemplate)

    def predict(self, u: np.ndarray| None = None) -> None:
        """
        Predict the next state of the bounding box (applies the state transition).
        """
        # Predict state
        if u is not None:
            # Ensure u has the correct shape (n, 1)
            if u.ndim == 1:
                u = u.reshape(-1, 1)
            self.state = (self.F @ self.state).astype(np.float32) + (self.B @ u).astype(np.float32)
        else:
            self.state = (self.F @ self.state).astype(np.float32)
        # Predict error covariance
        self.P = (self.F @ self.P @ self.F.T + self.Q).astype(np.float32)

        # Increase time since update
        self.time_since_update += 1

I think this would be a nice feature, let me know what you think. Maybe a simple wrapper can already help.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions