Label: 11, Position: (1486, 1304), Size: 19 x 24 Label: 12, Position: (1502, 1304), Size: 19 x 16 Label: 13, Position: (1548, 1308), Size: 25 x 20 Label: 14, Position: (1622, 1308), Size: 25 x 23 Label: 15, Position: (1603, 1309), Size: 32 x 10 Label: 16, Position: (1528, 1313), Size: 24 x 19 Label: 17, Position: (1584, 1314), Size: 27 x 24 Label: 18, Position: (1607, 1316), Size: 23 x 21 Label: 19, Position: (1485, 1317), Size: 12 x 36 Label: 20, Position: (1511, 1317), Size: 23 x 29转成(x,y,w,h)形式
时间: 2024-03-22 21:38:42 浏览: 71
下面是Python代码实现:
```python
data = [(11, (1486, 1304), (19, 24)),
(12, (1502, 1304), (19, 16)),
(13, (1548, 1308), (25, 20)),
(14, (1622, 1308), (25, 23)),
(15, (1603, 1309), (32, 10)),
(16, (1528, 1313), (24, 19)),
(17, (1584, 1314), (27, 24)),
(18, (1607, 1316), (23, 21)),
(19, (1485, 1317), (12, 36)),
(20, (1511, 1317), (23, 29))]
# 转换格式
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文件中。
相关问题
Label: 11, Position: (1486, 1304), Size: 19 x 24 Label: 12, Position: (1502, 1304), Size: 19 x 16 Label: 13, Position: (1548, 1308), Size: 25 x 20 Label: 14, Position: (1622, 1308), Size: 25 x 23 Label: 15, Position: (1603, 1309), Size: 32 x 10 Label: 16, Position: (1528, 1313), Size: 24 x 19 Label: 17, Position: (1584, 1314), Size: 27 x 24 Label: 18, Position: (1607, 1316), Size: 23 x 21 Label: 19, Position: (1485, 1317), Size: 12 x 36 Label: 20, Position: (1511, 1317), Size: 23 x 29
(1486, 1304, 19, 24)
(1502, 1304, 19, 16)
(1548, 1308, 25, 20)
(1622, 1308, 25, 23)
(1603, 1309, 32, 10)
(1528, 1313, 24, 19)
(1584, 1314, 27, 24)
(1607, 1316, 23, 21)
(1485, 1317, 12, 36)
(1511, 1317, 23, 29)
Label: 66, Position: (1546, 1404), Size: 18 x 29 Label: 67, Position: (1555, 1406), Size: 26 x 23 Label: 68, Position: (1507, 1408), Size: 23 x 29 Label: 69, Position: (1668, 1408), Size: 42 x 31 Label: 70, Position: (1627, 1409), Size: 28 x 21 Label: 71, Position: (1530, 1412), Size: 28 x 28 Label: 72, Position: (1674, 1413), Size: 37 x 38 Label: 73, Position: (1601, 1414), Size: 30 x 22 Label: 74, Position: (1688, 1415), Size: 29 x 37 Label: 75, Position: (1573, 1421), Size: 32 x 22 Label: 76, Position: (1641, 1421), Size: 29 x 17 Label: 77, Position: (1548, 1428), Size: 30 x 21 Label: 78, Position: (1616, 1428), Size: 28 x 14 Label: 79, Position: (1516, 1433), Size: 22 x 33 Label: 80, Position: (1585, 1433), Size: 32 x 12 Label: 81, Position: (1534, 1434), Size: 24 x 24 Label: 82, Position: (1555, 1442), Size: 31 x 19 Label: 83, Position: (1578, 1452), Size: 30 x 16 Label: 84, Position: (1550, 1453), Size: 29 x 19 Label: 85, Position: (1525, 1454), Size: 30 x 32 Label: 86, Position: (1593, 1458), Size: 40 x 10 Label: 87, Position: (1500, 1459), Size: 30 x 26 Label: 88, Position: (1491, 1466), Size: 18 x 36 Label: 89, Position: (1550, 1467), Size: 30 x 17 Label: 90, Position: (1498, 1481), Size: 32 x 21 Label: 91, Position: (1528, 1481), Size: 28 x 19
(x, y, w, h)形式:
(1546, 1404, 18, 29)
(1555, 1406, 26, 23)
(1507, 1408, 23, 29)
(1668, 1408, 42, 31)
(1627, 1409, 28, 21)
(1530, 1412, 28, 28)
(1674, 1413, 37, 38)
(1601, 1414, 30, 22)
(1688, 1415, 29, 37)
(1573, 1421, 32, 22)
(1641, 1421, 29, 17)
(1548, 1428, 30, 21)
(1616, 1428, 28, 14)
(1516, 1433, 22, 33)
(1585, 1433, 32, 12)
(1534, 1434, 24, 24)
(1555, 1442, 31, 19)
(1578, 1452, 30, 16)
(1550, 1453, 29, 19)
(1525, 1454, 30, 32)
(1593, 1458, 40, 10)
(1500, 1459, 30, 26)
(1491, 1466, 18, 36)
(1550, 1467, 30, 17)
(1498, 1481, 32, 21)
(1528, 1481, 28, 19)
阅读全文