isl-org / isl-org/Open3D

Loading and Saving OBJ, loss of precision

Open
#5,753 4 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).

### 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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.