Fix handling mixed masks

This commit is contained in:
Nicolas Mowen 2024-04-29 08:01:24 -06:00
parent 8c610bea49
commit a4faccd4b5

View File

@ -155,14 +155,18 @@ def get_relative_coordinates(
relative_masks = [] relative_masks = []
for m in mask: for m in mask:
points = m.split(",") points = m.split(",")
relative_masks.append(
",".join( if any(x > "1.0" for x in points):
[ relative_masks.append(
f"{round(int(points[i]) / frame_shape[1], 3)},{round(int(points[i + 1]) / frame_shape[0], 3)}" ",".join(
for i in range(0, len(points), 2) [
] f"{round(int(points[i]) / frame_shape[1], 3)},{round(int(points[i + 1]) / frame_shape[0], 3)}"
for i in range(0, len(points), 2)
]
)
) )
) else:
relative_masks.append(m)
mask = relative_masks mask = relative_masks
elif isinstance(mask, str) and any(x > "1.0" for x in mask.split(",")): elif isinstance(mask, str) and any(x > "1.0" for x in mask.split(",")):