-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMeasureSession.h
More file actions
70 lines (54 loc) · 1.51 KB
/
MeasureSession.h
File metadata and controls
70 lines (54 loc) · 1.51 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
//
// Created by kinit on 2021-11-05.
//
#ifndef MPEGMEASURE2021_MEASURESESSION_H
#define MPEGMEASURE2021_MEASURESESSION_H
#include <cstdint>
#include <array>
#include <tuple>
#include <vector>
#include <opencv2/core/mat.hpp>
class MeasureSession {
public:
enum class EdgePointType {
LEFT_EDGE = 1,
RIGHT_EDGE = 2,
};
using EdgeRecord = struct {
cv::Point point;
int deltaTimeMs;
EdgePointType type;
};
[[nodiscard]]
bool isInitialized() const noexcept;
void init(int width, int height);
void updateFrame(const cv::Point &posA, const std::array<uint64_t, 2> &measureTimeA,
const cv::Point &posB, const std::array<uint64_t, 2> &measureTimeB);
void reset();
[[nodiscard]]
float calculateT() const;
[[nodiscard]]
float calculateTheta() const;
[[nodiscard]]
const std::vector<EdgeRecord> &getPeriodDataA() const;
[[nodiscard]]
const std::vector<EdgeRecord> &getPeriodDataB() const;
private:
enum class PointMotionStatus {
RESET = 0,
GOING_LEFT = 1,
GOING_RIGHT = 2,
};
struct LastCamInfo {
PointMotionStatus status = PointMotionStatus::RESET;
int lastX = 0;
int lastDeltaX = 0;
uint64_t lastTimePoint = 0;
};
cv::Size mImageSize = {0, 0};
LastCamInfo mCamInfoA = {};
LastCamInfo mCamInfoB = {};
std::vector<EdgeRecord> mPeriodDataA;
std::vector<EdgeRecord> mPeriodDataB;
};
#endif //MPEGMEASURE2021_MEASURESESSION_H