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

Strange color behavior when saving .PCD file and loading it again. from [PCL-users] #1543

Closed
r9y9 opened this issue Feb 19, 2016 · 11 comments
Closed
Labels
kind: bug Type of issue

Comments

@r9y9
Copy link
Contributor

r9y9 commented Feb 19, 2016

ref: http://www.pcl-users.org/Strange-color-behavior-when-saving-PCD-file-and-loading-it-again-td4040975.html

I was able to reproduce this with my PCD file (captured by Kinect v2) locally, so I filed this issue here.

A sample code and pcd file can be found at https://github.com/r9y9/pcdio_test.

Orignal point cloud captured by kinect v2:

2016-02-19 13 28 03

Saving and loading it again then:

2016-02-19 13 28 57

This strange behavior only happens when saving PCD file as ASCII (no problem in binary mode). I'm testing with PCL trunk on osx 10.10.4.

@VictorLamoine
Copy link
Contributor

Thanks for the complete test code!
I can reproduce this issue on Ubuntu 14.04 with PCL trunk and PCL 1.7.2.

Your input PCD file doesn't seem to be corrupted, I used pcl_converter to convert it to a PLY file and it is fine.

@VictorLamoine VictorLamoine added the kind: bug Type of issue label Feb 19, 2016
@UnaNancyOwen
Copy link
Member

I'll report test results.
I can reproduce this issue as well on Windows (vc14) with PCL 1.8.0rc1.

Maybe, This issue seems to occur only when using pcl::PointXYZRGB.
(This issue didn't occur when using pcl::PointXYZRGBA.)

@SergioRAgostinho
Copy link
Member

I was able to reproduce it as well. I'm looking into this now.

@SergioRAgostinho
Copy link
Member

The issue is related to our float representation of color. As you know, color is stored in 32bits, sometimes as float with the member name ' rgb' sometimes as a unit32_t with member name 'rgba' . The color information is packed as

uint8_t alpha | uint8_t red | uint8_t green | uint8_t blue

Now according to the IEEE 754 NaN definition, if your first 9 bits are set to 1s, then the value is parsed as a NaN.

When we use the type PointXYZRGB and we get the fields for the pointcloud, it's inferring we have an rgb field of float type. When we then later do the pcl::is_nan check, everything in this format

s111 1111 1xxx xxxx xxxx xxxx xxxx xxxx

get's interpreted as nan.

I gotta admit, fixing this one requires some Boost MPL kung fu skill, I'm not really sure I have at the moment 😄, but let's see...

@VictorLamoine
Copy link
Contributor

What about #1385 ?

@SergioRAgostinho
Copy link
Member

What about #1385 ?

It will solve the issue.

I really feel we should simply register all point types that have color with uint32_t rgba, and I tried it, but it opened even bigger problems 😄

@taketwo
Copy link
Member

taketwo commented Aug 18, 2016

Should be fixed by #1385, reopen if it is not.

@taketwo taketwo closed this as completed Aug 18, 2016
@dbersan
Copy link

dbersan commented May 24, 2018

I had this same issue today. So it's not solved? Any workaround?

@taketwo
Copy link
Member

taketwo commented May 24, 2018

Are you using 1.8.1 or master?

@dbersan
Copy link

dbersan commented May 24, 2018

I'm actually using pcl_ros... I guess it is 1.7, but I'm not sure. I needed to save the pointcloud from a topic. I guess it might easier to convert to XYZGRBA ?

@taketwo
Copy link
Member

taketwo commented May 25, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Type of issue
Projects
None yet
Development

No branches or pull requests

6 participants