Skip to content

Instantly share code, notes, and snippets.

@iKrishneel
Created January 10, 2018 10:43
Show Gist options
  • Save iKrishneel/9997b01b376341ed07f2b160d5221aa3 to your computer and use it in GitHub Desktop.
Save iKrishneel/9997b01b376341ed07f2b160d5221aa3 to your computer and use it in GitHub Desktop.
convert_sensor_msg_to_pil
import numpy as np
from PIL import Image as PILImage
channel = int(np.ceil(len(img_msg.data)/(img_msg.height * img_msg.width)))
im = np.ndarray(shape=(img_msg.height, img_msg.width, channel),
dtype=np.uint8, buffer=img_msg.data)
pim = PILImage.fromarray(im)
pim.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment