Method
expand
(self, box, max_w, max_h, ratio)
Source from the content-addressed store, hash-verified
| 22 | self._map = dict() |
| 23 | |
| 24 | def expand(self, box, max_w, max_h, ratio): |
| 25 | l = box[0] |
| 26 | r = box[2] |
| 27 | t = box[1] |
| 28 | b = box[3] |
| 29 | center_x = (l + r) / 2 |
| 30 | center_y = (t + b) / 2 |
| 31 | w_side = (r - l) * ratio / 2 |
| 32 | h_side = (b - t) * ratio / 2 |
| 33 | |
| 34 | l = center_x - w_side |
| 35 | r = center_x + w_side |
| 36 | t = center_y - h_side |
| 37 | b = center_y + h_side |
| 38 | l = max(0, l) |
| 39 | t = max(0, t) |
| 40 | r = min(max_w, r) |
| 41 | b = min(max_h, b) |
| 42 | return int(l), int(t), int(r), int(b) |
| 43 | |
| 44 | def exec(self): |
| 45 | envelope = self.inp.recv() |
Tested by
no test coverage detected