Open3D
Open3D copied to clipboard
Loading and Saving OBJ, loss of precision
Checklist
- [X] I have searched for similar issues.
- [X] For Python issues, I have tested with the latest development wheel.
- [X] I have checked the release documentation and the latest documentation (for
masterbranch).
My Question
I am attempting to reproject obj meshes from one coordinate system to another and would like to use open3d to access the mesh vertex array. The problem I'm running into is that open3d can't seem to handle the precision and large numbers stored in the obj's I'm using. Example vertices: v -2487002.881739342 -4684683.676570751 3529638.9835389843 v -2487004.0341807394 -4684683.789984506 3529638.299934322 v -2487003.1884904536 -4684683.513722925 3529638.9835389843
If I open this obj and save it right back out, these are the vertices: v -2.487e+06 -4.68468e+06 3.52964e+06 v -2.487e+06 -4.68468e+06 3.52964e+06 v -2.487e+06 -4.68468e+06 3.52964e+06
Is there a property or setting that I need to use to prevent this loss of information?
Here is my current code:
import open3d as o3d
import numpy as np
import json
from decimal import Decimal as dec
from pyproj import Transformer
from pyproj import CRS
from pyproj import Proj,itransform
filename = r"downloaded_files\obj\20525362626173417-30-933_edit\model.obj"
mesh = o3d.io.read_triangle_mesh(filename, True, print_progress=True)
crs1 = CRS.from_epsg(4328)
crs2 = CRS.from_epsg(2229)
reproj = Transformer.from_crs(crs1,crs2)
file = open(r"downloaded_files\obj\20525362626173417-30-933_edit\log.txt", "a")
file.write(f'{mesh.vertices[0][1]}')
file.close()
print(np.float64(mesh.vertices[0][1]).astype(str))
print(repr(mesh.vertices[0][2]))
'''
verts = np.asanyarray(mesh.vertices, dtype='object')
y,x,z = reproj.transform(verts[:,0],verts[:,1],verts[:,2])
reprojdata = np.column_stack((x,y,z))
mesh.vertices = o3d.utility.Vector3dVector(np.asanyarray(reprojdata, dtype='object'))
'''
o3d.io.write_triangle_mesh(r"downloaded_files\obj\20525362626173417-30-933_edit\model_reproj.obj",mesh, write_ascii=False)
i have the same problem
Having the same question.
Having same problem here. Anyone can help with this? @errissa