-
Notifications
You must be signed in to change notification settings - Fork 1
/
mouse_callback.h
60 lines (51 loc) · 1.82 KB
/
mouse_callback.h
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
//
// Created by hp on 2018/11/17.
//
#ifndef II_BSOFT_MOUSE_CALLBACK_H
#define II_BSOFT_MOUSE_CALLBACK_H
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui.hpp>
//#include <opencv/cxcore.h>
#include "global.h"
using namespace cv;
using namespace std;
void callback_PerspectiveTransform(int event, int x, int y, int flags, void *) {
if (PerspectiveNum < 4 && event == EVENT_LBUTTONDOWN) {
cout << "No. " << PerspectiveNum + 1 << " base point = ( "
<< x << " , " << y << " )\n";
PerspectiveBase[PerspectiveNum++] = Point2f(x, y);
addpoint = true;
}
}
void callback_FindPoint(int event, int x, int y, int flags, void *) {
if (event == EVENT_LBUTTONDOWN && HeadOrTailMark == 1) {
++HeadOrTailMark;
HeadRepresent = Point2f(x, y);
cout << "the representative of head = ( " << x << " , " << y << " )\n";
} else if (event == EVENT_LBUTTONDOWN && HeadOrTailMark == 2) {
++HeadOrTailMark;
TailRepresent = Point2f(x, y);
cout << "the representative of tail = ( " << x << " , " << y << " )\n";
}
}
void callback_FindRoute_naive(int event, int x, int y, int flags, void *) {
if (event == EVENT_LBUTTONDOWN) {
++routeCnt;
cout << "naive find route : ( " << x << " , " << y << " )\n";
temRoute = Point2f(x, y);
}
}
void callback_FindRoute_startpoint(int event, int x, int y, int flags, void *) {
if (getstart == 0 && event == cv::EVENT_LBUTTONDOWN) {
getstart = 1;
cout << "( " << x << " , " << y << " ) start point saved .\n";
startpoint.x = x;
startpoint.y = y;
}
}
void callback_Threshold(int thre, void *) {
cv::threshold(grayImg, thresImg, thre, 255, 0);
}
#endif //II_BSOFT_MOUSE_CALLBACK_H