def draw_image(self, data):
        # collects all shapes that are wanted by the user

        image = data[DATA_KEY_RAW_IMAGE]

        if not self.color:
            image = image[:, ::2]

        height, width = image.shape[:2]

        shapes = []
        if self.middle_line:
            shapes.extend(line(0, height / 2, width, height / 2, 0, 0, 0, 3))

        if self.ball_active:
            if self.ball_candidates:
                shapes.extend(data[VIZ_KEY_CANDIDATE_SHAPES])
            if self.ball_orange_bypass:
                shapes.extend(data[VIZ_KEY_ORANGE_BALL_SHAPE])
            if self.rated_ball:
                shapes.extend(data[VIZ_KEY_RATED_OUT_SHAPES])
            if self.balls_on_body:
                shapes.extend(data[VIZ_KEY_BODY_OUT_SHAPES])
            if self.small_ball:
                shapes.extend(data[VIZ_KEY_SMALL_OUT_SHAPES])
            if self.huge_ball:
                shapes.extend(data[VIZ_KEY_HUGE_OUT_SHAPES])
            if self.far_ball:
                shapes.extend(data[VIZ_KEY_FAR_OUT_SHAPES])
            if self.ball_list:
                shapes.extend(data[VIZ_KEY_BALL_POSSIBLE_LIST_SHAPE])

        if self.goal_active:
            if self.goal_candidate:
                shapes.extend(data[VIZ_KEY_GOAL_CANDIDATE_SHAPES])
            if self.goals_sorted:
                shapes.extend(data[VIZ_KEY_GOAL_SORTED_OUT_SHAPES])
            if self.final_goal:
                shapes.extend(data[VIZ_KEY_GOAL_FINAL_SHAPE])

        image = draw_shapes(image, shapes)

        cv2.imshow("Visualization", image[:, :, :3].copy())
    def draw_legend(self, data):

        leg_im = np.zeros((self.height, self.width), np.uint8)
        current_index = data.get(VIZ_KEY_CURRENT_FRAME, 0)
        number_images = data.get(VIZ_KEY_NUMBER_IMAGES, 0)

        #start position on the image
        x_start = 5
        y_start = 15
        shapes = []

        # Header
        shapes.extend(self.legend_header(self.width, self.nr_colums, x_start, y_start))
        x = x_start
        y = y_start + 20

        # General information
        if current_index != 0 and current_index != number_images - 1:
            shapes.extend(green_text(x, y, "Frame: %d of %d " % (current_index, number_images - 1)))
        else:
            shapes.extend(red_text(x, y, "Frame: %d of %d " % (current_index, number_images - 1)))

        #todo further stuff? maybe a statistic of seen balls until this bpoint

        # Ball information
        x = self.width/self.nr_colums + x_start

        shapes.extend(white_text_block(x, y, data[VIZ_KEY_BALL_STATISTIC]))

        texts = data[VIZ_KEY_BALL_LEGEND]
        shapes.extend(list_text(x, y, texts))
        chosen_text = "Chosen Ball: " + str(data.get(VIZ_KEY_BEST_BALL_NUMBER, []))
        shapes.extend(green_text(x, self.height - 10, chosen_text))

        # Goal informatiion
        x = 2 * self.width/self.nr_colums + x_start
        #todo add some meaningful information about the goals

        # Active features for visualization:
        activate_features = data[VIZ_KEY_ACTIVE_FEATURES]
        # Key bindings #todo only if datapictures
        x = 3 * self.width/self.nr_colums + x_start

        def active(key, features):
            k = key.lower()[3:].replace(" ", "_")
            if True in [(k in f or f in k) for f in features]:
                key = "x " + key
            else:
                key = key + "  "
            return key
        a = lambda k: active(k, activate_features)

        key_binding_string1 = [a("d: Image index + 1"),
                              a("a: Image index -1"),
                              a("w: Image index +10"),
                              a("s: Image index -10"),
                              a("e: Jump to end"),
                              a("q: Jump tp start"),
                              "",
                              a("c: Color/BW Image"),
                              a("y: middle line"),
                              "",
                              a("b: All Ball Viz"),
                              a("t: Ball candidates"),
                              a("z: Bad rated balls"),
                              a("u: Balls on body"),
                              a("i: Orange bypass"),
                              a("o: To small balls"),
                              a("h: To huge balls"),
                              a("j: To far balls"),
                              a("l: No. in chosen list"),
                              ""]

        key_binding_string2 = [a("g: All goal viz"),
                               a("v: Goal candidates"),
                               a("n: Goals sorted out"),
                               a("m: Final goal")]

        shapes.extend(white_text_block(x, y, key_binding_string1))
        x = 4 * self.width/self.nr_colums + x_start
        shapes.extend(white_text_block(x, y, key_binding_string2))

        leg_im = draw_shapes(leg_im, shapes)
        cv2.imshow("Legend", leg_im)