Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/centroidtracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Created by pratheek on 2019-11-27.

class CentroidTracker {
public:
explicit CentroidTracker(int maxDisappeared);
explicit CentroidTracker(int maxDisappeared, int maxDistance);

void register_Object(int cX, int cY);

Expand All @@ -29,7 +29,7 @@ class CentroidTracker {
std::map<int, std::vector<std::pair<int, int>>> path_keeper;
private:
int maxDisappeared;

int maxDistance;
int nextObjectID;

static double calcDistance(double x1, double y1, double x2, double y2);
Expand Down
7 changes: 6 additions & 1 deletion src/centroidtracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Created by pratheek on 2019-11-27.

using namespace std;

CentroidTracker::CentroidTracker(int maxDisappeared) {
CentroidTracker::CentroidTracker(int maxDisappeared, int maxDistance) {
this->nextObjectID = 0;
this->maxDisappeared = maxDisappeared;
this->maxDistance = maxDistance;
}

double CentroidTracker::calcDistance(double x1, double y1, double x2, double y2) {
Expand Down Expand Up @@ -131,6 +132,10 @@ std::vector<std::pair<int, std::pair<int, int>>> CentroidTracker::update(vector<
for (int i = 0; i < rows.size(); i++) {
//if we have already examined either the row or column value before, ignore it
if (usedRows.count(rows[i]) || usedCols.count(cols[i])) { continue; }

// Added maxDistance logic here
if (Distances[rows[i]][cols[i]] > this->maxDistance) { continue; }

//otherwise, grab the object ID for the current row, set its new centroid,
// and reset the disappeared counter
int objectID = objectIDs[rows[i]];
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace std;

int main() {
std::cout << "Hello, Tracker!" << std::endl;
auto centroidTracker = new CentroidTracker(20);
auto centroidTracker = new CentroidTracker(20, 50);

VideoCapture cap(0);
// VideoCapture cap("../../test2.mp4");
Expand Down