Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Loading and Saving OBJ, loss of precision

Open EODEFX opened this issue 2 years ago • 3 comments

Checklist

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)

EODEFX avatar Dec 02 '22 01:12 EODEFX

i have the same problem

DavidCao1993 avatar Nov 10 '23 09:11 DavidCao1993

Having the same question.

huonghld avatar Feb 08 '24 23:02 huonghld

Having same problem here. Anyone can help with this? @errissa

qiwu-nuro avatar Jun 04 '24 07:06 qiwu-nuro