forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highgui.cpp
79 lines (61 loc) · 2.08 KB
/
highgui.cpp
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
#include "highgui_gocv.h"
// Window
void Window_New(const char* winname, int flags) {
cv::namedWindow(winname, flags);
}
void Window_Close(const char* winname) {
cv::destroyWindow(winname);
}
void Window_IMShow(const char* winname, Mat mat) {
cv::imshow(winname, *mat);
}
double Window_GetProperty(const char* winname, int flag) {
return cv::getWindowProperty(winname, flag);
}
void Window_SetProperty(const char* winname, int flag, double value) {
cv::setWindowProperty(winname, flag, value);
}
void Window_SetTitle(const char* winname, const char* title) {
cv::setWindowTitle(winname, title);
}
int Window_WaitKey(int delay = 0) {
return cv::waitKey(delay);
}
void Window_Move(const char* winname, int x, int y) {
cv::moveWindow(winname, x, y);
}
void Window_Resize(const char* winname, int width, int height) {
cv::resizeWindow(winname, width, height);
}
struct Rect Window_SelectROI(const char* winname, Mat img) {
cv::Rect bRect = cv::selectROI(winname, *img);
Rect r = {bRect.x, bRect.y, bRect.width, bRect.height};
return r;
}
struct Rects Window_SelectROIs(const char* winname, Mat img) {
std::vector<cv::Rect> rois;
cv::selectROIs(winname, *img, rois);
Rect* rects = new Rect[rois.size()];
for (size_t i = 0; i < rois.size(); ++i) {
Rect r = {rois[i].x, rois[i].y, rois[i].width, rois[i].height};
rects[i] = r;
}
Rects ret = {rects, (int)rois.size()};
return ret;
}
// Trackbar
void Trackbar_Create(const char* winname, const char* trackname, int max) {
cv::createTrackbar(trackname, winname, NULL, max);
}
int Trackbar_GetPos(const char* winname, const char* trackname) {
return cv::getTrackbarPos(trackname, winname);
}
void Trackbar_SetPos(const char* winname, const char* trackname, int pos) {
cv::setTrackbarPos(trackname, winname, pos);
}
void Trackbar_SetMin(const char* winname, const char* trackname, int pos) {
cv::setTrackbarMin(trackname, winname, pos);
}
void Trackbar_SetMax(const char* winname, const char* trackname, int pos) {
cv::setTrackbarMax(trackname, winname, pos);
}