Color problems extracting RGB from Pointcloud2
Hello all,
I am trying to convert a PointCloud2 message into an xyzrgb text file but am having problems with the rgb.
I am using and Intel RealSense camera and can extract RGB values just fine using the following code.
def store_cloud(self, pc2_msg):
self.data = []
gen = pc2.read_points(pc2_msg, skip_nans=True, field_names=("x", "y", "z", "rgb"))
for data in gen:
test = data[3]
s = struct.pack('>f' ,test)
i = struct.unpack('>l',s)[0]
pack = ctypes.c_uint32(i).value
r = int((pack & 0x00FF0000)>> 16)
g = int((pack & 0x0000FF00)>> 8)
b = int((pack & 0x000000FF))
self.data.append([data[0], data[1], data[2], r, g, b])
However upon viewing the point cloud in CloudCompare the colors behave strangely.
Some of the colors such as my skin and a good portion of the cieling and walls are colored correctly, but the rest of the image is colored wrong. Blue botches bloom where there is high reflection and my pink shirt turns blue. The flourescent lights are also a bright shade of blue. I do not understand how there can be such a discrepancy between the RVIZ display and the colored point cloud i extracted.
These images show the problem I am having.
If anyone has any ideas of how to fix this i would love to hear them.
RVIZ_pointcloud
My_pointcloud
Please attach your images directly to your question. I've given you sufficient karma.
@gvdhoorn Thanks for the karma!
I am also facing the same problem? Is there a solution/ reason to it?