質問編集履歴
4
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -81,6 +81,7 @@
|
|
81
81
|
```
|
82
82
|
|
83
83
|
### plyファイルの中身
|
84
|
+
plyファイルの中身を出力するコード
|
84
85
|
|
85
86
|
```python
|
86
87
|
import struct
|
@@ -104,6 +105,8 @@
|
|
104
105
|
print (struct.unpack('f', f.read(4))[0], end=' ')
|
105
106
|
print ("")
|
106
107
|
```
|
108
|
+
|
109
|
+
出力されたplyファイルの中身
|
107
110
|
|
108
111
|
```output.txt
|
109
112
|
b'ply\r\n'
|
3
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -81,7 +81,31 @@
|
|
81
81
|
```
|
82
82
|
|
83
83
|
### plyファイルの中身
|
84
|
+
|
85
|
+
```python
|
86
|
+
import struct
|
87
|
+
file_path = 'input.ply'
|
88
|
+
|
89
|
+
with open(file_path, 'rb') as f:
|
90
|
+
# read header
|
91
|
+
while True:
|
92
|
+
line = f.readline()
|
93
|
+
print (line)
|
94
|
+
if b'end_header' in line:
|
95
|
+
break
|
96
|
+
if b'vertex ' in line:
|
97
|
+
vnum = int(line.split(b' ')[-1]) # num of vertices
|
98
|
+
if b'face ' in line:
|
99
|
+
fnum = int(line.split(b' ')[-1]) # num of faces
|
100
|
+
|
101
|
+
# read vertices
|
102
|
+
for i in range(vnum):
|
103
|
+
for j in range(3):
|
104
|
+
print (struct.unpack('f', f.read(4))[0], end=' ')
|
105
|
+
print ("")
|
84
106
|
```
|
107
|
+
|
108
|
+
```output.txt
|
85
109
|
b'ply\r\n'
|
86
110
|
b'format binary_little_endian 1.0\r\n'
|
87
111
|
b'comment pointcloud saved from Realsense Viewer\r\n'
|
2
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
**別のplyファイルを3次元座標をもとに出力させた時**
|
21
21
|

|
22
22
|
|
23
|
-
|
23
|
+
|
24
24
|
### 該当のソースコード
|
25
25
|
|
26
26
|
```python
|
1
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,6 +80,27 @@
|
|
80
80
|
plt.show()
|
81
81
|
```
|
82
82
|
|
83
|
+
### plyファイルの中身
|
84
|
+
```
|
85
|
+
b'ply\r\n'
|
86
|
+
b'format binary_little_endian 1.0\r\n'
|
87
|
+
b'comment pointcloud saved from Realsense Viewer\r\n'
|
88
|
+
b'element vertex 173845\r\n'
|
89
|
+
b'property float32 x\r\n'
|
90
|
+
b'property float32 y\r\n'
|
91
|
+
b'property float32 z\r\n'
|
92
|
+
b'property uchar red\r\n'
|
93
|
+
b'property uchar green\r\n'
|
94
|
+
b'property uchar blue\r\n'
|
95
|
+
b'element face 335218\r\n'
|
96
|
+
b'property list uchar int vertex_indices\r\n'
|
97
|
+
b'end_header\r\n'
|
98
|
+
-0.999194860458374 0.7624208927154541 -1.4152500629425049
|
99
|
+
-43201033404416.0 -8.505155401575953e-14 -2.472513521814055e-24
|
100
|
+
1.9825851062962584e-23 2.3415821739039566e+27 4.552246991806896e-06
|
101
|
+
...
|
102
|
+
```
|
103
|
+
|
83
104
|
### 最後に
|
84
105
|
|
85
106
|
うまくいく時といかない時の違いがわかりません.
|