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

Sample points from textured mesh #2483

Closed
sebaFP opened this issue Oct 15, 2020 · 14 comments · Fixed by #6842
Closed

Sample points from textured mesh #2483

sebaFP opened this issue Oct 15, 2020 · 14 comments · Fixed by #6842

Comments

@sebaFP
Copy link

sebaFP commented Oct 15, 2020

Hi,
I need to generate a point cloud from a textured obj, I can generate it but without colors.
Can I generate a sample but getting vertex color from texture?
Thanks!

@griegler
Copy link
Contributor

Textures are not considered yet in sample_point_cloud_*. It shouldn't be hard to implement. Would you be interested in contributing a PR with our guidance?

@Xelawk
Copy link

Xelawk commented Dec 24, 2020

Textures are not considered yet in sample_point_cloud_*. It shouldn't be hard to implement. Would you be interested in contributing a PR with our guidance?

I also really need this feature

@ShougangShen
Copy link

Hi,
I need to generate a point cloud from a textured obj, I can generate it but without colors.
Can I generate a sample but getting vertex color from texture?
Thanks!

Hello, I have the same requirement as you. Have you realized this feature?

@Xelawk
Copy link

Xelawk commented Apr 6, 2021

Hi,
I need to generate a point cloud from a textured obj, I can generate it but without colors.
Can I generate a sample but getting vertex color from texture?
Thanks!

Hello, I have the same requirement as you. Have you realized this feature?

Yep, I have the code to do this operation. If you need it, please contact me :-)

@MaybeOjbk
Copy link

Hi,
I need to generate a point cloud from a textured obj, I can generate it but without colors.
Can I generate a sample but getting vertex color from texture?
Thanks!

Hello, I have the same requirement as you. Have you realized this feature?

Yep, I have the code to do this operation. If you need it, please contact me :-)
can you give me your code ?

@Xelawk
Copy link

Xelawk commented Jul 8, 2021

Hi,
I need to generate a point cloud from a textured obj, I can generate it but without colors.
Can I generate a sample but getting vertex color from texture?
Thanks!

Hello, I have the same requirement as you. Have you realized this feature?

Yep, I have the code to do this operation. If you need it, please contact me :-)
can you give me your code ?

OK, Tell me you email

@cr139139
Copy link

cr139139 commented Jul 9, 2021

Hi,
I need to generate a point cloud from a textured obj, I can generate it but without colors.
Can I generate a sample but getting vertex color from texture?
Thanks!

Hello, I have the same requirement as you. Have you realized this feature?

Yep, I have the code to do this operation. If you need it, please contact me :-)

Can I also get the code for the operation? I'll send a note to your gmail address.

@Xelawk
Copy link

Xelawk commented Jul 9, 2021

Feel free to the repo: https://github.com/Xelawk/mesh_utils
If it does help you, pls star it, Thanks

@cr139139
Copy link

cr139139 commented Jul 11, 2021 via email

@benjaminum
Copy link
Contributor

Thanks for sharing a solution.

@NiuCY
Copy link

NiuCY commented May 16, 2023

I think this way is better:
mesh = trimesh.load_mesh(mesh_path)
samples, face_idx, colors = trimesh.sample.sample_surface(mesh, 30000, sample_color=True)

@nikste
Copy link
Contributor

nikste commented Jun 23, 2024

It seems @Xelawk solution does not work anymore with the new version of Open3d (or I am doing something wrong)
@benjaminum @griegler can we reopen this and do you have some pointers how this could be implemented for open3d?

@nikste
Copy link
Contributor

nikste commented Jun 23, 2024

so I guess I can put it there:

if (has_vert_color) {

check if there has_textures() returns true and then read the color from the texture.
how to arrive at the right pixel coordinate though to read the color and add to the resulting point cloud color?
what does triangle_uvs[triangle_idx] ?

@benjaminum benjaminum reopened this Jun 24, 2024
@benjaminum
Copy link
Contributor

Hi @nikste
The steps to implement this would be

  1. Remember triangle idx for each point
  2. Compute triangle barycentric coordinates for the sampled point from the point xyz and the triangle vertices xyz
  3. Compute UV coordinates using the triangle_uvs with the weights from the barycentric coordinates
  4. Look up the color values in the texture at the respective UV coordinates

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

Successfully merging a pull request may close this issue.

10 participants