本文整理汇总了Python中pyglui.cygl.utils.draw_points函数的典型用法代码示例。如果您正苦于以下问题:Python draw_points函数的具体用法?Python draw_points怎么用?Python draw_points使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_points函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: gl_display
def gl_display(self):
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
gluOrtho2D(
-self.h_pad, (self.frame_count) + self.h_pad, -self.v_pad, 1 + self.v_pad
) # ranging from 0 to cache_len-1 (horizontal) and 0 to 1 (vertical)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
if self.drag_mode:
color1 = (0.0, 0.8, 0.5, 0.5)
color2 = (0.0, 0.8, 0.5, 1.0)
else:
color1 = (0.25, 0.8, 0.8, 0.5)
color2 = (0.25, 0.8, 0.8, 1.0)
draw_polyline(verts=[(0, 0), (self.current_frame_index, 0)], color=RGBA(*color1))
draw_polyline(verts=[(self.current_frame_index, 0), (self.frame_count, 0)], color=RGBA(0.5, 0.5, 0.5, 0.5))
draw_points([(self.current_frame_index, 0)], color=RGBA(*color1), size=40)
draw_points([(self.current_frame_index, 0)], color=RGBA(*color2), size=10)
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
开发者ID:lloves,项目名称:pupil,代码行数:27,代码来源:seek_bar.py
示例2: gl_display
def gl_display(self):
"""
This is where we can draw to any gl surface
by default this is the main window, below we change that
"""
# active our window
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(self.window)
# start drawing things:
gl_utils.clear_gl_screen()
# set coordinate system to be between 0 and 1 of the extents of the window
gl_utils.make_coord_system_norm_based()
# draw the image
draw_gl_texture(self.img)
# make coordinte system identical to the img pixel coordinate system
gl_utils.make_coord_system_pixel_based(self.img.shape)
# draw some points on top of the image
# notice how these show up in our window but not in the main window
draw_points([(200, 400), (600, 400)], color=RGBA(0., 4., .8, .8), size=self.my_var)
draw_polyline([(200, 400), (600, 400)], color=RGBA(0., 4., .8, .8), thickness=3)
# since this is our own window we need to swap buffers in the plugin
glfwSwapBuffers(self.window)
# and finally reactive the main window
glfwMakeContextCurrent(active_window)
开发者ID:papr,项目名称:pupil-helpers,代码行数:29,代码来源:example_plugin.py
示例3: gl_display_in_window
def gl_display_in_window(self):
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(self._window)
clear_gl_screen()
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
p_window_size = glfwGetWindowSize(self._window)
r = p_window_size[0]/15.
# compensate for radius of marker
gl.glOrtho(-r,p_window_size[0]+r,p_window_size[1]+r,-r ,-1,1)
# Switch back to Model View Matrix
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
#hacky way of scaling and fitting in different window rations/sizes
grid = _make_grid()*min((p_window_size[0],p_window_size[1]*5.5/4.))
#center the pattern
grid -= np.mean(grid)
grid +=(p_window_size[0]/2-r,p_window_size[1]/2+r)
draw_points(grid,size=r,color=RGBA(0.,0.,0.,1),sharpness=0.95)
if self.clicks_to_close <5:
self.glfont.set_size(int(p_window_size[0]/30.))
self.glfont.draw_text(p_window_size[0]/2.,p_window_size[1]/4.,'Touch %s more times to close window.'%self.clicks_to_close)
glfwSwapBuffers(self._window)
glfwMakeContextCurrent(active_window)
开发者ID:DanielNoteboom,项目名称:Mobile_Capstone,代码行数:29,代码来源:camera_intrinsics_estimation.py
示例4: gl_display
def gl_display(self):
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
gluOrtho2D(-self.h_pad, (self.frame_count)+self.h_pad, -self.v_pad, 1+self.v_pad) # ranging from 0 to cache_len-1 (horizontal) and 0 to 1 (vertical)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
# if self.drag_mode:
# color1 = (0.,.8,.5,.5)
# color2 = (0.,.8,.5,1.)
# else:
color1 = (1,1,1,0.4)#(.25,.8,.8,.5)
color2 = (1,1,1,1.)#(.25,.8,.8,1.)
thickness = 10.
draw_polyline(verts=[(0,0),(self.current_frame_index,0)],
thickness=thickness,color=RGBA(*color1))
draw_polyline(verts=[(self.current_frame_index,0),(self.frame_count,0)],
thickness=thickness,color=RGBA(*color1))
if not self.drag_mode:
draw_points([(self.current_frame_index,0)],color=RGBA(*color1),size=30)
draw_points([(self.current_frame_index,0)],color=RGBA(*color2),size=20)
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
开发者ID:papr,项目名称:pupil,代码行数:29,代码来源:seek_bar.py
示例5: _draw_current_reference
def _draw_current_reference(self, current_reference):
with self._frame_coordinate_system:
cygl_utils.draw_points(
[current_reference.screen_pos],
size=35,
color=cygl_utils.RGBA(0, 0.5, 0.5, 0.7),
)
self._draw_inner_dot(current_reference)
开发者ID:pupil-labs,项目名称:pupil,代码行数:8,代码来源:reference_location_renderer.py
示例6: draw_pupil_data
def draw_pupil_data(self, key, width, height, scale):
right = self.cache[key]["right"]
left = self.cache[key]["left"]
with gl_utils.Coord_System(*self.cache[key]["xlim"], *self.cache[key]["ylim"]):
cygl_utils.draw_points(
right, size=2.0 * scale, color=COLOR_LEGEND_EYE_RIGHT
)
cygl_utils.draw_points(left, size=2.0 * scale, color=COLOR_LEGEND_EYE_LEFT)
开发者ID:pupil-labs,项目名称:pupil,代码行数:9,代码来源:pupil_producers.py
示例7: _draw_surface_corner_handles
def _draw_surface_corner_handles(self, surface):
img_corners = surface.map_from_surf(
self.norm_corners.copy(),
self.tracker.camera_model,
compensate_distortion=False,
)
pyglui_utils.draw_points(
img_corners, size=20, color=pyglui_utils.RGBA(*self.color_primary, 0.5)
)
开发者ID:pupil-labs,项目名称:pupil,代码行数:10,代码来源:gui.py
示例8: gl_display_in_window
def gl_display_in_window(self):
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(self._window)
clear_gl_screen()
hdpi_factor = glfwGetFramebufferSize(self._window)[0] / glfwGetWindowSize(self._window)[0]
r = 110 * self.marker_scale * hdpi_factor
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
p_window_size = glfwGetWindowSize(self._window)
gl.glOrtho(0, p_window_size[0], p_window_size[1], 0, -1, 1)
# Switch back to Model View Matrix
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
def map_value(value, in_range=(0, 1), out_range=(0, 1)):
ratio = (out_range[1] - out_range[0]) / (in_range[1] - in_range[0])
return (value - in_range[0]) * ratio + out_range[0]
pad = 0.6 * r
screen_pos = (
map_value(self.display_pos[0], out_range=(pad, p_window_size[0] - pad)),
map_value(self.display_pos[1], out_range=(p_window_size[1] - pad, pad)),
)
alpha = interp_fn(
self.screen_marker_state,
0.0,
1.0,
float(self.sample_duration + self.lead_in + self.lead_out),
float(self.lead_in),
float(self.sample_duration + self.lead_in),
)
draw_concentric_circles(screen_pos, r, 6, alpha)
# some feedback on the detection state
if self.detected and self.on_position:
draw_points([screen_pos], size=5, color=RGBA(0.0, 0.8, 0.0, alpha), sharpness=0.5)
else:
draw_points([screen_pos], size=5, color=RGBA(0.8, 0.0, 0.0, alpha), sharpness=0.5)
if self.clicks_to_close < 5:
self.glfont.set_size(int(p_window_size[0] / 30.0))
self.glfont.draw_text(
p_window_size[0] / 2.0,
p_window_size[1] / 4.0,
"Touch %s more times to cancel calibration." % self.clicks_to_close,
)
glfwSwapBuffers(self._window)
glfwMakeContextCurrent(active_window)
开发者ID:lloves,项目名称:pupil,代码行数:52,代码来源:screen_marker_calibration.py
示例9: draw_recent_pupil_positions
def draw_recent_pupil_positions(self):
try:
for gp in self.surface.gaze_history:
pyglui_utils.draw_points(
[gp["norm_pos"]],
color=pyglui_utils.RGBA(0.0, 0.8, 0.5, 0.8),
size=80,
)
except AttributeError:
# If gaze_history does not exist, we are in the Surface_Tracker_Offline.
# In this case gaze visualizations will be drawn directly onto the scene
# image and thus propagate to the surface crop automatically.
pass
开发者ID:pupil-labs,项目名称:pupil,代码行数:13,代码来源:gui.py
示例10: gl_display
def gl_display(self):
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glOrtho(-self.h_pad, (self.frame_count)+self.h_pad, -self.v_pad, 1+self.v_pad,-1,1) # ranging from 0 to cache_len-1 (horizontal) and 0 to 1 (vertical)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
color1 = RGBA(.1,.9,.2,.5)
color2 = RGBA(.1,.9,.9,.5)
if self.in_mark != 0 or self.out_mark != self.frame_count:
draw_polyline( [(self.in_mark,0),(self.out_mark,0)],color=color1,thickness=2)
draw_points([(self.in_mark,0),],color=color1,size=10)
draw_points([(self.out_mark,0),],color=color1,size=10)
if self.sections:
for s in self.sections:
if self.sections.index(s) != self.focus:
draw_polyline( [(s[0],0),(s[1],0)],color=RGBA(.1,.9,.9,.2),thickness=2)
for mark in s:
draw_points([(mark,0),],color=color2,size=5)
if self.mid_sections:
for m in self.mid_sections:
draw_points([(m,0),],color=RGBA(.1,.9,.9,.1),size=10)
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
开发者ID:cpicanco,项目名称:player_plugins,代码行数:34,代码来源:trim_marks_patch.py
示例11: _draw_surface_menu_buttons
def _draw_surface_menu_buttons(
self, surface, surface_edit_anchor, marker_edit_anchor
):
# Buttons
pyglui_utils.draw_points(
[marker_edit_anchor], color=pyglui_utils.RGBA(*self.color_primary)
)
if surface in self._edit_surf_markers:
pyglui_utils.draw_points(
[marker_edit_anchor],
size=13,
color=pyglui_utils.RGBA(*self.color_secondary),
)
pyglui_utils.draw_points(
[surface_edit_anchor], color=pyglui_utils.RGBA(*self.color_primary)
)
if surface in self._edit_surf_corners:
pyglui_utils.draw_points(
[surface_edit_anchor],
size=13,
color=pyglui_utils.RGBA(*self.color_secondary),
)
# Text
self._draw_text(
(surface_edit_anchor[0] + 15, surface_edit_anchor[1] + 6),
"edit surface",
self.color_secondary,
)
self._draw_text(
(marker_edit_anchor[0] + 15, marker_edit_anchor[1] + 6),
"add/remove markers",
self.color_secondary,
)
开发者ID:pupil-labs,项目名称:pupil,代码行数:33,代码来源:gui.py
示例12: gl_display_in_window
def gl_display_in_window(self):
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(self._window)
clear_gl_screen()
# Set Matrix unsing gluOrtho2D to include padding for the marker of radius r
#
############################
# r #
# 0,0##################w,h #
# # # #
# # # #
#r# #r#
# # # #
# # # #
# 0,h##################w,h #
# r #
############################
hdpi_factor = glfwGetFramebufferSize(self._window)[0]/glfwGetWindowSize(self._window)[0]
r = 110*self.marker_scale * hdpi_factor
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
p_window_size = glfwGetWindowSize(self._window)
# compensate for radius of marker
gl.glOrtho(-r*.6,p_window_size[0]+r*.6,p_window_size[1]+r*.7,-r*.7 ,-1,1)
# Switch back to Model View Matrix
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
screen_pos = denormalize(self.display_pos,p_window_size,flip_y=True)
alpha = interp_fn(self.screen_marker_state,0.,1.,float(self.sample_duration+self.lead_in+self.lead_out),float(self.lead_in),float(self.sample_duration+self.lead_in))
draw_concentric_circles(screen_pos,r,6,alpha)
#some feedback on the detection state
if self.detected and self.on_position:
draw_points([screen_pos],size=5,color=RGBA(0.,1.,0.,alpha),sharpness=0.95)
else:
draw_points([screen_pos],size=5,color=RGBA(1.,0.,0.,alpha),sharpness=0.95)
if self.clicks_to_close <5:
self.glfont.set_size(int(p_window_size[0]/30.))
self.glfont.draw_text(p_window_size[0]/2.,p_window_size[1]/4.,'Touch %s more times to cancel calibration.'%self.clicks_to_close)
glfwSwapBuffers(self._window)
glfwMakeContextCurrent(active_window)
开发者ID:cpicanco,项目名称:pupil,代码行数:49,代码来源:screen_marker_calibration.py
示例13: gl_display_in_window
def gl_display_in_window(self):
active_window = glfwGetCurrentContext()
if glfwWindowShouldClose(self._window):
self.close_window()
return
glfwMakeContextCurrent(self._window)
clear_gl_screen()
gl.glColor3f(.80, .80, .8)
self.draw_rect(0, 0, 2000, 2000)
self.draw_markers()
hdpi_factor = glfwGetFramebufferSize(self._window)[0]/glfwGetWindowSize(self._window)[0]
r = 110*self.marker_scale * hdpi_factor
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
p_window_size = glfwGetFramebufferSize(self._window)
gl.glOrtho(0, p_window_size[0], p_window_size[1], 0, -1, 1)
# Switch back to Model View Matrix
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
def map_value(value,in_range=(0,1),out_range=(0,1)):
ratio = (out_range[1]-out_range[0])/(in_range[1]-in_range[0])
return (value-in_range[0])*ratio+out_range[0]
#pad = 0.1*1920
pad = .7*r
screen_pos = map_value(self.display_pos[0],out_range=(pad,p_window_size[0]-pad)),map_value(self.display_pos[1],out_range=(p_window_size[1]-pad,pad))
alpha = interp_fn(self.screen_marker_state,0.,1.,float(self.sample_duration+self.lead_in+self.lead_out),float(self.lead_in),float(self.sample_duration+self.lead_in))
if self.screen_marker_state < self.sample_duration+self.lead_in+self.lead_out:
draw_concentric_circles(screen_pos,r,6,alpha)
#some feedback on the detection state
if self.detected and self.on_position:
draw_points([screen_pos],size=10*self.marker_scale,color=RGBA(0.,.8,0.,alpha),sharpness=0.5)
elif self.screen_marker_state < self.sample_duration+self.lead_in+self.lead_out:
draw_points([screen_pos],size=10*self.marker_scale,color=RGBA(0.8,0.,0.,alpha),sharpness=0.5)
#if self.clicks_to_close <5:
# self.glfont.set_size(int(p_window_size[0]/30.))
# self.glfont.draw_text(p_window_size[0]/2.,p_window_size[1]/4.,'Touch {} more times to cancel calibration.'.format(self.clicks_to_close))
glfwSwapBuffers(self._window)
glfwMakeContextCurrent(active_window)
开发者ID:samtuhka,项目名称:pupil,代码行数:47,代码来源:screen_marker_calibration.py
示例14: gl_draw_frame
def gl_draw_frame(self,img_size,color = (1.0,0.2,0.6,1.0),highlight=False,surface_mode=False,marker_mode=False):
"""
draw surface and markers
"""
if self.detected:
r,g,b,a = color
frame = np.array([[[0,0],[1,0],[1,1],[0,1],[0,0]]],dtype=np.float32)
hat = np.array([[[.3,.7],[.7,.7],[.5,.9],[.3,.7]]],dtype=np.float32)
hat = cv2.perspectiveTransform(hat,self.m_to_screen)
frame = cv2.perspectiveTransform(frame,self.m_to_screen)
alpha = min(1,self.build_up_status/self.required_build_up)
if highlight:
draw_polyline_norm(frame.reshape((5,2)),1,RGBA(r,g,b,a*.1),line_type=GL_POLYGON)
draw_polyline_norm(frame.reshape((5,2)),1,RGBA(r,g,b,a*alpha))
draw_polyline_norm(hat.reshape((4,2)),1,RGBA(r,g,b,a*alpha))
text_anchor = frame.reshape((5,-1))[2]
text_anchor[1] = 1-text_anchor[1]
text_anchor *=img_size[1],img_size[0]
text_anchor = text_anchor[0],text_anchor[1]-75
surface_edit_anchor = text_anchor[0],text_anchor[1]+25
marker_edit_anchor = text_anchor[0],text_anchor[1]+50
if self.defined:
if marker_mode:
draw_points([marker_edit_anchor],color=RGBA(0,.8,.7))
else:
draw_points([marker_edit_anchor])
if surface_mode:
draw_points([surface_edit_anchor],color=RGBA(0,.8,.7))
else:
draw_points([surface_edit_anchor])
self.glfont.set_blur(3.9)
self.glfont.set_color_float((0,0,0,.8))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'edit surface')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,'add/remove markers')
self.glfont.set_blur(0.0)
self.glfont.set_color_float((0.1,8.,8.,.9))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'edit surface')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,'add/remove markers')
else:
progress = (self.build_up_status/float(self.required_build_up))*100
progress_text = '%.0f%%'%progress
self.glfont.set_blur(3.9)
self.glfont.set_color_float((0,0,0,.8))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'Learning affiliated markers...')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,progress_text)
self.glfont.set_blur(0.0)
self.glfont.set_color_float((0.1,8.,8.,.9))
self.glfont.draw_text(text_anchor[0]+15,text_anchor[1]+6,self.marker_status())
self.glfont.draw_text(surface_edit_anchor[0]+15,surface_edit_anchor[1]+6,'Learning affiliated markers...')
self.glfont.draw_text(marker_edit_anchor[0]+15,marker_edit_anchor[1]+6,progress_text)
开发者ID:papr,项目名称:pupil,代码行数:54,代码来源:reference_surface.py
示例15: gl_display
def gl_display(self):
"""
Display marker and surface info inside world screen
"""
if self.mode == "Show Markers and Surfaces":
for m in self.markers:
hat = np.array([[[0, 0], [0, 1], [0.5, 1.3], [1, 1], [1, 0], [0, 0]]], dtype=np.float32)
hat = cv2.perspectiveTransform(hat, m_marker_to_screen(m))
if m["perimeter"] >= self.min_marker_perimeter:
draw_polyline(hat.reshape((6, 2)), color=RGBA(0.1, 1.0, 1.0, 0.5))
draw_polyline(hat.reshape((6, 2)), color=RGBA(0.1, 1.0, 1.0, 0.3), line_type=GL_POLYGON)
else:
draw_polyline(hat.reshape((6, 2)), color=RGBA(0.1, 1.0, 1.0, 0.5))
for s in self.surfaces:
if s not in self.edit_surfaces and s is not self.marker_edit_surface:
s.gl_draw_frame(self.img_shape)
for s in self.edit_surfaces:
s.gl_draw_frame(self.img_shape, highlight=True, surface_mode=True)
s.gl_draw_corners()
if self.marker_edit_surface:
inc = []
exc = []
for m in self.markers:
if m["perimeter"] >= self.min_marker_perimeter:
if self.marker_edit_surface.markers.has_key(m["id"]):
inc.append(m["centroid"])
else:
exc.append(m["centroid"])
draw_points(exc, size=20, color=RGBA(1.0, 0.5, 0.5, 0.8))
draw_points(inc, size=20, color=RGBA(0.5, 1.0, 0.5, 0.8))
self.marker_edit_surface.gl_draw_frame(
self.img_shape, color=(0.0, 0.9, 0.6, 1.0), highlight=True, marker_mode=True
)
for s in self.surfaces:
if self.locate_3d:
s.gl_display_in_window_3d(self.g_pool.image_tex, self.camera_calibration)
else:
s.gl_display_in_window(self.g_pool.image_tex)
开发者ID:caomw,项目名称:pupil,代码行数:42,代码来源:surface_tracker.py
示例16: _draw_marker_toggles
def _draw_marker_toggles(self, surface):
active_markers = []
inactive_markers = []
for marker in self.tracker.markers:
if marker.perimeter < self.tracker.marker_min_perimeter:
continue
centroid = np.mean(marker.verts_px, axis=0)
centroid = (centroid[0, 0], centroid[0, 1])
if marker.id in surface.registered_markers_dist.keys():
active_markers.append(centroid)
else:
inactive_markers.append(centroid)
pyglui_utils.draw_points(
inactive_markers, size=20, color=pyglui_utils.RGBA(*self.color_primary, 0.8)
)
pyglui_utils.draw_points(
active_markers, size=20, color=pyglui_utils.RGBA(*self.color_tertiary, 0.8)
)
开发者ID:pupil-labs,项目名称:pupil,代码行数:20,代码来源:gui.py
示例17: gl_display
def gl_display(self):
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glOrtho(-self.h_pad, (self.frame_count)+self.h_pad, -self.v_pad, 1+self.v_pad,-1,1) # ranging from 0 to cache_len-1 (horizontal) and 0 to 1 (vertical)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
color1 = RGBA(.1,.9,.2,1.)
color2 = RGBA(.1,.9,.2,1.)
if self.in_mark != 0 or self.out_mark != self.frame_count:
draw_polyline( [(self.in_mark,0),(self.out_mark,0)],color=color1,thickness=20.)
draw_points([(self.in_mark,0),],color=color2,size=20)
draw_points([(self.out_mark,0),],color=color2,size=20)
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
开发者ID:neuroidss,项目名称:pupil,代码行数:22,代码来源:trim_marks.py
示例18: gl_display_in_window
def gl_display_in_window(self):
active_window = glfwGetCurrentContext()
if glfwWindowShouldClose(self._window):
self.close_window()
return
glfwMakeContextCurrent(self._window)
clear_gl_screen()
hdpi_factor = glfwGetFramebufferSize(self._window)[0]/glfwGetWindowSize(self._window)[0]
r = self.marker_scale * hdpi_factor
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
p_window_size = glfwGetFramebufferSize(self._window)
gl.glOrtho(0, p_window_size[0], p_window_size[1], 0, -1, 1)
# Switch back to Model View Matrix
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
def map_value(value,in_range=(0,1),out_range=(0,1)):
ratio = (out_range[1]-out_range[0])/(in_range[1]-in_range[0])
return (value-in_range[0])*ratio+out_range[0]
pad = 90 * r
screen_pos = map_value(self.display_pos[0],out_range=(pad,p_window_size[0]-pad)),map_value(self.display_pos[1],out_range=(p_window_size[1]-pad,pad))
alpha = interp_fn(self.screen_marker_state,0.,1.,float(self.sample_duration+self.lead_in+self.lead_out),float(self.lead_in),float(self.sample_duration+self.lead_in))
r2 = 2 * r
draw_points([screen_pos], size=60*r2, color=RGBA(0., 0., 0., alpha), sharpness=0.9)
draw_points([screen_pos], size=38*r2, color=RGBA(1., 1., 1., alpha), sharpness=0.8)
draw_points([screen_pos], size=19*r2, color=RGBA(0., 0., 0., alpha), sharpness=0.55)
# some feedback on the detection state and button pressing
if self.detected and self.on_position and self.space_key_was_pressed:
color = RGBA(.8,.8,0., alpha)
else:
if self.detected:
color = RGBA(0.,.8,0., alpha)
else:
color = RGBA(.8,0.,0., alpha)
draw_points([screen_pos],size=3*r2,color=color,sharpness=0.5)
if self.clicks_to_close <5:
self.glfont.set_size(int(p_window_size[0]/30.))
self.glfont.draw_text(p_window_size[0]/2.,p_window_size[1]/4.,'Touch {} more times to cancel {}.'.format(self.clicks_to_close, self.mode_pretty))
glfwSwapBuffers(self._window)
glfwMakeContextCurrent(active_window)
开发者ID:cpicanco,项目名称:capture_plugins,代码行数:49,代码来源:participant_driven_calibration.py
示例19: gl_display
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,
)
开发者ID:pupil-labs,项目名称:pupil,代码行数:38,代码来源:fingertip_calibration.py
示例20: gl_display
def gl_display(self):
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
gluOrtho2D(-self.h_pad, (self.frame_count)+self.h_pad, -self.v_pad, 1+self.v_pad) # ranging from 0 to cache_len-1 (horizontal) and 0 to 1 (vertical)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
# custom events
for e in self.custom_events:
draw_polyline([(e,.06),(e,.005)], color = RGBA(.8, .8, .8, .8))
size = len(self.custom_events)
if size > 1:
for i, e in enumerate(self.custom_events):
draw_points([(e, .03)], size = 5, color = RGBA(.1, .5, .5, 1.))
i = 0
while True:
if i == 0:
draw_polyline([(self.custom_events[i],.03),(self.custom_events[i+1],0.03)], color = RGBA(.8, .8, .8, .8))
elif (i > 0) and (i < (size-1)):
draw_polyline([(self.custom_events[i] +1,.03),(self.custom_events[i+1],0.03)], color = RGBA(.8, .8, .8, .8))
if 'chain' in self.mode:
i += 1
elif 'in out pairs' in self.mode:
i += 2
if i > (size-1):
break
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
开发者ID:cpicanco,项目名称:player_plugins,代码行数:37,代码来源:segmentation.py
注:本文中的pyglui.cygl.utils.draw_points函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论