| 42 | return int(l), int(t), int(r), int(b) |
| 43 | |
| 44 | def exec(self): |
| 45 | envelope = self.inp.recv() |
| 46 | if envelope is None: |
| 47 | self._map.clear() |
| 48 | return |
| 49 | |
| 50 | msg = envelope.msg |
| 51 | |
| 52 | # push the first |
| 53 | msg['shaper'] = [] |
| 54 | for track in msg['tracks']: |
| 55 | tid = track['tid'] |
| 56 | box = track['bbox'] |
| 57 | if tid not in self._map: |
| 58 | self._map[tid] = dict() |
| 59 | |
| 60 | data = msg['data'] |
| 61 | l, t, r, b = self.expand(box, data.shape[1], data.shape[0], |
| 62 | 1.1) |
| 63 | crop = data[t:b, l:r] |
| 64 | msg['shaper'].append(crop) |
| 65 | # cv2.imwrite(f'shaper_{envelope.partial_id}.jpg', crop) |
| 66 | |
| 67 | self.out.send(envelope) |