| 31 | logger.info("Image Reid loaded.") |
| 32 | |
| 33 | def exec(self): |
| 34 | envelope = self.inp.recv() |
| 35 | if envelope is None: |
| 36 | return |
| 37 | image = envelope.msg |
| 38 | |
| 39 | data = image['data'] |
| 40 | items = image['items'] |
| 41 | assert isinstance(items, list) |
| 42 | |
| 43 | for item in items: |
| 44 | bbox = item['bbox'] |
| 45 | crop = data[round(bbox[1]):round(bbox[3]), |
| 46 | round(bbox[0]):round(bbox[2])] |
| 47 | |
| 48 | # cv2.imwrite(f'reid_image_{envelope.partial_id}.jpg', crop) |
| 49 | feature = self._model.inference(crop) |
| 50 | item['feature'] = feature |
| 51 | logger.info(f'feature {feature}') |
| 52 | self.out.send(envelope) |