Label: 31, Position: (1622, 1342), Size: 20 x 24 Label: 32, Position: (1558, 1343), Size: 25 x 23 Label: 33, Position: (1504, 1346), Size: 29 x 37 Label: 34, Position: (1600, 1346), Size: 24 x 16 Label: 35, Position: (1640, 1346), Size: 18 x 29 Label: 36, Position: (1618, 1348), Size: 11 x 29 Label: 37, Position: (1656, 1348), Size: 28 x 46 Label: 38, Position: (1491, 1349), Size: 28 x 39 Label: 39, Position: (1527, 1351), Size: 16 x 44 Label: 40, Position: (1538, 1351), Size: 17 x 56转换成(x, y, w, h)的形式
时间: 2024-03-22 09:38:46 浏览: 16
下面是Python代码实现:
```python
data = [(31, (1622, 1342), (20, 24)),
(32, (1558, 1343), (25, 23)),
(33, (1504, 1346), (29, 37)),
(34, (1600, 1346), (24, 16)),
(35, (1640, 1346), (18, 29)),
(36, (1618, 1348), (11, 29)),
(37, (1656, 1348), (28, 46)),
(38, (1491, 1349), (28, 39)),
(39, (1527, 1351), (16, 44)),
(40, (1538, 1351), (17, 56))]
# 转换格式
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: 31, Position: (1622, 1342), Size: 20 x 24 Label: 32, Position: (1558, 1343), Size: 25 x 23 Label: 33, Position: (1504, 1346), Size: 29 x 37 Label: 34, Position: (1600, 1346), Size: 24 x 16 Label: 35, Position: (1640, 1346), Size: 18 x 29 Label: 36, Position: (1618, 1348), Size: 11 x 29 Label: 37, Position: (1656, 1348), Size: 28 x 46 Label: 38, Position: (1491, 1349), Size: 28 x 39 Label: 39, Position: (1527, 1351), Size: 16 x 44 Label: 40, Position: (1538, 1351), Size: 17 x 56
(1622, 1342, 20, 24)
(1558, 1343, 25, 23)
(1504, 1346, 29, 37)
(1600, 1346, 24, 16)
(1640, 1346, 18, 29)
(1618, 1348, 11, 29)
(1656, 1348, 28, 46)
(1491, 1349, 28, 39)
(1527, 1351, 16, 44)
(1538, 1351, 17, 56)
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)
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)