从 jSon 文件中提取矩阵
Extract matrix from jSon file
我使用 fSpy 软件:开源静态图像相机匹配
将结果与 Rhino 3d 一起使用,我导出到 jSon 文件,其中包含相机位置矩阵
我需要将 行 提取到带有 Python 的数字列表中
感谢帮助
从这个:
"cameraTransform": {
"rows": [
[
-0.7469096503244566,
-0.0048362499036055774,
-0.6649079522302825,
-6.756347957309588
],
[
-0.6649255299159078,
0.005255128514812499,
0.7468911723205343,
7.333944516331069
],
[
-0.00011797562067967932,
0.9999744968303753,
-0.007140852231397498,
-4.200072574252649
],
[
0,
0,
0,
1
]
]
}
到:
0 -0.7469096503244566
1 -0.0048362499036055774
2 -0.6649079522302825
3 -6.756347957309588
4 -0.6649255299159078
5 0.005255128514812499
6 0.7468911723205343
7 7.333944516331069
8 -0.00011797562067967932
9 0.9999744968303753
10 -0.007140852231397498
11 -4.200072574252649
12 0
13 0
14 0
15 1
将json格式转换为python格式后可以试试这个:
cameraTransform= {
"rows": [
[
-0.7469096503244566,
-0.0048362499036055774,
-0.6649079522302825,
-6.756347957309588
],
[
-0.6649255299159078,
0.005255128514812499,
0.7468911723205343,
7.333944516331069
],
[
-0.00011797562067967932,
0.9999744968303753,
-0.007140852231397498,
-4.200072574252649
],
[
0,
0,
0,
1
]
]
}
from itertools import chain
for idx, value in enumerate(chain(*cameraTransform['rows'])):
print(idx, value)
输出:
0 -0.7469096503244566
1 -0.0048362499036055774
2 -0.6649079522302825
3 -6.756347957309588
4 -0.6649255299159078
5 0.005255128514812499
6 0.7468911723205343
7 7.333944516331069
8 -0.00011797562067967932
9 0.9999744968303753
10 -0.007140852231397498
11 -4.200072574252649
12 0
13 0
14 0
15 1
我使用 fSpy 软件:开源静态图像相机匹配 将结果与 Rhino 3d 一起使用,我导出到 jSon 文件,其中包含相机位置矩阵 我需要将 行 提取到带有 Python 的数字列表中 感谢帮助
从这个:
"cameraTransform": {
"rows": [
[
-0.7469096503244566,
-0.0048362499036055774,
-0.6649079522302825,
-6.756347957309588
],
[
-0.6649255299159078,
0.005255128514812499,
0.7468911723205343,
7.333944516331069
],
[
-0.00011797562067967932,
0.9999744968303753,
-0.007140852231397498,
-4.200072574252649
],
[
0,
0,
0,
1
]
]
}
到:
0 -0.7469096503244566
1 -0.0048362499036055774
2 -0.6649079522302825
3 -6.756347957309588
4 -0.6649255299159078
5 0.005255128514812499
6 0.7468911723205343
7 7.333944516331069
8 -0.00011797562067967932
9 0.9999744968303753
10 -0.007140852231397498
11 -4.200072574252649
12 0
13 0
14 0
15 1
将json格式转换为python格式后可以试试这个:
cameraTransform= {
"rows": [
[
-0.7469096503244566,
-0.0048362499036055774,
-0.6649079522302825,
-6.756347957309588
],
[
-0.6649255299159078,
0.005255128514812499,
0.7468911723205343,
7.333944516331069
],
[
-0.00011797562067967932,
0.9999744968303753,
-0.007140852231397498,
-4.200072574252649
],
[
0,
0,
0,
1
]
]
}
from itertools import chain
for idx, value in enumerate(chain(*cameraTransform['rows'])):
print(idx, value)
输出:
0 -0.7469096503244566
1 -0.0048362499036055774
2 -0.6649079522302825
3 -6.756347957309588
4 -0.6649255299159078
5 0.005255128514812499
6 0.7468911723205343
7 7.333944516331069
8 -0.00011797562067967932
9 0.9999744968303753
10 -0.007140852231397498
11 -4.200072574252649
12 0
13 0
14 0
15 1