def gl_display(self): # normalize coordinate system, no need this step in utility functions with gl_utils.Coord_System(0, 1, 0, 1): ref_point_norm = [r['norm_pos'] for r in self.circle_marker_positions if self.g_pool.capture.get_frame_index() == r['index']] cygl_utils.draw_points(ref_point_norm, size=35, color=cygl_utils.RGBA(0, .5, 0.5, .7)) cygl_utils.draw_points(ref_point_norm, size=5, color=cygl_utils.RGBA(.0, .9, 0.0, 1.0)) manual_refs_in_frame = [r for r in self.manual_ref_positions if self.g_pool.capture.get_frame_index() in r['index_range']] current = self.g_pool.capture.get_frame_index() for mr in manual_refs_in_frame: if mr['index'] == current: cygl_utils.draw_points([mr['norm_pos']], size=35, color=cygl_utils.RGBA(.0, .0, 0.9, .8)) cygl_utils.draw_points([mr['norm_pos']], size=5, color=cygl_utils.RGBA(.0, .9, 0.0, 1.0)) else: distance = abs(current - mr['index']) range_radius = (mr['index_range'][-1] - mr['index_range'][0]) // 2 # scale alpha [.1, .9] depending on distance to current frame alpha = distance / range_radius alpha = 0.1 * alpha + 0.9 * (1. - alpha) # Use draw_progress instead of draw_circle. draw_circle breaks # because of the normalized coord-system. cygl_utils.draw_progress(mr['norm_pos'], 0., 0.999, inner_radius=20., outer_radius=35., color=cygl_utils.RGBA(.0, .0, 0.9, alpha)) cygl_utils.draw_points([mr['norm_pos']], size=5, color=cygl_utils.RGBA(.0, .9, 0.0, alpha)) # calculate correct timeline height. Triggers timeline redraw only if changed self.timeline.content_height = max(0.001, self.timeline_line_height * len(self.sections))
def gl_display(self): """ use gl calls to render at least: the published position of the reference better: show the detected postion even if not published """ if self.active or self.visualize: # Draw hand detection results for (x1, y1, x2, y2), fingertips in zip(self.hand_viz, self.finger_viz): pts = np.array([[x1, y1], [x1, y2], [x2, y2], [x2, y1], [x1, y1]], np.int32) cygl_utils.draw_polyline(pts, thickness=3 * self.g_pool.gui_user_scale, color=cygl_utils.RGBA(0., 1., 0., 1.)) for tip in fingertips: if tip is not None: y, x = tip cygl_utils.draw_progress((x, y), 0., 1., inner_radius=25 * self.g_pool.gui_user_scale, outer_radius=35 * self.g_pool.gui_user_scale, color=cygl_utils.RGBA(1., 1., 1., 1.), sharpness=0.9) cygl_utils.draw_points([(x, y)], size=10 * self.g_pool.gui_user_scale, color=cygl_utils.RGBA(1., 1., 1., 1.), sharpness=0.9)
def _draw_close_reference(self, reference_location, diff_to_current): with self._frame_coordinate_system: alpha = 0.7 * (1.0 - diff_to_current / (self.close_ref_range + 1.0)) cygl_utils.draw_progress( reference_location.screen_pos, 0.0, 0.999, inner_radius=20.0, outer_radius=35.0, color=cygl_utils.RGBA(0, 0.5, 0.5, alpha), ) self._draw_inner_dot(reference_location)
def gl_display(self): """ use gl calls to render at least: the published position of the reference better: show the detected postion even if not published """ if self.active or self.visualize: # Draw hand detection results for (x1, y1, x2, y2), fingertips in zip(self.hand_viz, self.finger_viz): pts = np.array( [[x1, y1], [x1, y2], [x2, y2], [x2, y1], [x1, y1]], np.int32 ) cygl_utils.draw_polyline( pts, thickness=3 * self.g_pool.gui_user_scale, color=cygl_utils.RGBA(0.0, 1.0, 0.0, 1.0), ) for tip in fingertips: if tip is not None: y, x = tip cygl_utils.draw_progress( (x, y), 0.0, 1.0, inner_radius=25 * self.g_pool.gui_user_scale, outer_radius=35 * self.g_pool.gui_user_scale, color=cygl_utils.RGBA(1.0, 1.0, 1.0, 1.0), sharpness=0.9, ) cygl_utils.draw_points( [(x, y)], size=10 * self.g_pool.gui_user_scale, color=cygl_utils.RGBA(1.0, 1.0, 1.0, 1.0), sharpness=0.9, )