-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMeasureView.h
More file actions
54 lines (42 loc) · 1.06 KB
/
MeasureView.h
File metadata and controls
54 lines (42 loc) · 1.06 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
//
// Created by kinit on 2021-11-04.
//
#ifndef MPEGMEASURE2021_MEASUREVIEW_H
#define MPEGMEASURE2021_MEASUREVIEW_H
#include <array>
#include <opencv2/core/mat.hpp>
class MeasureView {
public:
using PointRecord = struct {
float x;
float y;
};
static constexpr int HEIGHT = 400;
static constexpr int WIDTH = 600;
static constexpr int POS_RECT_A = 200;
static constexpr int MAX_VALUE_ABS_OFFSET = 20;
private:
cv::Mat mFrameBuffer = cv::Mat(cv::Size(WIDTH, HEIGHT), CV_8UC3, cv::Scalar(0, 0, 0));
int mDataStartIndex = 0;
int mDataLength = 0;
int mLastDataIndex = -1;
std::array<PointRecord, 20> mDataArray;
bool mBufferDirty = true;
private:
void onDraw();
public:
void updateData(float x, float y);
void updateNoData();
void clearData();
inline void invalidate() {
mBufferDirty = true;
}
[[nodiscard]]
inline cv::Mat getFrameBuffer() {
if (mBufferDirty) {
onDraw();
}
return mFrameBuffer;
}
};
#endif //MPEGMEASURE2021_MEASUREVIEW_H