Skip to content

Instantly share code, notes, and snippets.

@shubhamwagh
Created November 13, 2020 12:34
Show Gist options
  • Select an option

  • Save shubhamwagh/6932e34cbfa9e83d6c15fa1700571f33 to your computer and use it in GitHub Desktop.

Select an option

Save shubhamwagh/6932e34cbfa9e83d6c15fa1700571f33 to your computer and use it in GitHub Desktop.
ROS PointClou2 to numpy conversion (this will avoid bit flip)
colours = np.array([
bytearray(msg.data[rgb_field.offset + 2::msg.point_step]),
bytearray(msg.data[rgb_field.offset + 1::msg.point_step]),
bytearray(msg.data[rgb_field.offset + 0::msg.point_step])
]).transpose().astype(np.float32)/255.0
@shubhamwagh
Copy link
Author

Reading it directly from the data buffer preserves colour data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment