def _save_image_msg(img_msg, filename): pil_img = image_snappy_helper.imgmsg_to_pil(img_msg, rgba=False) if pil_img.mode in ('RGB', 'RGBA'): pil_img = pil_img.convert('RGB') pil_img = image_snappy_helper.pil_bgr2rgb(pil_img) pil_img = pil_img.convert('RGB') pil_img.save(filename)
def set_image(self, image_msg, image_topic, image_stamp): self._image_msg = image_msg if image_msg: self._image = image_snappy_helper.imgmsg_to_pil(image_msg) else: self._image = None self._image_topic = image_topic self._image_stamp = image_stamp self.put_image_into_scene()
def set_image(self, image_msg, image_topic, image_stamp): with self._image_lock: self._image_msg = image_msg if image_msg: self._image = image_snappy_helper.imgmsg_to_pil(image_msg) else: self._image = None self._image_surface = None self._image_topic = image_topic self._image_stamp = image_stamp wx.CallAfter(self.parent.Refresh)
def _load_thumbnail(self, topic, stamp, thumbnail_details): """ Loads the thumbnail from the bag """ (thumbnail_height,) = thumbnail_details # Find position of stamp using index t = rospy.Time.from_sec(stamp) bag, entry = self.timeline.get_entry(t, topic) if not entry: return None, None pos = entry.position # Not in the cache; load from the bag file with self.timeline._bag_lock: msg_topic, msg, msg_stamp = bag._read_message(pos) # Convert from ROS image to PIL image try: pil_image = image_snappy_helper.imgmsg_to_pil(msg) except Exception, ex: print >> sys.stderr, 'Error loading image on topic %s: %s' % (topic, str(ex)) return None, None