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

Both positive and negative (u,v) coordinates #12392

Closed
jwatson-CO-edu opened this issue Nov 11, 2023 · 1 comment
Closed

Both positive and negative (u,v) coordinates #12392

jwatson-CO-edu opened this issue Nov 11, 2023 · 1 comment

Comments

@jwatson-CO-edu
Copy link

jwatson-CO-edu commented Nov 11, 2023

Model: D405

I am attempting to interpret the uv coordinates in order to generate an XYZRGB point cloud in python. I do not understand what is meant when V takes on both positive and negative values. I attempted to follow this guide:

The mapping of (u,v) to a color pixel is:
For {u/v} : [0-1] --> [0-{width-1/height-1}], Meaning that
(0,0) is mapped to (0,0)
(0,1) is mapped to (0,height-1)
(1,0) is mapped to (width-1,0)
(1,1) is mapped to (width-1,height-1)

We do not provide a function that takes texture (u, v) and returns RGB (r, g, b, a), mainly because mostly rendering libraries take texture parameters and will handle it on their own. But you can do the mapping yourself if you wish by converting texture to pixel using the above explanation.

Originally posted by @zivsha in #1231 (comment)

To produce

pc = rs.pointcloud()
pc.map_to( colFrm )
points = pc.calculate( depFrm )
vtx = np.asarray( points.get_vertices(2) )
tex = np.asarray( points.get_texture_coordinates(2) )
col = np.zeros( (vtx.shape[0], 3), dtype = int )

for k, uvCoord in enumerate( tex ):
    i = int( min( uvCoord[0], 1.0) * (self.cols-1) )
    j = int( -uvCoord[1] * (self.rows-1) )
    print( uvCoord, i ,j )
    col[k,:] = colImg[j,i,:]

Somtimes UV is [ 0.09909751 -0.05718123] and sometimes it is [0.39045626 0.36308518].
Also, it was necessary for me to clip U to 1.0 in this scheme.

@jwatson-CO-edu
Copy link
Author

The Open3D library has facilities for this:
https://github.com/correlllab/MAGPIE/blob/PDDLStream_Testing/40_blocks_detect/42_Get-PCD-Color.ipynb
Although I do not understand the negative V values or U values greater than 1.0, I no longer need to. Issue closed.

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

No branches or pull requests

1 participant