-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_grasps.py
40 lines (35 loc) · 1.07 KB
/
sample_grasps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'''
Description: In User Settings Edit
Author: Qianen
Date: 2021-09-14 18:50:21
LastEditTime: 2021-09-28 21:34:37
LastEditors: Qianen
'''
import sys
import pickle
from pathlib import Path
from ogsom.ogmanager import OGManager
SCALE = 1
STEP = 0.005
def process(obj_path):
print('start to process file:', obj_path.as_posix())
ogm = OGManager.from_obj_file(obj_path, step=STEP, scale=SCALE)
# 避免在atlas上rtree无法使用的问题
# ogm.mesh = None
pkl_path = obj_path.with_suffix('.pkl')
if pkl_path.exists():
print('remove file:', pkl_path.as_posix())
pkl_path.unlink()
with open(pkl_path, 'wb') as f:
pickle.dump(ogm, f)
if __name__ == '__main__':
for arg in sys.argv[1:]:
p = Path(arg).resolve()
if not p.exists():
print(p.as_posix(), 'is not a file(suffix .obj) or folder')
if p.is_dir():
for fp in p.iterdir():
if fp.is_file() and fp.suffix == '.obj':
process(fp)
elif p.is_file() and p.suffix == '.obj':
process(p)