-
Notifications
You must be signed in to change notification settings - Fork 0
/
direct_test.cpp
47 lines (35 loc) · 1.05 KB
/
direct_test.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
// g++ -IC:/OpenCV/build/opencv-4.0.1_omp_tbb_mkl/install/include direct.cpp direct_test.cpp -o test.exe -LC:/OpenCV/build/opencv-4.0.1_omp_tbb_mkl/install/x64/mingw/lib -lopencv_core401 -lopencv_imgproc401 -lopencv_highgui401
#include "direct.h"
using namespace std;
using namespace cv;
double my_distance2(int dx, int dy){
return abs(dx) + abs(dy);
}
void onMouse(int event, int x, int y, int flags, void *param);
// Global variables
const char wnd_name[] = "Display";
DirectVoronoi test;
Mat frame;
int key;
int main(){
test.init(Size(600, 400), my_distance2);
// test.init(Size(600, 400));
namedWindow(wnd_name);
setMouseCallback(wnd_name, onMouse);
test.draw(frame);
imshow(wnd_name, frame);
while(1){
key = waitKey(33);
if(key == 27) // ESC
break;
}
destroyAllWindows();
return 0;
}
void onMouse(int event, int x, int y, int flags, void *param){
if(event == EVENT_LBUTTONUP){
test.add_point(Point(x, y));
test.draw(frame);
imshow(wnd_name, frame);
}
}