Guest User

Untitled

a guest
Apr 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import sfm
  2. import numpy as np
  3. shape_only = False # or True
  4. model = sfm.load('C:/Users/glbay/PycharmProjects/3DFaceReconstructionFromMultipleImages/3DMM/sfm_shape_29587.scm', shape_only)
  5. faces = model.faces
  6. shape = model.shape
  7. texture = model.texture
  8. pcamodel = model.shape.mean
  9.  
  10. try:
  11. file = open("C:/Users/glbay/PycharmProjects/3DFaceReconstructionFromMultipleImages/output/temp.obj" , "r+")
  12. except IOError:
  13. file = open("C:/Users/glbay/PycharmProjects/3DFaceReconstructionFromMultipleImages/output/temp.obj", "w")
  14. file.truncate()
  15. points = np.array(pcamodel)
  16. points = points.reshape(3,-1).T
  17. file.write("#OBJ file created by Bayarjargal.J n#Vertices : " + str(model.numvertices) + "n#Faces : "+ str(model.numfaces) +"n")
  18. for x, y ,z in points:
  19. file.write("v " + str(float("{0:.4f}".format(x))) + " " + str(float("{0:.4f}".format(y))) + " " + str(float("{0:.4f}".format(z))) + "n")
  20.  
  21. i = 0
  22. for a , b, c in faces:
  23. file.write("f " + str(c) + " " + str(b) + " " + str(a) + "n")
  24. i+=1
  25. print "FACES WRITTEN : " + str(i)
Add Comment
Please, Sign In to add comment