forked from samuelmurray/tracking-by-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit. Predictor that assumes stationary objects. Used as ba…
…seline model
- Loading branch information
1 parent
ffa1172
commit 6ef7271
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |