Skip to content

Commit

Permalink
Initial commit. Predictor that assumes stationary objects. Used as ba…
Browse files Browse the repository at this point in the history
…seline model
  • Loading branch information
samuelmurray committed May 12, 2017
1 parent ffa1172 commit 6ef7271
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cpp/src/tracker/predictor/StationaryPredictor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "StationaryPredictor.h"

// Constructors

StationaryPredictor::StationaryPredictor(const Detection &initialState, int ID)
: Predictor(initialState.label, ID), state(std::make_shared<BoundingBox>(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<BoundingBox>(det.bb);
}

// Getters

Detection StationaryPredictor::getPredictedNextDetection() const {
return Detection(getLabel(), 1, *state);
}

Tracking StationaryPredictor::getTracking() const {
return Tracking(getLabel(), getID(), *state);
}
42 changes: 42 additions & 0 deletions cpp/src/tracker/predictor/StationaryPredictor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef CPP_STATIONARYPREDICTOR_H
#define CPP_STATIONARYPREDICTOR_H


#include "Predictor.h"

#include <memory>

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<BoundingBox> state;
};


#endif //CPP_STATIONARYPREDICTOR_H

0 comments on commit 6ef7271

Please sign in to comment.