-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackers.cpp
More file actions
87 lines (67 loc) · 1.67 KB
/
Trackers.cpp
File metadata and controls
87 lines (67 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include <iostream>
#include <chrono>
#include <Vector>
#include <iomanip>
#include <opencv2/opencv.hpp>
class Timer {
public:
std::chrono::time_point<std::chrono::steady_clock> start, end;
std::chrono::duration<float> duration;
Timer() {
start = std::chrono::high_resolution_clock::now();
};
~Timer() {
end = std::chrono::high_resolution_clock::now();
duration = end - start;
};
};
class TimeTracker {
public:
// This struct aims to make a tracker object that can be used to model time propagation
int TrackerSize = 0;
std::vector<float> TT;
TimeTracker() {};
void ReShape(int a) {
this->TT.resize(a);
this->TrackerSize = a;
};
void Append(float a) {
TT[TrackerSize] = a;
TrackerSize++;
};
};
class TrajectoryTracker {
public:
int TranslationSize, RotationSize;
std::vector<cv::Mat> Rotation, Translation;
cv::Mat FinalR, FinalT;
TrajectoryTracker() {
cv::Mat FinalT(cv::Size(3, 3), CV_64FC1, cv::Scalar(1));
cv::Mat FinalR(cv::Size(3, 3), CV_64FC1, cv::Scalar(1));
};
void ReSize(int a) {
Rotation.resize(a);
RotationSize = a;
Translation.resize(a);
TranslationSize = a;
};
void AddTranslation(int time, cv::Mat val) {
Translation[time] = val;
}
void AddRotation(int time, cv::Mat val) {
Rotation[time] = val;
}
cv::Mat ComputeFinalRotation() {
for (int i = 0; i < TranslationSize; i++) {
this->FinalR *= this->Rotation[i];
}
return this->FinalR;
};
cv::Mat ComputeFinalTranslation() {
for (int i = 0; i < this->TranslationSize; i++) {
this->FinalT *= this->Translation[i];
}
return this->FinalT;
};
};