Skip to content

Commit

Permalink
Allow rgb fields to be of type uint32 and rgba fields to be of type f…
Browse files Browse the repository at this point in the history
…loat
  • Loading branch information
stefanbuettner committed May 13, 2016
1 parent dc206ed commit 75e922b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions common/include/pcl/point_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,10 @@ namespace pcl
{
if (field.name == "rgb")
{
return (field.datatype == pcl::PCLPointField::FLOAT32 &&
// For fixing the alpha value bug #1141, the rgb field can also match
// uint32.
return ((field.datatype == pcl::PCLPointField::FLOAT32 ||
field.datatype == pcl::PCLPointField::UINT32) &&
field.count == 1);
}
else
Expand All @@ -712,8 +715,10 @@ namespace pcl
}
else
{
// For fixing the alpha value bug #1141, rgb can also match uint32
return (field.name == traits::name<PointT, fields::rgb>::value &&
field.datatype == traits::datatype<PointT, fields::rgb>::value &&
(field.datatype == traits::datatype<PointT, fields::rgb>::value ||
field.datatype == pcl::PCLPointField::UINT32) &&
field.count == traits::datatype<PointT, fields::rgb>::size);
}
}
Expand Down
2 changes: 1 addition & 1 deletion io/include/pcl/io/impl/pcd_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ pcl::PCDWriter::writeASCII (const std::string &file_name,
* because several fully opaque color values are mapped to
* nan.
*/
if ("rgb" == fields[i].name)
if ("rgb" == fields[d].name)
{
uint32_t value;
memcpy (&value, reinterpret_cast<const char*> (&cloud.points[indices[i]]) + fields[d].offset + c * sizeof (float), sizeof (float));
Expand Down

0 comments on commit 75e922b

Please sign in to comment.