Repository navigation
Expand file tree
/
Copy pathMoveHandle.cpp
More file actions
123 lines (111 loc) · 3.4 KB
/
Copy pathMoveHandle.cpp
File metadata and controls
123 lines (111 loc) · 3.4 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <utility>
#include "MoveHandle.h"
void MoveHandle::addPoint(cv::Point newPoint) {
this->newPoint = std::move(newPoint);
}
Gesture MoveHandle::analyseLocus() {
Gesture g = NOOPERATION;
switch (step)
{
case 1:
if(InRegionCenter(newPoint,winSize)) {
step++;
cout << "got" << endl;
}
break;
case 2:
if(!InRegionCenter(newPoint,winSize)) {
first = newPoint;
step++;
cout << "out" << endl;
}
break;
case 3:
Step(g);
break;
default:break;
}
return g;
}
bool MoveHandle::InRegionLeftOfTurn(cv::Point p, cv::Size winSize) {
return p.x < winSize.width / 3;
}
bool MoveHandle::InRegionRightOfTurn(cv::Point p, cv::Size winSize) {
return p.x > winSize.width * 2 / 3;
}
bool MoveHandle::InRegionTop(cv::Point p, cv::Size winSize) {
return p.y < winSize.height / 3;
}
bool MoveHandle::InRegionBottom(cv::Point p, cv::Size winSize) {
//if( p.y > winSize.height * 2 / 3) cout << "bottom" << endl;
return p.y > winSize.height * 2 / 3;
}
bool MoveHandle::InRegionCenter(cv::Point p, cv::Size winSize) {
return p.x > winSize.width / 3 && p.x < winSize.width * 2 / 3 && p.y > winSize.height / 3 && p.y < winSize.height * 2 / 3;
}
void MoveHandle::Step(Gesture &g) {
if (InRegionRightOfTurn(first, winSize) && InRegionLeftOfTurn(newPoint, winSize)) {
g = LEFT;
step = 1;
cout << "turn right to " << endl;
}
else if(InRegionRightOfTurn(first,winSize)&&InRegionTop(newPoint,winSize)){
g = UP;
step=1;
cout<<"turn up to"<<endl;
}
else if(InRegionRightOfTurn(first,winSize)&&InRegionBottom(newPoint,winSize)){
g=DOWN;
step=1;
cout<<"turn down to"<<endl;
}//右边的时候
else if (InRegionLeftOfTurn(first, winSize) && InRegionRightOfTurn(newPoint, winSize)) {
g = RIGHT;
step = 1;
cout << "turn left to" << endl;
}
else if(InRegionLeftOfTurn(first,winSize)&&InRegionTop(newPoint,winSize)){
g=UP;
step=1;
cout<<"turn up to"<<endl;
}
else if(InRegionLeftOfTurn(first,winSize)&&InRegionBottom(newPoint,winSize)){
g=DOWN;
step=1;
cout<<"turn down to"<<endl;
}//左边的时候
else if (InRegionTop(first, winSize) && InRegionBottom(newPoint, winSize)) {
g = DOWN;
step = 1;
cout << "turn down to" << endl;
}
else if(InRegionTop(first,winSize)&&InRegionLeftOfTurn(newPoint,winSize)){
g=LEFT;
step=1;
cout<<"turn left to"<<endl;
}
else if(InRegionTop(first,winSize)&&InRegionRightOfTurn(newPoint,winSize)){
g=RIGHT;
step=1;
cout<<"turn right to"<<endl;
}//上面的时候
else if (InRegionBottom(first, winSize) && InRegionTop(newPoint, winSize)) {
g = UP;
step = 1;
cout << "turn up to" << endl;
}
else if(InRegionBottom(first,winSize)&&InRegionRightOfTurn(newPoint,winSize)){
g=RIGHT;
step=1;
cout<<"turn right to"<<endl;
}
else if(InRegionBottom(first,winSize)&&InRegionLeftOfTurn(newPoint,winSize)){
g=LEFT;
step=1;
cout<<"turn left to"<<endl;
}//在下面的时候
}
void MoveHandle::reset() {
step = 1;
cout << "Reset Seccess" <<endl;
}