예제 #1
0
 def correct(self, measure):
     """Correct the model based on real measures."""
     measures_array = np.array([measure.x, measure.y, measure.w, measure.h],
                               dtype=np.float32)
     estimated = self.kalman_filter.correct(measures_array)
     estimated = KalmanTracker.__decapsulate_measure(estimated)
     self.act_prediction = Region.from_matrix(estimated)
     return self.act_prediction
예제 #2
0
    def predict(self):
        """Predict next position and size of tracked object."""
        prediction_raw = self.kalman_filter.predict()
        self.kalman_filter.statePost = np.copy(self.kalman_filter.statePre)
        self.kalman_filter.errorCovPost = np.copy(
            self.kalman_filter.errorCovPre)
        prediction_decapsulated = KalmanTracker.__decapsulate_measure(
            prediction_raw)
        prediction_wrap = Region.from_matrix(prediction_decapsulated)
        self.act_prediction = prediction_wrap

        # Collect last history:
        if self.prediction_history.full():
            self.prediction_history.get()
        self.prediction_history.put(self.act_prediction)

        return self.act_prediction