-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplay.cpp
More file actions
34 lines (27 loc) · 886 Bytes
/
Display.cpp
File metadata and controls
34 lines (27 loc) · 886 Bytes
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
/* $Rev: 250 $ */
#include "Display.h"
#include <opencv/highgui.h>
Display::Display(const std::string& windowName, unsigned int width, unsigned int height, Colour colour) :
img_(cv::Size(width, height), CV_8UC3), windowName_(windowName) {
cv::namedWindow(windowName_);
img_.setTo(cv::Scalar(255*colour.blue, 255*colour.green, 255*colour.red));
}
Display::~Display() {
cv::destroyWindow(windowName_);
}
void Display::set(int x, int y, Colour colour) {
cv::Vec3b& col = img_.at<cv::Vec3b>(y,x);
col[2] = int(255*colour.red);
col[1] = int(255*colour.green);
col[0] = int(255*colour.blue);
}
void Display::refresh() const {
cv::imshow(windowName_, img_);
cv::waitKey(5);
}
void Display::save(const std::string& filename) const {
cv::imwrite(filename, img_);
}
void Display::pause(double seconds) const {
cv::waitKey(int(seconds*1000));
}