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

Is there any example of loading objects in the scene? #185

Closed
Steve-Tod opened this issue Mar 11, 2022 · 4 comments
Closed

Is there any example of loading objects in the scene? #185

Steve-Tod opened this issue Mar 11, 2022 · 4 comments

Comments

@Steve-Tod
Copy link

Hi,

Thank you for your great work! It must take a great amount of effort to implement such a system!

Current only APIs for loading simple primitives and ShapeNet shapes are presented in the examples. Is there any simple way to load our own objects (maybe in the form of an obj file)?

@Steve-Tod
Copy link
Author

For example, how should I pre-process and load google scanned objects for simulation and rendering?

@Qwlouse
Copy link
Collaborator

Qwlouse commented Mar 24, 2022

Hi,
thank you for your question and sorry for being so unresponsive.

Two part answer:

Firstly, for ShapeNet and Google Scanned Objects there should be very little work on your part required.
For example this should work for GSO:

import kubric as kb
...
gso = kb.AssetSource.from_manifest("gs://kubric-public/assets/GSO/GSO.json")
obj = gso.create(asset_id="Marvel_Avengers_Titan_Hero_Series_Doctor_Doom")
scene += obj

See the movi_c_worker for a full example.

The same works for ShapeNet with the only exception that you first need to register at the shapenet.org and agree to their terms, to find the corresponding AssetSource link. See shapenet.py for a full example.

The second part about preprocessing custom objects is slightly more complicated. We do not yet have documentation on that.
If you just want to add a single asset in obj, gltf or blender format for rendering, then the easiest would probably be to manually instantiate a FileBasedObject. Something like this:

obj = kb.FileBasedObject(
  asset_id="custom", 
  render_filename="custom.obj", 
  bounds=((-1, -1, -1), (1, 1, 1)),
  simulation_filename=None)

scene += obj

To make this work for simulation you would need to create a collision mesh in obj format and a corresponding urdf file that you can pass as simulation_filename. If your mesh is watertight, you can take a look at the GSO preprocessing script about how to do that. If not, then things get complicated, and you will have to do more than that. The ShapeNet preprocessing scripts can serve as a starting point there.

@Steve-Tod
Copy link
Author

Thank you for your help!

@WenyuanQ
Copy link

Hi Thank you very much for the helping!

I have successfully added '.obj' file into scene using function: kb.FileBasedObject(). I'd like to ask if I can add '.mtl' or '.jpg' texture information into this object? Thanks.
And another question, when I add object into scene, seems it cannot generate segmentation annotation. Could you please tell me how can I make it correct?

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

No branches or pull requests

3 participants