def make_rated_out_shapes(self, data): shapes = [] for info in data[VIZ_KEY_BALL_RATING_OUT]: x, y, radius, rating = info x, y, radius = transform_relative_to_pixel(x, y, radius, self.image_width, self.image_height) shapes.extend(red_ball(x, y, radius)) shapes.extend(red_text(x, y, "R: %.0f" % rating)) return shapes
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)