0

I'm using Open3D in Python to sample 1000 points on the same .obj file to get a point cloud. But every time you process the same .obj file, you end up with a different point cloud.

Is there a way to get the same point cloud for the same .obj file every time? GPT suggests setting a random seed, but it doesn't work after I set it.

# 从OBJ文件中加载点云数据
mesh = o3d.io.read_triangle_mesh(objFilePath)
# 按密度均匀采点(更加均匀)
density_pcd = mesh.sample_points_poisson_disk(cloudCount)

1 Answer 1

0

You can use o3d.utility.random.seed method to seed the pseudo random number generator.

import numpy as np
import open3d as o3d

mesh = o3d.io.read_triangle_mesh(o3d.data.BunnyMesh().path)

o3d.utility.random.seed(0)
pcd1 = mesh.sample_points_poisson_disk(10000)

o3d.utility.random.seed(0)
pcd2 = mesh.sample_points_poisson_disk(10000)

print("Attempt 1 - ", np.asarray(pcd1.points))
print("Attempt 2 - ", np.asarray(pcd2.points))

This outputs:

Attempt 1 -  [[ 0.01492238  0.09300141 -0.02622804]
 [-0.01413355  0.03830949  0.01325172]
 [ 0.00476777  0.03917924  0.02900373]
 ...
 [-0.05335926  0.05457066 -0.00657736]
 [ 0.03605862  0.08903801  0.03850483]
 [-0.02861732  0.06359598 -0.02864595]]
Attempt 2 -  [[ 0.01492238  0.09300141 -0.02622804]
 [-0.01413355  0.03830949  0.01325172]
 [ 0.00476777  0.03917924  0.02900373]
 ...
 [-0.05335926  0.05457066 -0.00657736]
 [ 0.03605862  0.08903801  0.03850483]
 [-0.02861732  0.06359598 -0.02864595]]

Note this approach might not always work for all Open3D methods. For example, if the random number is generated by one of the dependencies (such as uvatlas), this method will not help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.