From 6ef727173e8e2e23bc6201bf905b166684c919a1 Mon Sep 17 00:00:00 2001 From: Samuel Murray Date: Fri, 12 May 2017 15:09:34 +0900 Subject: [PATCH] Initial commit. Predictor that assumes stationary objects. Used as baseline model --- .../tracker/predictor/StationaryPredictor.cpp | 36 ++++++++++++++++ .../tracker/predictor/StationaryPredictor.h | 42 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 cpp/src/tracker/predictor/StationaryPredictor.cpp create mode 100644 cpp/src/tracker/predictor/StationaryPredictor.h diff --git a/cpp/src/tracker/predictor/StationaryPredictor.cpp b/cpp/src/tracker/predictor/StationaryPredictor.cpp new file mode 100644 index 0000000..d781c84 --- /dev/null +++ b/cpp/src/tracker/predictor/StationaryPredictor.cpp @@ -0,0 +1,36 @@ +#include "StationaryPredictor.h" + +// Constructors + +StationaryPredictor::StationaryPredictor(const Detection &initialState, int ID) + : Predictor(initialState.label, ID), state(std::make_shared(initialState.bb)) {} + +StationaryPredictor::StationaryPredictor(StationaryPredictor &&rhs) + : Predictor(std::move(rhs)), state(rhs.state) {} + +StationaryPredictor &StationaryPredictor::operator=(StationaryPredictor &&rhs) { + Predictor::operator=(std::move(rhs)); + state = std::move(rhs.state); + return *this; +} + +// Methods + +void StationaryPredictor::update() { + Predictor::update(); +} + +void StationaryPredictor::update(const Detection &det) { + Predictor::update(det); + state = std::make_shared(det.bb); +} + +// Getters + +Detection StationaryPredictor::getPredictedNextDetection() const { + return Detection(getLabel(), 1, *state); +} + +Tracking StationaryPredictor::getTracking() const { + return Tracking(getLabel(), getID(), *state); +} \ No newline at end of file diff --git a/cpp/src/tracker/predictor/StationaryPredictor.h b/cpp/src/tracker/predictor/StationaryPredictor.h new file mode 100644 index 0000000..d6a5432 --- /dev/null +++ b/cpp/src/tracker/predictor/StationaryPredictor.h @@ -0,0 +1,42 @@ +#ifndef CPP_STATIONARYPREDICTOR_H +#define CPP_STATIONARYPREDICTOR_H + + +#include "Predictor.h" + +#include + +class StationaryPredictor : public Predictor { +public: + StationaryPredictor(const Detection &initialState, int ID); + + StationaryPredictor(StationaryPredictor &&rhs); + + StationaryPredictor &operator=(StationaryPredictor &&rhs); + + /** + * Does nothing except calling Predictor::update(). + */ + void update() override; + + /** + * Sets state to match the Detection. + */ + void update(const Detection &det) override; + + /** + * Returns state as Detection. + */ + Detection getPredictedNextDetection() const override; + + /** + * Returns state as Tracking. + */ + Tracking getTracking() const override; + +private: + std::shared_ptr state; +}; + + +#endif //CPP_STATIONARYPREDICTOR_H \ No newline at end of file