コード例 #1
0
    def render(self, tree, size=None, window_name="Render"):
        obs = tree.root.data["obs"]
        img = obs[-1] if type(obs) is list else obs

        if size: img = cv2.resize(img, size, interpolation=cv2.INTER_AREA)
        if len(img.shape) == 2: img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
        display_image_cv2(window_name, img)
コード例 #2
0
 def render_tree(self, tree, size=None, window_name="Render tree"):
     get_img = lambda obs: obs[-1] if type(obs) is list else obs
     root_img = get_img(tree.root.data["obs"])
     image = root_img / 255.0
     for child in tree.root.children:
         for node in child.breadth_first():
             image += 0.4 / 255.0 * (get_img(node.data["obs"])-root_img)
     display_image_cv2(window_name, cv2.resize(image, size, interpolation=cv2.INTER_AREA))
コード例 #3
0
    def render_tree(self, abstract_tree, size=None, window_name="Render tree"):
        get_img = lambda obs: obs[-1] if type(obs) is list else obs

        root = abstract_tree.root.low_level_tree.root
        root_img = get_img(root.data["obs"])
        image = root_img/255.0
        for child in root.children:
            image += self._get_image_from_subtree(child, background=root_img)
        if size:
            image = cv2.resize(image, size, interpolation=cv2.INTER_AREA)
        display_image_cv2(window_name, image)
コード例 #4
0
 def render_downsampled(self, tree, max_pix_value, size=None, window_name="Render downsampled"):
     if "downsampled_image" in tree.root.low_level_tree.root.data:
         img = tree.root.low_level_tree.root.data["downsampled_image"]
         display_image_cv2(window_name, img/float(max_pix_value))
コード例 #5
0
 def render_downsampled(self, tree, max_pix_value, size=None, window_name="Render downsampled"):
     if "downsampled_image" in tree.root.data:
         img = tree.root.data["downsampled_image"]
         if size: img = cv2.resize(img, size, interpolation=cv2.INTER_AREA)
         if len(img.shape) == 2: img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
         display_image_cv2(window_name, img/float(max_pix_value))