MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / box_convert_simple

Function box_convert_simple

tools/preprocess/pose2d_utils.py:10–18  ·  view source on GitHub ↗
(box, convert_type="xyxy2xywh")

Source from the content-addressed store, hash-verified

8
9
10def 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
21def read_img(image, convert="RGB", check_exist=False):

Callers 1

postprocessMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected