Go to the source code of this file.
|
bool | mergeBoundingBoxes (int &x1, int &y1, int &w1, int &h1, int x2, int y2, int w2, int h2) |
|
◆ mergeBoundingBoxes()
bool mergeBoundingBoxes |
( |
int & | x1, |
|
|
int & | y1, |
|
|
int & | w1, |
|
|
int & | h1, |
|
|
int | x2, |
|
|
int | y2, |
|
|
int | w2, |
|
|
int | h2 ) |
Definition at line 9 of file 2.cpp.
9 {
10
11 int x1_ = x1+w1;
12 int y1_ = y1+h1;
13
14 int x2_ = x2+w2;
15 int y2_ = y2+h2;
16 bool overlap = false;
17
18
19
20
21
22
23 if ((x1_ > x2) && (y1_ > y2) && (x1 <= x2) && (y1 <= y2)){
24 overlap = true;
25 }
26
27
28 else if ((x2_ > x1) && (y2_ > y1) && (x1 >= x2) && (y1 >= y2)){
29 overlap = true;
30 }
31 else if ((x1_ > x2) && (y2_ > y1) && (x1 <= x2) && (y1 >= y2)){
32 overlap = true;
33 }
34 else if ((x2_ > x1) && (y1_ > y2) && (x1 >= x2) && (y1 <= y2)){
35 overlap = true;
36 }
37
38
39
40
41 w1 = max(x1_,x2_)-min(x1,x2);
42 h1 = max(y1_,y2_)-min(y1,y2);
43 x1 = min(x1,x2);
44 y1 = min(y1,y2);
45 return overlap;
46}
Referenced by main().