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.scene().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.scene()._bag_lock:
            msg_topic, msg, msg_stamp = bag._read_message(pos)

        # Convert from ROS image to PIL image
        try:
            pil_image = image_helper.imgmsg_to_pil(msg)
        except Exception, ex:
            print >> sys.stderr, 'Error loading image on topic %s: %s' % (
                topic, str(ex))
            pil_image = None
Exemplo n.º 2
0
 def set_image(self, image_msg, image_topic, image_stamp):
     self._image_msg = image_msg
     if image_msg:
         self._image = image_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()
Exemplo n.º 3
0
 def set_image(self, image_msg, image_topic, image_stamp):
     self._image_msg = image_msg
     if image_msg:
         self._image = image_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 _save_image_msg(img_msg, filename):
    pil_img = image_helper.imgmsg_to_pil(img_msg, rgba=False)

    if pil_img.mode in ('RGB', 'RGBA'):
        pil_img = pil_img.convert('RGB')
        pil_img = image_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):
        with self._image_lock:
            self._image_msg = image_msg
            if image_msg:
                self._image = image_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)
Exemplo n.º 6
0
    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.scene().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.scene()._bag_lock:
            msg_topic, msg, msg_stamp = bag._read_message(pos)

        # Convert from ROS image to PIL image
        try:
            pil_image = image_helper.imgmsg_to_pil(msg)
        except Exception as ex:
            print('Error loading image on topic %s: %s' % (topic, str(ex)),
                  file=sys.stderr)
            pil_image = None

        if not pil_image:
            print('Disabling renderer on %s' % topic, file=sys.stderr)
            self.timeline.set_renderer_active(topic, False)
            return None, None

        # Calculate width to maintain aspect ratio
        try:
            pil_image_size = pil_image.size
            thumbnail_width = int(
                round(thumbnail_height *
                      (float(pil_image_size[0]) / pil_image_size[1])))
            # Scale to thumbnail size
            thumbnail = pil_image.resize((thumbnail_width, thumbnail_height),
                                         self.quality)

            return msg_stamp, thumbnail

        except Exception as ex:
            print('Error loading image on topic %s: %s' % (topic, str(ex)),
                  file=sys.stderr)
            raise
            return None, None
    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_helper.imgmsg_to_pil(msg)
        except Exception, ex:
            print >> sys.stderr, 'Error loading image on topic %s: %s' % (topic, str(ex)) 
            return None, None