Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto_scaling parameter for scaling the mesh inside the unit sphere #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maurock
Copy link

@maurock maurock commented Dec 5, 2022

Problem statement

When the method sample_sdf_near_surface(..) is called, the mesh is first scaled to fit into a unit sphere. The scaling ratio is not fixed, as it depends on the object geometry - which means that different objects are scaled differently. While in the virtual domain this is not a problem, as we can extract geometry information from the simulator, a geometry-dependent scaling ratio is a problem in the real world, where we cannot extract geometry information from the object easily. Therefore, it is essential to have a way to keep the scaling ratio fixed for all the objects in our dataset. Moreover, having control over the scaling ratio could be beneficial in the virtual domain as well.

Changes

This PR adds two parameters to the methods sample_sdf_near_surface(..) and scale_to_unit_sphere(..) :

  • auto_scaling: when True, the mesh is automatically scaled to fit into a unit sphere. Thus, nothing changes from the current repository. When False, the mesh is scaled according to the parameter scale_ratio.
  • scale_ratio: this parameter is used to scale the original mesh when the method scale_to_unit_sphere(..) is called. This parameter allows to have control over the scaling procedure.

Example

# sample from mesh_1 and mesh_2, keeping the ratio between the original and resulting mesh fixed at 1.3
samples_1 = mesh_to_sdf.sample_sdf_near_surface(mesh_1, auto_scaling=False, scale_ratio = 1.3)[0]
samples_2 = mesh_to_sdf.sample_sdf_near_surface(mesh_2, auto_scaling=False, scale_ratio = 1.3)[0]

# plot the samples
fig = plotly.graph_objects.Figure(
            [   go.Scatter3d(
                     x=samples_1[:, 0], y=samples_1[:, 1],  z=samples_1[:, 2], 
                     mode='markers', marker=dict(size=1, color='darkblue') ),
                 go.Scatter3d(
                     x=samples_2[:, 0], y=samples_2[:, 1], z=samples_2[:, 2], 
                     mode='markers', marker=dict(size=1, color='orange')  )
            ]
        )
fig.show()

image

Both objects have been scaled by the same ratio, therefore we can use the DeepSDF method in downstream tasks in the real world.

I hope this makes sense, I am happy answer any questions you may have about this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant