Converts bounding box format from one type to another.
(self, format)
| 57 | # self.normalized = normalized |
| 58 | |
| 59 | def convert(self, format): |
| 60 | """Converts bounding box format from one type to another.""" |
| 61 | assert format in _formats, f'Invalid bounding box format: {format}, format must be one of {_formats}' |
| 62 | if self.format == format: |
| 63 | return |
| 64 | elif self.format == 'xyxy': |
| 65 | func = xyxy2xywh if format == 'xywh' else xyxy2ltwh |
| 66 | elif self.format == 'xywh': |
| 67 | func = xywh2xyxy if format == 'xyxy' else xywh2ltwh |
| 68 | else: |
| 69 | func = ltwh2xyxy if format == 'xyxy' else ltwh2xywh |
| 70 | self.bboxes = func(self.bboxes) |
| 71 | self.format = format |
| 72 | |
| 73 | def areas(self): |
| 74 | """Return box areas.""" |
no test coverage detected