| 8 | |
| 9 | |
| 10 | def box_convert_simple(box, convert_type="xyxy2xywh"): |
| 11 | if convert_type == "xyxy2xywh": |
| 12 | return [box[0], box[1], box[2] - box[0], box[3] - box[1]] |
| 13 | elif convert_type == "xywh2xyxy": |
| 14 | return [box[0], box[1], box[2] + box[0], box[3] + box[1]] |
| 15 | elif convert_type == "xyxy2ctwh": |
| 16 | return [(box[0] + box[2]) / 2, (box[1] + box[3]) / 2, box[2] - box[0], box[3] - box[1]] |
| 17 | elif convert_type == "ctwh2xyxy": |
| 18 | return [box[0] - box[2] // 2, box[1] - box[3] // 2, box[0] + (box[2] - box[2] // 2), box[1] + (box[3] - box[3] // 2)] |
| 19 | |
| 20 | |
| 21 | def read_img(image, convert="RGB", check_exist=False): |