本文整理汇总了Python中pyglui.graph.pop_view函数的典型用法代码示例。如果您正苦于以下问题:Python pop_view函数的具体用法?Python pop_view怎么用?Python pop_view使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pop_view函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: session
#.........这里部分代码省略.........
pupil_graph.label = "Confidence: %0.2f"
while not glfwWindowShouldClose(main_window):
#grab new frame
if g_pool.play or g_pool.new_seek:
g_pool.new_seek = False
try:
new_frame = cap.get_frame_nowait()
except EndofVideoFileError:
#end of video logic: pause at last frame.
g_pool.play=False
update_graph = True
else:
update_graph = False
frame = new_frame.copy()
events = {}
#report time between now and the last loop interation
events['dt'] = get_dt()
#new positons we make a deepcopy just like the image is a copy.
events['gaze_positions'] = deepcopy(g_pool.gaze_positions_by_frame[frame.index])
events['pupil_positions'] = deepcopy(g_pool.pupil_positions_by_frame[frame.index])
if update_graph:
#update performace graphs
for p in events['pupil_positions']:
pupil_graph.add(p['confidence'])
t = new_frame.timestamp
if ts != t:
dt,ts = t-ts,t
fps_graph.add(1./dt)
g_pool.play_button.status_text = str(frame.index)
#always update the CPU graph
cpu_graph.update()
# publish delayed notifiactions when their time has come.
for n in g_pool.delayed_notifications.values():
if n['_notify_time_'] < time():
del n['_notify_time_']
del g_pool.delayed_notifications[n['subject']]
g_pool.notifications.append(n)
# notify each plugin if there are new notifactions:
while g_pool.notifications:
n = g_pool.notifications.pop(0)
for p in g_pool.plugins:
p.on_notify(n)
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame,events)
#check if a plugin need to be destroyed
g_pool.plugins.clean()
# render camera image
glfwMakeContextCurrent(main_window)
make_coord_system_norm_based()
g_pool.image_tex.update_from_frame(frame)
g_pool.image_tex.draw()
make_coord_system_pixel_based(frame.img.shape)
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil_graph.draw()
graph.pop_view()
g_pool.gui.update()
#present frames at appropriate speed
cap.wait(frame)
glfwSwapBuffers(main_window)
glfwPollEvents()
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['window_size'] = glfwGetWindowSize(main_window)
session_settings['window_position'] = glfwGetWindowPos(main_window)
session_settings['version'] = 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.close()
g_pool.gui.terminate()
glfwDestroyWindow(main_window)
示例2: eye
#.........这里部分代码省略.........
timestamps.append(frame.timestamp)
# pupil ellipse detection
result = g_pool.pupil_detector.detect(frame, g_pool.u_r, g_pool.display_mode == 'algorithm')
result['id'] = eye_id
# stream the result
g_pool.pupil_queue.put(result)
# GL drawing
if window_should_update():
if not g_pool.iconified:
glfw.glfwMakeContextCurrent(main_window)
clear_gl_screen()
# switch to work in normalized coordinate space
if g_pool.display_mode == 'algorithm':
g_pool.image_tex.update_from_ndarray(frame.img)
elif g_pool.display_mode in ('camera_image','roi'):
g_pool.image_tex.update_from_ndarray(frame.gray)
else:
pass
make_coord_system_norm_based(g_pool.flip)
g_pool.image_tex.draw()
window_size = glfw.glfwGetWindowSize(main_window)
make_coord_system_pixel_based((frame.height,frame.width,3),g_pool.flip)
if result['method'] == '3d c++':
eye_ball = result['projected_sphere']
try:
pts = cv2.ellipse2Poly( (int(eye_ball['center'][0]),int(eye_ball['center'][1])),
(int(eye_ball['axes'][0]/2),int(eye_ball['axes'][1]/2)),
int(eye_ball['angle']),0,360,8)
except ValueError as e:
pass
else:
draw_polyline(pts,2,RGBA(0.,.9,.1,result['model_confidence']) )
if result['confidence'] >0:
if result.has_key('ellipse'):
pts = cv2.ellipse2Poly( (int(result['ellipse']['center'][0]),int(result['ellipse']['center'][1])),
(int(result['ellipse']['axes'][0]/2),int(result['ellipse']['axes'][1]/2)),
int(result['ellipse']['angle']),0,360,15)
confidence = result['confidence'] * 0.7 #scale it a little
draw_polyline(pts,1,RGBA(1.,0,0,confidence))
draw_points([result['ellipse']['center']],size=20,color=RGBA(1.,0.,0.,confidence),sharpness=1.)
# render graphs
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
graph.pop_view()
# render GUI
g_pool.gui.update()
#render the ROI
if g_pool.display_mode == 'roi':
g_pool.u_r.draw(g_pool.gui.scale)
#update screen
glfw.glfwSwapBuffers(main_window)
glfw.glfwPollEvents()
g_pool.pupil_detector.visualize() #detector decides if we visualize or not
# END while running
# in case eye recording was still runnnig: Save&close
if writer:
logger.info("Done recording eye.")
writer = None
np.save(timestamps_path,np.asarray(timestamps))
glfw.glfwRestoreWindow(main_window) #need to do this for windows os
# save session persistent settings
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['roi'] = g_pool.u_r.get()
session_settings['flip'] = g_pool.flip
session_settings['display_mode'] = g_pool.display_mode
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['capture_settings'] = g_pool.capture.settings
session_settings['window_size'] = glfw.glfwGetWindowSize(main_window)
session_settings['window_position'] = glfw.glfwGetWindowPos(main_window)
session_settings['version'] = g_pool.version
session_settings['last_pupil_detector'] = g_pool.pupil_detector.__class__.__name__
session_settings['pupil_detector_settings'] = g_pool.pupil_detector.get_settings()
session_settings.close()
g_pool.pupil_detector.cleanup()
g_pool.gui.terminate()
glfw.glfwDestroyWindow(main_window)
glfw.glfwTerminate()
cap.close()
logger.debug("Process done")
示例3: world
#.........这里部分代码省略.........
t = frame.timestamp
dt,ts = t-ts,t
try:
fps_graph.add(1./dt)
except ZeroDivisionError:
pass
cpu_graph.update()
#a dictionary that allows plugins to post and read events
events = {}
#report time between now and the last loop interation
events['dt'] = get_dt()
#receive and map pupil positions
recent_pupil_positions = []
while not g_pool.pupil_queue.empty():
p = g_pool.pupil_queue.get()
recent_pupil_positions.append(p)
pupil_graph.add(p['confidence'])
events['pupil_positions'] = recent_pupil_positions
# publish delayed notifiactions when their time has come.
for n in g_pool.delayed_notifications.values():
if n['_notify_time_'] < time():
del n['_notify_time_']
del g_pool.delayed_notifications[n['subject']]
g_pool.notifications.append(n)
# notify each plugin if there are new notifications:
while g_pool.notifications:
n = g_pool.notifications.pop(0)
for p in g_pool.plugins:
p.on_notify(n)
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame,events)
#check if a plugin need to be destroyed
g_pool.plugins.clean()
# render camera image
glfw.glfwMakeContextCurrent(main_window)
if g_pool.iconified:
pass
else:
g_pool.image_tex.update_from_frame(frame)
make_coord_system_norm_based()
g_pool.image_tex.draw()
make_coord_system_pixel_based((frame.height,frame.width,3))
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
if not g_pool.iconified:
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil_graph.draw()
graph.pop_view()
g_pool.gui.update()
glfw.glfwSwapBuffers(main_window)
glfw.glfwPollEvents()
glfw.glfwRestoreWindow(main_window) #need to do this for windows os
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['pupil_confidence_threshold'] = g_pool.pupil_confidence_threshold
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['capture_settings'] = g_pool.capture.settings
session_settings['window_size'] = glfw.glfwGetWindowSize(main_window)
session_settings['window_position'] = glfw.glfwGetWindowPos(main_window)
session_settings['version'] = g_pool.version
session_settings['eye0_process_alive'] = eyes_are_alive[0].value
session_settings['eye1_process_alive'] = eyes_are_alive[1].value
session_settings['detection_mapping_mode'] = g_pool.detection_mapping_mode
session_settings['audio_mode'] = audio.audio_mode
session_settings.close()
# de-init all running plugins
for p in g_pool.plugins:
p.alive = False
g_pool.plugins.clean()
g_pool.gui.terminate()
glfw.glfwDestroyWindow(main_window)
glfw.glfwTerminate()
g_pool.capture.close()
#shut down eye processes:
stop_eye_process(0,blocking = True)
stop_eye_process(1,blocking = True)
#shut down laucher
launcher_pipe.send("Exit")
logger.info("Process Shutting down.")
示例4: world
#.........这里部分代码省略.........
# Event loop
while not g_pool.quit.value:
# Get an image from the grabber
try:
frame = cap.get_frame()
except CameraCaptureError:
logger.error("Capture from camera failed. Stopping.")
break
except EndofVideoFileError:
logger.warning("Video file is done. Stopping")
break
#update performace graphs
t = frame.timestamp
dt,ts = t-ts,t
try:
fps_graph.add(1./dt)
except ZeroDivisionError:
pass
cpu_graph.update()
#a dictionary that allows plugins to post and read events
events = {}
#report time between now and the last loop interation
events['dt'] = get_dt()
#receive and map pupil positions
recent_pupil_positions = []
while not g_pool.pupil_queue.empty():
p = g_pool.pupil_queue.get()
recent_pupil_positions.append(p)
pupil_graph.add(p['confidence'])
events['pupil_positions'] = recent_pupil_positions
# notify each plugin if there are new notifactions:
while g_pool.notifications:
n = g_pool.notifications.pop(0)
for p in g_pool.plugins:
p.on_notify(n)
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame,events)
#check if a plugin need to be destroyed
g_pool.plugins.clean()
# render camera image
glfwMakeContextCurrent(main_window)
if g_pool.iconified:
pass
elif g_pool.update_textures == 2:
update_named_texture(g_pool.image_tex,frame.img)
elif g_pool.update_textures == 1:
update_named_texture(g_pool.image_tex,frame.gray)
make_coord_system_norm_based()
draw_named_texture(g_pool.image_tex)
make_coord_system_pixel_based((frame.height,frame.width,3))
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
if not g_pool.iconified:
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil_graph.draw()
graph.pop_view()
g_pool.gui.update()
glfwSwapBuffers(main_window)
glfwPollEvents()
glfwRestoreWindow(main_window) #need to do this for windows os
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['pupil_confidence_threshold'] = g_pool.pupil_confidence_threshold
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['capture_settings'] = g_pool.capture.settings
session_settings['window_size'] = glfwGetWindowSize(main_window)
session_settings['window_position'] = glfwGetWindowPos(main_window)
session_settings['update_textures'] = g_pool.update_textures
session_settings['version'] = g_pool.version
session_settings.close()
# de-init all running plugins
for p in g_pool.plugins:
p.alive = False
g_pool.plugins.clean()
g_pool.gui.terminate()
glfwDestroyWindow(main_window)
glfwTerminate()
cap.close()
logger.debug("Process done")
示例5: world
#.........这里部分代码省略.........
break
# update performace graphs
t = frame.timestamp
dt, ts = t - ts, t
try:
fps_graph.add(1.0 / dt)
except ZeroDivisionError:
pass
cpu_graph.update()
# a dictionary that allows plugins to post and read events
events = {}
# report time between now and the last loop interation
events["dt"] = get_dt()
# receive and map pupil positions
recent_pupil_positions = []
while not g_pool.pupil_queue.empty():
p = g_pool.pupil_queue.get()
recent_pupil_positions.append(p)
pupil_graph.add(p["confidence"])
events["pupil_positions"] = recent_pupil_positions
# publish delayed notifiactions when their time has come.
for n in g_pool.delayed_notifications.values():
if n["_notify_time_"] < time():
del n["_notify_time_"]
del g_pool.delayed_notifications[n["subject"]]
g_pool.notifications.append(n)
# notify each plugin if there are new notifications:
while g_pool.notifications:
n = g_pool.notifications.pop(0)
for p in g_pool.plugins:
p.on_notify(n)
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame, events)
# check if a plugin need to be destroyed
g_pool.plugins.clean()
# render camera image
glfw.glfwMakeContextCurrent(main_window)
if g_pool.iconified:
pass
else:
g_pool.image_tex.update_from_frame(frame)
make_coord_system_norm_based()
g_pool.image_tex.draw()
make_coord_system_pixel_based((frame.height, frame.width, 3))
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
if not g_pool.iconified:
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil_graph.draw()
graph.pop_view()
g_pool.gui.update()
glfw.glfwSwapBuffers(main_window)
glfw.glfwPollEvents()
glfw.glfwRestoreWindow(main_window) # need to do this for windows os
session_settings["loaded_plugins"] = g_pool.plugins.get_initializers()
session_settings["pupil_confidence_threshold"] = g_pool.pupil_confidence_threshold
session_settings["gui_scale"] = g_pool.gui.scale
session_settings["ui_config"] = g_pool.gui.configuration
session_settings["capture_settings"] = g_pool.capture.settings
session_settings["window_size"] = glfw.glfwGetWindowSize(main_window)
session_settings["window_position"] = glfw.glfwGetWindowPos(main_window)
session_settings["version"] = g_pool.version
session_settings["eye0_process_alive"] = eyes_are_alive[0].value
session_settings["eye1_process_alive"] = eyes_are_alive[1].value
session_settings["detection_mapping_mode"] = g_pool.detection_mapping_mode
session_settings.close()
# de-init all running plugins
for p in g_pool.plugins:
p.alive = False
g_pool.plugins.clean()
g_pool.gui.terminate()
glfw.glfwDestroyWindow(main_window)
glfw.glfwTerminate()
cap.close()
# shut down eye processes:
stop_eye_process(0)
stop_eye_process(1)
# shut down laucher
lauchner_pipe.send("Exit")
logger.debug("world process done")
示例6: eye
#.........这里部分代码省略.........
timestamps_path = os.path.join(record_path, "eye%s_timestamps.npy"%eye_id)
if raw_mode:
writer = JPEG_Dumper(video_path)
else:
writer = CV_Writer(video_path,float(cap.frame_rate), cap.frame_size)
timestamps = []
else:
logger.info("Done recording.")
writer.release()
writer = None
np.save(timestamps_path,np.asarray(timestamps))
del timestamps
if writer:
writer.write_video_frame(frame)
timestamps.append(frame.timestamp)
# pupil ellipse detection
result = pupil_detector.detect(frame,user_roi=u_r,visualize=g_pool.display_mode == 'algorithm')
result['id'] = eye_id
# stream the result
g_pool.pupil_queue.put(result)
# GL drawing
glfwMakeContextCurrent(main_window)
clear_gl_screen()
# switch to work in normalized coordinate space
if g_pool.display_mode == 'algorithm':
update_named_texture(g_pool.image_tex,frame.img)
elif g_pool.display_mode in ('camera_image','roi'):
update_named_texture(g_pool.image_tex,frame.gray)
else:
pass
make_coord_system_norm_based(g_pool.flip)
draw_named_texture(g_pool.image_tex)
# switch to work in pixel space
make_coord_system_pixel_based((frame.height,frame.width,3),g_pool.flip)
if result['confidence'] >0:
if result.has_key('axes'):
pts = cv2.ellipse2Poly( (int(result['center'][0]),int(result['center'][1])),
(int(result['axes'][0]/2),int(result['axes'][1]/2)),
int(result['angle']),0,360,15)
cygl_draw_polyline(pts,1,cygl_rgba(1.,0,0,.5))
cygl_draw_points([result['center']],size=20,color=cygl_rgba(1.,0.,0.,.5),sharpness=1.)
# render graphs
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
graph.pop_view()
# render GUI
g_pool.gui.update()
#render the ROI
if g_pool.display_mode == 'roi':
u_r.draw(g_pool.gui.scale)
#update screen
glfwSwapBuffers(main_window)
glfwPollEvents()
# END while running
# in case eye recording was still runnnig: Save&close
if writer:
logger.info("Done recording eye.")
writer = None
np.save(timestamps_path,np.asarray(timestamps))
# save session persistent settings
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['roi'] = u_r.get()
session_settings['flip'] = g_pool.flip
session_settings['display_mode'] = g_pool.display_mode
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['capture_settings'] = g_pool.capture.settings
session_settings['window_size'] = glfwGetWindowSize(main_window)
session_settings['window_position'] = glfwGetWindowPos(main_window)
session_settings['version'] = g_pool.version
session_settings.close()
pupil_detector.cleanup()
glfwDestroyWindow(main_window)
glfwTerminate()
cap.close()
#flushing queue in case world process did not exit gracefully
while not g_pool.pupil_queue.empty():
g_pool.pupil_queue.get()
g_pool.pupil_queue.close()
logger.debug("Process done")
示例7: main
#.........这里部分代码省略.........
pupil_graph = graph.Bar_Graph(max_val=1.0)
pupil_graph.pos = (260,110)
pupil_graph.update_rate = 5
pupil_graph.label = "Confidence: %0.2f"
while not glfwWindowShouldClose(main_window):
#grab new frame
if g_pool.play or g_pool.new_seek:
try:
new_frame = cap.get_frame()
except EndofVideoFileError:
#end of video logic: pause at last frame.
g_pool.play=False
if g_pool.new_seek:
display_time = new_frame.timestamp
g_pool.new_seek = False
update_graph = True
else:
update_graph = False
frame = new_frame.copy()
events = {}
#new positons we make a deepcopy just like the image is a copy.
events['pupil_positions'] = deepcopy(positions_by_frame[frame.index])
if update_graph:
#update performace graphs
for p in events['pupil_positions']:
pupil_graph.add(p['confidence'])
t = new_frame.timestamp
if ts != t:
dt,ts = t-ts,t
fps_graph.add(1./dt)
g_pool.play_button.status_text = str(frame.index)
#always update the CPU graph
cpu_graph.update()
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame,events)
#check if a plugin need to be destroyed
g_pool.plugins.clean()
# render camera image
glfwMakeContextCurrent(main_window)
make_coord_system_norm_based()
update_named_texture(g_pool.image_tex,frame.img)
draw_named_texture(g_pool.image_tex)
make_coord_system_pixel_based(frame.img.shape)
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil_graph.draw()
graph.pop_view()
g_pool.gui.update()
#present frames at appropriate speed
wait_time = frame.timestamp - display_time
display_time = frame.timestamp
try:
spent_time = time()-timestamp
sleep(wait_time-spent_time)
except:
pass
timestamp = time()
glfwSwapBuffers(main_window)
glfwPollEvents()
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['main_menu_config'] = g_pool.main_menu.configuration
session_settings['window_size'] = glfwGetWindowSize(main_window)
session_settings['window_position'] = glfwGetWindowPos(main_window)
session_settings.close()
# de-init all running plugins
for p in g_pool.plugins:
p.alive = False
g_pool.plugins.clean()
cap.close()
glfwDestroyWindow(main_window)
glfwTerminate()
logger.debug("Process done")
示例8: eye
#.........这里部分代码省略.........
# pupil ellipse detection
result = g_pool.pupil_detector.detect(frame, g_pool.u_r, g_pool.display_mode == 'algorithm')
result['id'] = eye_id
# stream the result
pupil_socket.send('pupil.%s'%eye_id,result)
# GL drawing
if window_should_update():
if is_window_visible(main_window):
glfw.glfwMakeContextCurrent(main_window)
clear_gl_screen()
# switch to work in normalized coordinate space
if g_pool.display_mode == 'algorithm':
g_pool.image_tex.update_from_ndarray(frame.img)
elif g_pool.display_mode in ('camera_image','roi'):
g_pool.image_tex.update_from_ndarray(frame.gray)
else:
pass
make_coord_system_norm_based(g_pool.flip)
g_pool.image_tex.draw()
window_size = glfw.glfwGetWindowSize(main_window)
make_coord_system_pixel_based((frame.height,frame.width,3),g_pool.flip)
g_pool.capture.gl_display()
if result['method'] == '3d c++':
eye_ball = result['projected_sphere']
try:
pts = cv2.ellipse2Poly( (int(eye_ball['center'][0]),int(eye_ball['center'][1])),
(int(eye_ball['axes'][0]/2),int(eye_ball['axes'][1]/2)),
int(eye_ball['angle']),0,360,8)
except ValueError as e:
pass
else:
draw_polyline(pts,2,RGBA(0.,.9,.1,result['model_confidence']) )
if result['confidence'] >0:
if result.has_key('ellipse'):
pts = cv2.ellipse2Poly( (int(result['ellipse']['center'][0]),int(result['ellipse']['center'][1])),
(int(result['ellipse']['axes'][0]/2),int(result['ellipse']['axes'][1]/2)),
int(result['ellipse']['angle']),0,360,15)
confidence = result['confidence'] * 0.7 #scale it a little
draw_polyline(pts,1,RGBA(1.,0,0,confidence))
draw_points([result['ellipse']['center']],size=20,color=RGBA(1.,0.,0.,confidence),sharpness=1.)
# render graphs
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
graph.pop_view()
# render GUI
g_pool.gui.update()
#render the ROI
g_pool.u_r.draw(g_pool.gui.scale)
if g_pool.display_mode == 'roi':
g_pool.u_r.draw_points(g_pool.gui.scale)
#update screen
glfw.glfwSwapBuffers(main_window)
glfw.glfwPollEvents()
g_pool.pupil_detector.visualize() #detector decides if we visualize or not
# END while running
# in case eye recording was still runnnig: Save&close
if writer:
logger.info("Done recording eye.")
writer = None
np.save(timestamps_path,np.asarray(timestamps))
glfw.glfwRestoreWindow(main_window) #need to do this for windows os
# save session persistent settings
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['roi'] = g_pool.u_r.get()
session_settings['flip'] = g_pool.flip
session_settings['display_mode'] = g_pool.display_mode
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['capture_settings'] = g_pool.capture.settings
session_settings['capture_manager_settings'] = g_pool.capture_manager.class_name, g_pool.capture_manager.get_init_dict()
session_settings['window_size'] = glfw.glfwGetWindowSize(main_window)
session_settings['window_position'] = glfw.glfwGetWindowPos(main_window)
session_settings['version'] = g_pool.version
session_settings['last_pupil_detector'] = g_pool.pupil_detector.__class__.__name__
session_settings['pupil_detector_settings'] = g_pool.pupil_detector.get_settings()
session_settings.close()
g_pool.capture.deinit_gui()
g_pool.pupil_detector.cleanup()
g_pool.gui.terminate()
glfw.glfwDestroyWindow(main_window)
glfw.glfwTerminate()
g_pool.capture_manager.cleanup()
g_pool.capture.cleanup()
logger.info("Process shutting down.")
示例9: update_named_texture
update_named_texture(g_pool.image_tex,frame.gray)
make_coord_system_norm_based()
draw_named_texture(g_pool.image_tex)
make_coord_system_pixel_based((frame.height,frame.width,3))
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
graph.push_view()
# fps_graph.draw()
# cpu_graph.draw()
# pupil_graph.draw()
# pupil_dia_graph.draw()
graph.pop_view()
g_pool.gui.update()
glfwSwapBuffers(main_window)
glfwPollEvents()
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['pupil_confidence_threshold'] = g_pool.pupil_confidence_threshold
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['side_bar_config'] = g_pool.sidebar.configuration
session_settings['capture_menu_config'] = g_pool.capture.menu.configuration
session_settings['general_menu_config'] = general_settings.configuration
session_settings['advanced_menu_config'] = advanced_settings.configuration
session_settings['calibration_menu_config']=g_pool.calibration_menu.configuration
session_settings['window_size'] = glfwGetWindowSize(main_window)
session_settings['window_position'] = glfwGetWindowPos(main_window)
示例10: world
#.........这里部分代码省略.........
recent_pupil_data = []
recent_gaze_data = []
new_notifications = []
while pupil_sub.new_data:
t,p = pupil_sub.recv()
pupil_graphs[p['id']].add(p['confidence'])
recent_pupil_data.append(p)
new_gaze_data = g_pool.active_gaze_mapping_plugin.on_pupil_datum(p)
for g in new_gaze_data:
gaze_pub.send('gaze',g)
recent_gaze_data += new_gaze_data
while notify_sub.new_data:
t,n = notify_sub.recv()
new_notifications.append(n)
events['pupil_positions'] = recent_pupil_data
events['gaze_positions'] = recent_gaze_data
# notify each plugin if there are new notifications:
for n in new_notifications:
handle_notifications(n)
for p in g_pool.plugins:
p.on_notify(n)
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame,events)
#check if a plugin need to be destroyed
g_pool.plugins.clean()
#send new events to ipc:
del events['pupil_positions'] #already on the wire
del events['gaze_positions'] #send earlier in this loop
del events['dt'] #no need to send this
for topic,data in events.iteritems():
for d in data:
ipc_pub.send(topic, d)
# render camera image
glfw.glfwMakeContextCurrent(main_window)
if g_pool.iconified:
pass
else:
g_pool.image_tex.update_from_frame(frame)
glFlush()
make_coord_system_norm_based()
g_pool.image_tex.draw()
make_coord_system_pixel_based((frame.height,frame.width,3))
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
if not g_pool.iconified:
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil0_graph.draw()
pupil1_graph.draw()
graph.pop_view()
g_pool.gui.update()
glfw.glfwSwapBuffers(main_window)
glfw.glfwPollEvents()
glfw.glfwRestoreWindow(main_window) #need to do this for windows os
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['ui_config'] = g_pool.gui.configuration
session_settings['capture_settings'] = g_pool.capture.settings
session_settings['window_size'] = glfw.glfwGetWindowSize(main_window)
session_settings['window_position'] = glfw.glfwGetWindowPos(main_window)
session_settings['version'] = g_pool.version
session_settings['eye0_process_alive'] = eyes_are_alive[0].value
session_settings['eye1_process_alive'] = eyes_are_alive[1].value
session_settings['detection_mapping_mode'] = g_pool.detection_mapping_mode
session_settings['audio_mode'] = audio.audio_mode
session_settings.close()
# de-init all running plugins
for p in g_pool.plugins:
p.alive = False
g_pool.plugins.clean()
g_pool.gui.terminate()
glfw.glfwDestroyWindow(main_window)
glfw.glfwTerminate()
g_pool.capture.close()
#shut down eye processes:
stop_eye_process(0)
stop_eye_process(1)
logger.info("Process shutting down.")
ipc_pub.notify({'subject':'world_process.stopped'})
#shut down launcher
n = {'subject':'launcher_process.should_stop'}
ipc_pub.notify(n)
zmq_ctx.destroy()
示例11: world
#.........这里部分代码省略.........
cpu_graph.label = 'CPU %0.1f'
fps_graph = graph.Bar_Graph()
fps_graph.pos = (140,130)
fps_graph.update_rate = 5
fps_graph.label = "%0.0f FPS"
pupil_graph = graph.Bar_Graph(max_val=1.0)
pupil_graph.pos = (260,130)
pupil_graph.update_rate = 5
pupil_graph.label = "Confidence: %0.2f"
# Event loop
while not g_pool.quit.value:
# Get an image from the grabber
try:
frame = cap.get_frame()
except CameraCaptureError:
logger.error("Capture from camera failed. Stopping.")
break
except EndofVideoFileError:
logger.warning("Video file is done. Stopping")
break
#update performace graphs
t = frame.timestamp
dt,ts = t-ts,t
try:
fps_graph.add(1./dt)
except ZeroDivisionError:
pass
cpu_graph.update()
#a dictionary that allows plugins to post and read events
events = {}
#receive and map pupil positions
recent_pupil_positions = []
while not g_pool.pupil_queue.empty():
p = g_pool.pupil_queue.get()
recent_pupil_positions.append(p)
pupil_graph.add(p['confidence'])
events['pupil_positions'] = recent_pupil_positions
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame,events)
#check if a plugin need to be destroyed
g_pool.plugins.clean()
# render camera image
glfwMakeContextCurrent(main_window)
if g_pool.update_textures == 2:
update_named_texture(g_pool.image_tex,frame.img)
elif g_pool.update_textures == 1:
update_named_texture(g_pool.image_tex,frame.gray)
make_coord_system_norm_based()
draw_named_texture(g_pool.image_tex)
make_coord_system_pixel_based((frame.height,frame.width,3))
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil_graph.draw()
graph.pop_view()
g_pool.gui.update()
glfwSwapBuffers(main_window)
glfwPollEvents()
session_settings['loaded_plugins'] = g_pool.plugins.get_initializers()
session_settings['pupil_confidence_threshold'] = g_pool.pupil_confidence_threshold
session_settings['gui_scale'] = g_pool.gui.scale
session_settings['side_bar_config'] = g_pool.sidebar.configuration
session_settings['capture_menu_config'] = g_pool.capture.menu.configuration
session_settings['general_menu_config'] = general_settings.configuration
session_settings['advanced_menu_config'] = advanced_settings.configuration
session_settings['calibration_menu_config']=g_pool.calibration_menu.configuration
session_settings['window_size'] = glfwGetWindowSize(main_window)
session_settings['window_position'] = glfwGetWindowPos(main_window)
session_settings['update_textures'] = g_pool.update_textures
session_settings.close()
# de-init all running plugins
for p in g_pool.plugins:
p.alive = False
g_pool.plugins.clean()
cap.close()
glfwDestroyWindow(main_window)
glfwTerminate()
logger.debug("Process done")
示例12: session
#.........这里部分代码省略.........
fps_graph.update_rate = 5
fps_graph.label = "%0.0f REC FPS"
pupil_graph = graph.Bar_Graph(max_val=1.0)
pupil_graph.pos = (260, 110)
pupil_graph.update_rate = 5
pupil_graph.label = "Confidence: %0.2f"
while not glfwWindowShouldClose(main_window):
# grab new frame
if g_pool.play or g_pool.new_seek:
try:
new_frame = cap.get_frame()
except EndofVideoFileError:
# end of video logic: pause at last frame.
g_pool.play = False
if g_pool.new_seek:
display_time = new_frame.timestamp
g_pool.new_seek = False
update_graph = True
else:
update_graph = False
frame = new_frame.copy()
events = {}
# new positons we make a deepcopy just like the image is a copy.
events["gaze_positions"] = deepcopy(g_pool.gaze_positions_by_frame[frame.index])
events["pupil_positions"] = deepcopy(g_pool.pupil_positions_by_frame[frame.index])
if update_graph:
# update performace graphs
for p in events["pupil_positions"]:
pupil_graph.add(p["confidence"])
t = new_frame.timestamp
if ts != t:
dt, ts = t - ts, t
fps_graph.add(1.0 / dt)
g_pool.play_button.status_text = str(frame.index)
# always update the CPU graph
cpu_graph.update()
# allow each Plugin to do its work.
for p in g_pool.plugins:
p.update(frame, events)
# check if a plugin need to be destroyed
g_pool.plugins.clean()
# render camera image
glfwMakeContextCurrent(main_window)
make_coord_system_norm_based()
update_named_texture(g_pool.image_tex, frame.img)
draw_named_texture(g_pool.image_tex)
make_coord_system_pixel_based(frame.img.shape)
# render visual feedback from loaded plugins
for p in g_pool.plugins:
p.gl_display()
graph.push_view()
fps_graph.draw()
cpu_graph.draw()
pupil_graph.draw()
graph.pop_view()
g_pool.gui.update()
# present frames at appropriate speed
wait_time = frame.timestamp - display_time
display_time = frame.timestamp
try:
spent_time = time() - timestamp
sleep(wait_time - spent_time)
except:
pass
timestamp = time()
glfwSwapBuffers(main_window)
glfwPollEvents()
session_settings["loaded_plugins"] = g_pool.plugins.get_initializers()
session_settings["gui_scale"] = g_pool.gui.scale
session_settings["ui_config"] = g_pool.gui.configuration
session_settings["window_size"] = glfwGetWindowSize(main_window)
session_settings["window_position"] = glfwGetWindowPos(main_window)
session_settings["version"] = 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.close()
g_pool.gui.terminate()
destroy_named_texture(g_pool.image_tex)
glfwDestroyWindow(main_window)