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

Fix rendering of pointclouds in PCLVisualizer #4067

Merged
merged 1 commit into from
May 9, 2020

Conversation

larshg
Copy link
Contributor

@larshg larshg commented May 8, 2020

Fixes #4040.

The culprit was the "memory leak" fixed in #3687.

Note:

Can we in some way avoid the memcpy - or maybe concatenate them to a single copy?
The XYZ will always be aligned?

Are we preparing to change at compile time, the underlaying datatype, ie. switch between float and double. Then this would require a bit more revamp I guess :)

@kunaltyagi
Copy link
Member

The XYZ will always be aligned?

This is not a guarantee (and stated explicitly in PCL's codebase)

to change at compile time, the underlaying datatype

In future maybe. I don't have any plans for that right now.

The culprit was the "memory leak" fixed in #3687

The leak was needed, as in SetArray takes ownership of the array?

@kunaltyagi kunaltyagi added changelog: fix Meta-information for changelog generation module: visualization needs: code review Specify why not closed/merged yet labels May 8, 2020
kunaltyagi
kunaltyagi previously approved these changes May 8, 2020
Copy link
Member

@kunaltyagi kunaltyagi left a comment

Choose a reason for hiding this comment

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

LGTM. It's simpler even.

@kunaltyagi kunaltyagi added this to the pcl-1.11.0 milestone May 8, 2020
@kunaltyagi
Copy link
Member

kunaltyagi commented May 8, 2020

Adding to milestone since it is a fix to regression in a key feature (and PCL 1.11.1 isn't planned, at least right now)

@larshg
Copy link
Contributor Author

larshg commented May 8, 2020

The XYZ will always be aligned?

This is not a guarantee (and stated explicitly in PCL's codebase)

So best to keep the single copy for each component I guess.

to change at compile time, the underlaying datatype

In future maybe. I don't have any plans for that right now.

Oki, I won't overthink this then and keep it as is.

The culprit was the "memory leak" fixed in #3687

The leak was needed, as in SetArray takes ownership of the array?

Yes, the 0 (save) indicates that the array should be deleted by VTK. Also, since no delete method is explicit set (overload of SetArray), its default is free().

I'm unsure exactly how VTK expands its array, with the AddNextTuple vs. us allocating the full array, so a benchmark would have been nice :)

But yes, I also think its simpler to read now.

There are places in the color handles that has the same procedure, which could be simplified, though again I'm not sure if it gives a small performance/memory degradation.

@larshg
Copy link
Contributor Author

larshg commented May 8, 2020

I think if it adds a point, which there is no space for, it increase its array with 1 / numberofcomponents, which is 3 (XYZ), ie 1/3 of its current index count, each time it expands its array.
So this will eventually leads to overshoot of array sizes.

Maybe, go back to the array/malloc approach.

@larshg
Copy link
Contributor Author

larshg commented May 8, 2020

Fixed it, with adding call to resize before adding values to the array.

@kunaltyagi kunaltyagi dismissed their stale review May 8, 2020 10:28

New code added

@kunaltyagi kunaltyagi self-requested a review May 8, 2020 10:28
@larshg larshg force-pushed the FixRenderingOfPoints branch from db21a42 to 20d0efd Compare May 8, 2020 11:41
@themightyoarfish
Copy link
Contributor

Confirmed to fix #4040 on osx.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

Once the variable scope thing is addressed feel free to merge.

@larshg larshg force-pushed the FixRenderingOfPoints branch from f89ca7b to c2675cd Compare May 8, 2020 14:46
Copy link
Member

@kunaltyagi kunaltyagi left a comment

Choose a reason for hiding this comment

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

Pending CI

@kunaltyagi kunaltyagi added needs: testing Specify why not closed/merged yet and removed needs: code review Specify why not closed/merged yet labels May 8, 2020
@kunaltyagi kunaltyagi merged commit 1e25568 into PointCloudLibrary:master May 9, 2020
@taketwo taketwo changed the title Fix rendering of points. Fix rendering of pointclouds in PCLVisualizer May 10, 2020
@larshg larshg deleted the FixRenderingOfPoints branch May 10, 2020 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Meta-information for changelog generation module: visualization needs: testing Specify why not closed/merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[tools] pcl_viewer does not show clouds anymore
4 participants