def draw_sections(self, width, height, scale):
        t0, t1 = self.g_pool.timestamps[0], self.g_pool.timestamps[-1]
        pixel_to_time_fac = height / (t1 - t0)
        with gl_utils.Coord_System(t0, t1, height, 0):
            gl.glTranslatef(0, 0.001 + scale * self.timeline_line_height / 2, 0)
            for s in self.sections:
                cal_slc = slice(*s['calibration_range'])
                map_slc = slice(*s['mapping_range'])
                cal_ts = self.g_pool.timestamps[cal_slc]
                map_ts = self.g_pool.timestamps[map_slc]

                color = cygl_utils.RGBA(*s['color'][:3], 1.)
                if len(cal_ts):
                    cygl_utils.draw_rounded_rect((cal_ts[0], -4 * scale),
                                      (cal_ts[-1] - cal_ts[0], 8 * scale),
                                      corner_radius=0,
                                      color=color,
                                      sharpness=1.)
                if len(map_ts):
                    cygl_utils.draw_rounded_rect((map_ts[0], -scale),
                                      (map_ts[-1] - map_ts[0], 2 * scale),
                                      corner_radius=0,
                                      color=color,
                                      sharpness=1.)

                color = cygl_utils.RGBA(1., 1., 1., .5)
                if s['calibration_method'] == "natural_features":
                    cygl_utils.draw_x([(m['timestamp'], 0) for m in self.manual_ref_positions],
                           height=12 * scale, width=3 * pixel_to_time_fac / scale, thickness=scale, color=color)
                else:
                    cygl_utils.draw_bars([(m['timestamp'], 0) for m in self.circle_marker_positions],
                              height=12 * scale, thickness=scale, color=color)

                gl.glTranslatef(0, scale * self.timeline_line_height, 0)
Beispiel #2
0
    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
        """

        # Draw rectangle preview with threshold color
        if self.world_size:
            offset = self.world_size[0] / 130.0
            ratio = self.world_size[1] / self.world_size[0]

            rect_size = None
            if ratio == 0.75:
                rect_size = [(self.world_size[0] / 20.0),
                             self.world_size[0] / 20.0 * 1.3]
            else:
                rect_size = [(self.world_size[0] / 20.0),
                             self.world_size[0] / 20.0 * 1.0]

            rect_color = colorsys.hsv_to_rgb(self.color_h / 360,
                                             self.color_s / 100,
                                             self.color_v / 100)
            draw_rounded_rect(
                [offset, self.world_size[1] - rect_size[1] - offset],
                size=rect_size,
                corner_radius=offset / 2,
                color=RGBA(rect_color[0], rect_color[1], rect_color[2], 1.))

        if self.active:

            # Draw contour of hand
            if self.show_contour:
                con = [(c[0][0], c[0][1]) for c in self.contour]
                if len(con) > 2:
                    con.append(con[0])
                    draw_polyline(con,
                                  color=RGBA(0., 1., 0., .7),
                                  thickness=5.0)

            # Draw all detected fingertips
            if len(self.markers) == 1:
                marker_norm = normalize(
                    self.markers[0], (self.world_size[0], self.world_size[1]),
                    flip_y=True)
                draw_points_norm([marker_norm],
                                 size=30,
                                 color=RGBA(0., 1., 1., .5))
            else:
                for mark in self.markers:
                    marker_norm = normalize(
                        mark, (self.world_size[0], self.world_size[1]),
                        flip_y=True)
                    draw_points_norm([marker_norm],
                                     size=30,
                                     color=RGBA(0., 0., 1., .5))
Beispiel #3
0
 def _draw_range(self, from_, to, scale, color_rgba, height, offset):
     gl.glTranslatef(0, offset * scale, 0)
     color = cygl_utils.RGBA(*color_rgba)
     cygl_utils.draw_rounded_rect(
         (from_, -height / 2 * scale),
         (to - from_, height * scale),
         corner_radius=0,
         color=color,
         sharpness=1.0,
     )
     gl.glTranslatef(0, -offset * scale, 0)
Beispiel #4
0
 def _draw_range(self, from_, to, scale, color_rgba, height, offset):
     gl.glTranslatef(0, offset * scale, 0)
     color = cygl_utils.RGBA(*color_rgba)
     cygl_utils.draw_rounded_rect(
         (from_, -height / 2 * scale),
         (to - from_, height * scale),
         corner_radius=0,
         color=color,
         sharpness=1.0,
     )
     gl.glTranslatef(0, -offset * scale, 0)
Beispiel #5
0
 def gl_display(self):
     if self.result != None and self.fixation_flag == True:
         draw_rounded_rect(self.result['corner'], self.result['size'], 0, color=RGBA(.200, .200, .200, 0.4))