Label: 26, Position: (1648, 1328), Size: 15 x 30 Label: 27, Position: (1598, 1333), Size: 27 x 20 Label: 28, Position: (1492, 1334), Size: 29 x 24 Label: 29, Position: (1534, 1334), Size: 34 x 22 Label: 30, Position: (1578, 1340), Size: 25 x 26转换成(x, y, w, h)的形式
时间: 2024-03-22 19:38:46 浏览: 123
switchable:用漂亮的iPhone风格的开关按钮代替复选框
下面是Python代码实现:
```python
data = [(26, (1648, 1328), (15, 30)),
(27, (1598, 1333), (27, 20)),
(28, (1492, 1334), (29, 24)),
(29, (1534, 1334), (34, 22)),
(30, (1578, 1340), (25, 26))]
# 转换格式
data = [(p[0], p[1], s[0], s[1]) for _, p, s in data]
# 写入txt文件
with open("result.txt", "w") as f:
for d in data:
f.write(" ".join(str(x) for x in d) + "\n")
```
同样地,将原始数据中的label丢弃,并将每个元素转换成(x, y, w, h)的形式。然后将结果写入txt文件中。
阅读全文