-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 color for sampling from mesh #6842
Add color for sampling from mesh #6842
Conversation
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
cpp/open3d/geometry/TriangleMesh.cpp
Outdated
pcd->colors_[point_idx] = Eigen::Vector3d( | ||
(double) *textures_[0].PointerAt<uint8_t>(uv(0) * w, uv(1) * h, 0) / 255 , | ||
(double) *textures_[0].PointerAt<uint8_t>(uv(0) * w, uv(1) * h, 1) / 255 , | ||
(double) *textures_[0].PointerAt<uint8_t>(uv(0) * w, uv(1) * h, 2) / 255); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjaminum
I'm not an Computer graphics expert. It seems the barycentric coordinates you were referring to (#2483 (comment)) are a sort of mixture weights for triangles (in this case it looks like a,b,c ?). Unfortunately this code seems to samples from the correct colors but from the wrong position in the texture map.
Am I making a mistake here with the uv
computation or am I using the PointerAt
function wrong ?
Maybe you see a mistake immediately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try (1-uv(1))*h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could it be that triangle(0), triangle(1), triangle(2)
in triangle_uvs_
don't select adjacent triangle vertices in the texture?
I'm trying to run it on a cube with different surface colors. This is the texture map:
sampled vertices were:
if we take a weighted average of these sampled points, we might end up in the black area (no valid texture).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the triangle_index_generator
does not take this into account, or something is unexpected in triangle_uvs_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikste triangle stores the indices of the vertices but we need the index to the right uv.
triangle_uvs_
if I recall correctly should have the size 3*#triangles. Can you try to get the uvs with [3tidx, 3tidx+1, 3*tidx+2]?
@benjaminum Couple of questions:
|
from my side this can be reviewed. |
Great! Results look good. I think we now have to answer questions 1-3 and define what we want.
|
I found this PR helpful, thanks for contributing. In terms of 1 to support multiple materials, here is one working version.
|
thanks @yshen47 ill take a look the next few days to incorporate this. haven't had much time to work on this before. |
@nikste Take your time, it should work after copy-and-paste the single file:) |
@benjaminum
|
for 3. different datatypes for textures: Open3D/cpp/open3d/geometry/Image.h Line 224 in fcf98ee
So, normalization with maximum value 255 should be ok, shouldn't it?
|
Yes that should be fine |
incorporated code from @yshen47, now uses |
forgot to add apply the style script, my bad. Style is applied now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds color to point cloud sampled from mesh
(#2483)
Type
Motivation and Context
Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description