-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.h
More file actions
63 lines (43 loc) · 1.45 KB
/
view.h
File metadata and controls
63 lines (43 loc) · 1.45 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
/**
* Written by Dean on 2021-04-07.
*
* Create and delete windows, draw camera frames and gaze points.
* */
#ifndef EYEDID_CPP_SAMPLE_VIEW_H_
#define EYEDID_CPP_SAMPLE_VIEW_H_
#include <string>
#include <vector>
#include "opencv2/opencv.hpp"
#include "drawables.h"
#include "priority_mutex.h"
namespace sample {
using read_lock_guard = std::lock_guard<typename PriorityMutex::high_mutex_type>;
using read_unique_lock = std::unique_lock<typename PriorityMutex::high_mutex_type>;
using write_lock_guard = std::lock_guard<typename PriorityMutex::low_mutex_type>;
using write_unique_lock = std::unique_lock<typename PriorityMutex::low_mutex_type>;
class View {
public:
View(int width, int height, std::string windowName);
void setPoint(int x, int y);
void setFrame(const cv::Mat& frame);
int draw(int wait_ms = 10);
void closeWindow();
const std::string& getWindowName() const;
drawables::Circle gaze_point_;
drawables::Circle calibration_point_;
drawables::Text calibration_desc_;
drawables::Image frame_;
std::vector<drawables::Text> desc_;
PriorityMutex::low_mutex_type& write_mutex() { return mutex_.low(); }
private:
void initElements();
void clearBackground();
void drawElements();
int drawWindow(int wait_ms);
PriorityMutex::high_mutex_type& read_mutex() { return mutex_.high(); }
std::string window_name_;
cv::Mat background_;
mutable PriorityMutex mutex_;
};
} // namespace sample
#endif // EYEDID_CPP_SAMPLE_VIEW_H_