Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for char_ in unused_elements.chars:
for p in g_pool.plugins:
p.on_char(char_)
# present frames at appropriate speed
cap.wait(frame)
glfw.glfwSwapBuffers(main_window)
glfw.glfwPollEvents()
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['min_data_confidence'] = g_pool.min_data_confidence
session_settings['gui_scale'] = g_pool.gui_user_scale
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['window_size'] = glfw.glfwGetWindowSize(main_window)
session_settings['window_position'] = glfw.glfwGetWindowPos(main_window)
session_settings['version'] = str(g_pool.version)
session_settings.close()
# de-init all running plugins
for p in g_pool.plugins:
p.alive = False
g_pool.plugins.clean()
cap.cleanup()
g_pool.gui.terminate()
glfw.glfwDestroyWindow(main_window)
logger.info("Process shutting down.")
ipc_pub.notify({'subject': 'player_process.stopped'})
def __init__(self, g_pool, alpha=0.6, eye_scale_factor=.5, show_ellipses=True,
eye0_config={'pos': (640, 10)}, eye1_config={'pos': (10, 10)}):
super().__init__(g_pool)
self.order = .6
self.menu = None
self.alpha = alpha
self.eye_scale_factor = eye_scale_factor
self.show_ellipses = show_ellipses
self.move_around = False
if self.g_pool.app != 'exporter':
window = g_pool.main_window
try:
self.hdpi_factor = float(glfwGetFramebufferSize(window)[0] / glfwGetWindowSize(window)[0])
except ZeroDivisionError:
self.hdpi_factor = 1.
else:
self.hdpi_factor = 1.
self.eye0 = Eye_Wrapper(g_pool, 0, hdpi_fac=self.hdpi_factor, **eye0_config)
self.eye1 = Eye_Wrapper(g_pool, 1, hdpi_fac=self.hdpi_factor, **eye1_config)
self.eye0.initliaze_video(g_pool.rec_dir, g_pool.timestamps)
self.eye1.initliaze_video(g_pool.rec_dir, g_pool.timestamps)
def toggle_depth_display():
def on_depth_mouse_button(window, button, action, mods):
if button == glfw.GLFW_MOUSE_BUTTON_LEFT and action == glfw.GLFW_PRESS:
self.mouse_drag = True
if (
button == glfw.GLFW_MOUSE_BUTTON_LEFT
and action == glfw.GLFW_RELEASE
):
self.mouse_drag = False
if self.depth_window is None:
self.pitch = 0
self.yaw = 0
win_size = glfw.glfwGetWindowSize(self.g_pool.main_window)
self.depth_window = glfw.glfwCreateWindow(
win_size[0], win_size[1], "3D Point Cloud"
)
glfw.glfwSetMouseButtonCallback(
self.depth_window, on_depth_mouse_button
)
active_window = glfw.glfwGetCurrentContext()
glfw.glfwMakeContextCurrent(self.depth_window)
gl_utils.basic_gl_setup()
gl_utils.make_coord_system_norm_based()
# refresh speed settings
glfw.glfwSwapInterval(0)
glfw.glfwMakeContextCurrent(active_window)
glfw.glfwSetWindowPos(window, window_pos[0], window_pos[1])
glfw.glfwSetDropCallback(window, on_drop)
glfont = fontstash.Context()
glfont.add_font('roboto', get_roboto_font_path())
glfont.set_align_string(v_align="center", h_align="middle")
glfont.set_color_float((0.2, 0.2, 0.2, 0.9))
gl_utils.basic_gl_setup()
glClearColor(0.5, .5, 0.5, 0.0)
text = 'Drop a recording directory onto this window.'
tip = '(Tip: You can drop a recording directory onto the app icon.)'
# text = "Please supply a Pupil recording directory as first arg when calling Pupil Player."
while not glfw.glfwWindowShouldClose(window):
fb_size = glfw.glfwGetFramebufferSize(window)
hdpi_factor = float(fb_size[0] / glfw.glfwGetWindowSize(window)[0])
gl_utils.adjust_gl_view(*fb_size)
if rec_dir:
if is_pupil_rec_dir(rec_dir):
logger.info("Starting new session with '{}'".format(rec_dir))
text = "Updating recording format."
tip = "This may take a while!"
else:
logger.error("'{}' is not a valid pupil recording".format(rec_dir))
tip = "Oops! That was not a valid recording."
rec_dir = None
gl_utils.clear_gl_screen()
glfont.set_blur(10.5)
glfont.set_color_float((0.0, 0.0, 0.0, 1.))
glfont.set_size(w/25.*hdpi_factor)
def on_button(window,button, action, mods):
if g_pool.display_mode == 'roi':
if action == glfw.GLFW_RELEASE and g_pool.u_r.active_edit_pt:
g_pool.u_r.active_edit_pt = False
return # if the roi interacts we dont what the gui to interact as well
elif action == glfw.GLFW_PRESS:
pos = glfw.glfwGetCursorPos(window)
pos = normalize(pos,glfw.glfwGetWindowSize(main_window))
if g_pool.flip:
pos = 1-pos[0],1-pos[1]
pos = denormalize(pos,(frame.width,frame.height)) # Position in img pixels
if g_pool.u_r.mouse_over_edit_pt(pos,g_pool.u_r.handle_size+40,g_pool.u_r.handle_size+40):
return # if the roi interacts we dont what the gui to interact as well
g_pool.gui.update_button(button,action,mods)
def on_pos(window, x, y):
hdpi_factor = glfw.glfwGetFramebufferSize(
window)[0] / glfw.glfwGetWindowSize(window)[0]
g_pool.gui.update_mouse(x * hdpi_factor, y * hdpi_factor)
if g_pool.u_r.active_edit_pt:
pos = normalize((x, y), glfw.glfwGetWindowSize(main_window))
if g_pool.flip:
pos = 1-pos[0],1-pos[1]
pos = denormalize(pos,g_pool.capture.frame_size )
g_pool.u_r.move_vertex(g_pool.u_r.active_pt_idx,pos)
)
)
self.menu.append(ui.Button("Add section", self.append_section))
# set to minimum height
self.timeline = ui.Timeline(
"Calibration Sections", self.draw_sections, self.draw_labels, 1
)
self.g_pool.user_timelines.append(self.timeline)
for sec in self.sections:
self.append_section_menu(sec)
self.on_window_resize(
glfw.glfwGetCurrentContext(),
*glfw.glfwGetWindowSize(glfw.glfwGetCurrentContext())
)