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

[Unity] Textured Point Cloud #1293

Merged
merged 3 commits into from
Mar 19, 2018
Merged

Conversation

zivsha
Copy link
Contributor

@zivsha zivsha commented Mar 7, 2018

This PR adds a few addition to the C# wrapper, and provides a demo of creating texturized point cloud in Unity.

C# Additions:

  • PointCloud.MapTexture and Points.TextureCoordinate to allow users to map a color image to the point cloud's points.
  • FrameQueue.Enqueue allowing users to push frames to a frame queue.
  • Allowing covariance for FrameQueue.PollForFrames.

Unity Additions:

  • Code cleanup and small refactoring for PointCloudGenerator.cs to allow texture mapping of color frames

Known Issue
High memory usage / memory leak when displaying textured point cloud in Unity.

- TextureCoordinate to Point class
- MapTexture to PointCloud class
- Enqueue to FrameQueue class
@zivsha zivsha changed the title Unity2 [Unity] Textured Point Cloud Mar 7, 2018
private float Remap(float value, float from1, float to1, float from2, float to2)
{
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
vertices = vertices ?? new Points.Vertex[points.Count];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use this for Unity. Vertex matches Vector3, TextureCoordinate matches Vector2.
Use a Vector3[] instead of Vertex[] and manually marshal the array.

Then PointCloudGenerator.cs#L126 wouldn't allocate so much.
You're also allocating here: PointCloudGenerator.cs#L132, that's what Vector3.Zero is for...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds right, how much do you think this affects performance though?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One less copy per vertex should help.
Still, there's more to do, particles aren't really the most performant way of rendering point clouds... Meshes are better suited, since you can update all of Mesh.vertices at once with one write (assuming you already have the pointcloud as a Vector3[])

Copy link
Contributor Author

@zivsha zivsha Mar 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ev-mp , I've removed the redundant allocation PointCloudGenerator.cs#L132 in the next commit, but the vertex copy still requires change.

@dorodnic dorodnic merged commit c7fcfd9 into IntelRealSense:development Mar 19, 2018
@zivsha zivsha deleted the unity2 branch March 26, 2018 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants