Open zouwenqin opened 3 years ago
I faced the same issue. Help please!
I faced the same issue. Help please!
maybe you can convert the obj to off manually by above code
`def obj2off(objpath, offpath):
'''
将obj文件转换为off文件
:param objpath: .obj文件的路径
:param offpath: .off文件的路径的保存地址
:return: 无
'''
line = ""
vset = []
fset = []
with open(objpath,'r') as f:
lines = f.readlines()
p = re.compile(r'/+')
space = re.compile(r' +')
for line in lines:
#拿到obj文件中一行,作为一个字符串
tailMark = " "
line = line+tailMark
if line[0]!='v' and line[0]!='f' :
continue
parameters = space.split(line.strip())
if parameters[0] == "v": #如果是顶点的话
Point = []
Point.append(eval( parameters[1]) )
Point.append(eval( parameters[2]) )
Point.append(eval( parameters[3]) )
vset.append(Point)
elif parameters[0] == "f": #如果是面的话,存放顶点的索引
vIndexSets = [] #临时存放点的集合
for i in range(1,len(parameters) ):
x = parameters[i]
ans = p.split(x)[0]
index = eval(ans)
index -= 1 #因为顶点索引在obj文件中是从1开始的,而我们存放的顶点是从0开始的,因此要减1
vIndexSets.append(index)
fset.append(vIndexSets)
with open(offpath, 'w') as out:
out = open(offpath, 'w')
out.write("OFF\n")
out.write(str(vset.__len__()) + " " + str(fset.__len__()) + " 0\n")
for j in range(len(vset)):
out.write(str(vset[j][0]) + " " + str(vset[j][1]) + " " + str(vset[j][2]) + "\n")
for i in range(len(fset)):
s = str(len( fset[i] ))
for j in range( len( fset[i] ) ):
s = s+ " "+ str(fset[i][j])
s += "\n"
out.write(s)
Dear Julian
i noticed the command line above and tried to uncomment the annotation but still error, my enviroment is ubuntu18, and i found that i can't find xvfb-run package. help!!!