def __init__(self, g_pool, fullscreen=False): super().__init__(g_pool) self.collect_new = False self.calculated = False self.obj_grid = _gen_pattern_grid((4, 11)) self.img_points = [] self.obj_points = [] self.count = 10 self.display_grid = _make_grid() self._window = None self.menu = None self.button = None self.clicks_to_close = 5 self.window_should_close = False self.fullscreen = fullscreen self.monitor_idx = 0 self.dist_mode = "Fisheye" self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.glfont.set_align_string(v_align='center') self.undist_img = None self.show_undistortion = False self.show_undistortion_switch = None if hasattr(self.g_pool.capture, 'intrinsics') and self.g_pool.capture.intrinsics: logger.info('Click show undistortion to verify camera intrinsics calibration.') logger.info('Hint: Straight lines in the real world should be straigt in the image.') else: logger.info('No camera intrinsics calibration is currently set for this camera!')
def init_ui(self): self.add_menu() self.menu.label = 'Fixation Detector' for help_block in self.__doc__.split('\n\n'): help_str = help_block.replace('\n', ' ').replace(' ', '').strip() self.menu.append(ui.Info_Text(help_str)) self.menu.append( ui.Slider('max_dispersion', self, min=0.01, step=0.1, max=5., label='Maximum Dispersion [degrees]')) self.menu.append( ui.Slider('min_duration', self, min=10, step=10, max=4000, label='Minimum Duration [milliseconds]')) self.menu.append( ui.Slider('confidence_threshold', self, min=0.0, max=1.0, label='Confidence Threshold')) self.glfont = fontstash.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_size(22) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0))
def __init__(self, g_pool, fullscreen=True, marker_scale=1.0, sample_duration=500, monitor_idx=0): super().__init__(g_pool) self.screen_marker_state = 0. self.sample_duration = sample_duration # number of frames to sample per site self.lead_in = 100 # frames of marker shown before starting to sample self.lead_out = 15 # frames of markers shown after sampling is donw self.active_site = None self.sites = [] self.display_pos = -1., -1. self.on_position = False self.pos = None self.marker_scale = marker_scale self._window = None self.menu = None self.monitor_idx = monitor_idx self.fullscreen = fullscreen self.clicks_to_close = 5 self.glfont = fontstash.Context() self.glfont.add_font('opensans',get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2,0.5,0.9,1.0)) self.glfont.set_align_string(v_align='center') self.window_position_default = (0, 0) self.circle_tracker = CircleTracker() self.markers = []
def init_gui(self): #lets make a menu entry in the sidebar self.menu = ui.Scrolling_Menu('view add edit annotations') self.g_pool.gui.append(self.menu) #add a button to close the plugin self.menu.append(ui.Button('close', self.close)) self.menu.append( ui.Info_Text( "Annotations recorded with capture are displayed when this plugin is loaded. New annotations can be added with the interface below." )) self.menu.append( ui.Info_Text( "If you want to revert annotations to the recorded state, stop player, delete the annotations file in the recording and reopen player." )) self.menu.append(ui.Text_Input('new_annotation_name', self)) self.menu.append(ui.Text_Input('new_annotation_hotkey', self)) self.menu.append(ui.Button('add annotation type', self.add_annotation)) self.sub_menu = ui.Growing_Menu('Events - click to remove') self.menu.append(self.sub_menu) self.update_buttons() self.on_window_resize(glfwGetCurrentContext(), *glfwGetWindowSize(glfwGetCurrentContext())) self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(24) #self.glfont.set_color_float((0.2,0.5,0.9,1.0)) self.glfont.set_align_string(v_align='center', h_align='middle')
def __init__(self, g_pool,fullscreen=True,marker_scale=1.0,sample_duration=40): super().__init__(g_pool) self.detected = False self.screen_marker_state = 0. self.lead_in = 25 # frames of marker shown before starting to sample self.display_pos = (.5,.5) self.on_position = False self.markers = [] self.pos = None self.marker_scale = marker_scale self._window = None self.menu = None self.fullscreen = fullscreen self.clicks_to_close = 5 self.glfont = fontstash.Context() self.glfont.add_font('opensans',get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2,0.5,0.9,1.0)) self.glfont.set_align_string(v_align='center') # UI Platform tweaks if system() == 'Linux': self.window_position_default = (0, 0) elif system() == 'Windows': self.window_position_default = (8, 31) else: self.window_position_default = (0, 0)
def __init__(self, name="unnamed", saved_definition=None): self.name = name self.markers = {} self.detected_markers = 0 self.defined = False self.build_up_status = 0 self.required_build_up = 90. self.detected = False self.m_to_screen = None self.m_from_screen = None self.camera_pose_3d = None self.uid = str(time()) self.real_world_size = {'x': 1., 'y': 1.} ###window and gui vars self._window = None self.fullscreen = False self.window_should_open = False self.window_should_close = False self.gaze_on_srf = [ ] # points on surface for realtime feedback display self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(22) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) if saved_definition is not None: self.load_from_dict(saved_definition)
def init_ui(self): self.add_menu() self.menu.label = "Offline Surface Tracker" self.add_button = ui.Thumb( "add_surface", setter=lambda x: self.add_surface(), getter=lambda: False, label="A", hotkey="a", ) self.g_pool.quickbar.append(self.add_button) self.glfont = fontstash.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_color_float((1.0, 1.0, 1.0, 0.8)) self.glfont.set_align_string(v_align="right", h_align="top") self.timeline = ui.Timeline( "Surface Tracker", self.gl_display_cache_bars, self.draw_labels, self.timeline_line_height * (len(self.surfaces) + 1), ) self.g_pool.user_timelines.append(self.timeline) self.update_gui_markers()
def __init__(self, g_pool, fullscreen=False): super(Camera_Intrinsics_Estimation, self).__init__(g_pool) self.collect_new = False self.calculated = False self.obj_grid = _gen_pattern_grid((4, 11)) self.img_points = [] self.obj_points = [] self.count = 10 self.img_shape = None self.display_grid = _make_grid() self._window = None self.menu = None self.button = None self.clicks_to_close = 5 self.window_should_close = False self.fullscreen = fullscreen self.monitor_idx = 0 self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.glfont.set_align_string(v_align='center')
def open_window(self): if not self._window: self.input = {'button':None, 'mouse':(0,0)} # get glfw started if self.run_independently: glfwInit() window = glfwGetCurrentContext() self._window = glfwCreateWindow(self.window_size[0], self.window_size[1], self.name, None, window) glfwMakeContextCurrent(self._window) if not self._window: exit() glfwSetWindowPos(self._window,0,0) # Register callbacks window glfwSetFramebufferSizeCallback(self._window,self.on_resize) glfwSetWindowIconifyCallback(self._window,self.on_iconify) glfwSetKeyCallback(self._window,self.on_key) glfwSetCharCallback(self._window,self.on_char) glfwSetMouseButtonCallback(self._window,self.on_button) glfwSetCursorPosCallback(self._window,self.on_pos) glfwSetScrollCallback(self._window,self.on_scroll) # get glfw started if self.run_independently: init() self.basic_gl_setup() self.glfont = fs.Context() self.glfont.add_font('opensans',get_opensans_font_path()) self.glfont.set_size(22) self.glfont.set_color_float((0.2,0.5,0.9,1.0)) self.on_resize(self._window,*glfwGetFramebufferSize(self._window)) glfwMakeContextCurrent(window)
def __init__(self, g_pool, fullscreen=True, marker_scale=1.0, sample_duration=40): super(Screen_Marker_Calibration, self).__init__(g_pool) self.detected = False self.screen_marker_state = 0. self.sample_duration = sample_duration # number of frames to sample per site self.lead_in = 25 #frames of marker shown before starting to sample self.lead_out = 5 #frames of markers shown after sampling is donw self.active_site = None self.sites = [] self.display_pos = None self.on_position = False self.markers = [] self.pos = None self.marker_scale = marker_scale self._window = None self.menu = None self.button = None self.fullscreen = fullscreen self.clicks_to_close = 5 self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.glfont.set_align_string(v_align='center')
def init_ui(self): self.add_menu() self.menu.label = "Fixation Detector" for help_block in self.__doc__.split("\n\n"): help_str = help_block.replace("\n", " ").replace(" ", "").strip() self.menu.append(ui.Info_Text(help_str)) self.menu.append( ui.Slider( "max_dispersion", self, min=0.01, step=0.1, max=5.0, label="Maximum Dispersion [degrees]", )) self.menu.append( ui.Slider( "min_duration", self, min=10, step=10, max=4000, label="Minimum Duration [milliseconds]", )) self.glfont = fontstash.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_size(22) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0))
def init_ui(self): self.glfont = fs.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_font('opensans') self.fps_timeline = ui.Timeline('Recorded FPS', self.draw_fps, self.draw_fps_legend) self.fps_timeline.content_height *= 2 self.g_pool.user_timelines.append(self.fps_timeline)
def init_ui(self): self.add_menu() pupil_producer_plugins = [p for p in self.g_pool.plugin_by_name.values() if issubclass(p, Pupil_Producer_Base)] pupil_producer_plugins.sort(key=lambda p: p.__name__) self.menu_icon.order = 0.29 def open_plugin(p): self.notify_all({'subject': 'start_plugin', 'name': p.__name__}) # We add the capture selection menu self.menu.append(ui.Selector( 'pupil_producer', setter=open_plugin, getter=lambda: self.__class__, selection=pupil_producer_plugins, labels=[p.__name__.replace('_', ' ') for p in pupil_producer_plugins], label='Pupil Producers' )) self.glfont = fs.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_font('opensans') self.dia_timeline = ui.Timeline('Pupil Diameter [px]', self.draw_pupil_diameter, self.draw_dia_legend) self.conf_timeline = ui.Timeline('Pupil Confidence', self.draw_pupil_conf, self.draw_conf_legend) self.g_pool.user_timelines.append(self.dia_timeline) self.g_pool.user_timelines.append(self.conf_timeline)
def __init__(self, g_pool, *args, **kwargs): super(PicoflexxCommon, self).__init__(g_pool) self.hue_near = kwargs.get('hue_near', 0.0) self.hue_far = kwargs.get('hue_far', 0.75) self.dist_near = kwargs.get('dist_near', 0.14) self.dist_far = kwargs.get('dist_far', 5.0) self.preview_true_depth = kwargs.get('preview_true_depth', False) self.preview_depth = kwargs.get('preview_depth', True) self._recent_depth_frame = None # type: Optional[DepthFrame] self._recent_frame = None # type: Optional[IRFrame] # capture doesn't provide this in g_pool like player does, main_window isn't present during export self._camera_render_size = glfw.glfwGetWindowSize( g_pool.main_window) if hasattr(g_pool, 'main_window') else None self.current_exposure = 0 # type: int self.glfont = fontstash.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_color_float((1.0, 1.0, 1.0, 0.8)) self.glfont.set_align_string(v_align="center", h_align="top") self._colorbar_offs = (6, 30, 30, 30) self._colorbar_pos = [520, 12] self._colorbar_size = (300, 20) self._tex_id_color_bar = None self._current_opts = None self._mouse_drag_pos = None # type: Optional[Tuple[int, int]]
def init_ui(self): super().init_ui() self.glfont = fs.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_font('opensans') self.timeline = ui.Timeline('Blink Detection', self.draw_activation, self.draw_legend) self.timeline.content_height *= 2 self.g_pool.user_timelines.append(self.timeline)
def init_ui(self): self.add_menu() pupil_producer_plugins = [ p for p in self.g_pool.plugin_by_name.values() if issubclass(p, Pupil_Producer_Base) ] pupil_producer_plugins.sort( key=lambda p: p.pupil_data_source_selection_label()) pupil_producer_plugins.sort( key=lambda p: p.pupil_data_source_selection_order()) pupil_producer_labels = [ p.pupil_data_source_selection_label() for p in pupil_producer_plugins ] self.menu.label = self.plugin_menu_label() self.menu_icon.order = 0.29 self.menu_icon.tooltip = "Pupil Data" def open_plugin(p): self.notify_all({"subject": "start_plugin", "name": p.__name__}) # We add the capture selection menu self.menu.append( ui.Selector( "pupil_producer", setter=open_plugin, getter=lambda: self.__class__, selection=pupil_producer_plugins, labels=pupil_producer_labels, label="Data Source", )) self.cache = {} self.cache_pupil_timeline_data(DATA_KEY_DIAMETER, detector_tag="3d") self.cache_pupil_timeline_data( DATA_KEY_CONFIDENCE, detector_tag="2d", ylim=(0.0, 1.0), fallback_detector_tag="3d", ) self.glfont = fs.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_font("opensans") self.dia_timeline = ui.Timeline( label="Pupil Diameter 3D", draw_data_callback=self.draw_pupil_diameter, draw_label_callback=self.draw_dia_legend, content_height=40.0, ) self.conf_timeline = ui.Timeline("Pupil Confidence", self.draw_pupil_conf, self.draw_conf_legend) self.g_pool.user_timelines.append(self.dia_timeline) self.g_pool.user_timelines.append(self.conf_timeline)
def init_ui(self): super().init_ui() self.menu.label = "Offline Calibration" self.glfont = fontstash.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_color_float((1., 1., 1., 1.)) self.glfont.set_align_string(v_align='right', h_align='top') def use_as_natural_features(): self.manual_ref_positions.extend(self.circle_marker_positions) self.manual_ref_positions.sort(key=lambda mr: mr['index']) def jump_next_natural_feature(): self.manual_ref_positions.sort(key=lambda mr: mr['index']) current = self.g_pool.capture.get_frame_index() for nf in self.manual_ref_positions: if nf['index'] > current: self.notify_all({'subject': 'seek_control.should_seek', 'index': nf['index']}) return logger.error('No further natural feature available') def clear_natural_features(): self.manual_ref_positions = [] self.menu.append(ui.Info_Text('"Detection" searches for circle markers in the world video.')) # self.menu.append(ui.Button('Redetect', self.start_marker_detection)) slider = ui.Slider('detection_progress', self, label='Detection Progress', setter=lambda _: _) slider.display_format = '%3.0f%%' self.menu.append(slider) toggle_label = 'Cancel circle marker detection' if self.process_pipe else 'Start circle marker detection' self.toggle_detection_button = ui.Button(toggle_label, self.toggle_marker_detection) self.menu.append(self.toggle_detection_button) self.menu.append(ui.Separator()) self.menu.append(ui.Button('Use calibration markers as natural features', use_as_natural_features)) self.menu.append(ui.Button('Jump to next natural feature', jump_next_natural_feature)) self.menu.append(ui.Switch('manual_ref_edit_mode', self, label="Natural feature edit mode")) self.menu.append(ui.Button('Clear natural features', clear_natural_features)) self.menu.append(ui.Info_Text('Calibration only considers pupil data that has an equal or higher confidence than the minimum calibration confidence.')) self.menu.append(ui.Slider('min_calibration_confidence', self.g_pool, step=.01, min=0.0, max=1.0, label='Minimum calibration confidence')) 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()))
def init_gui(self): from pyglui import ui text = ui.Info_Text(self.info_text) self.g_pool.capture_source_menu.append(text) from pyglui.pyfontstash import fontstash self.glfont = fontstash.Context() self.glfont.add_font('opensans',ui.get_opensans_font_path()) self.glfont.set_size(64) self.glfont.set_color_float((1.,1.,1.,1.0)) self.glfont.set_align_string(v_align='center',h_align='middle')
def init_ui(self): self.glfont = fontstash.Context() self.glfont.add_font('opensans',get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2,0.5,0.9,1.0)) self.glfont.set_align_string(v_align='center',h_align='middle') self.window_size = glfwGetFramebufferSize(glfwGetCurrentContext()) self.tex = Render_Target(*self.window_size) self._socket = zmq_tools.Msg_Receiver(self.g_pool.zmq_ctx,self.g_pool.ipc_sub_url,('logging',))
def __init__(self, g_pool, fullscreen=False): super(Camera_Intrinsics_Estimation, self).__init__(g_pool) self.collect_new = False self.calculated = False self.obj_grid = _gen_pattern_grid((4, 11)) self.img_points = [] self.obj_points = [] self.count = 10 self.display_grid = _make_grid() self._window = None self.menu = None self.button = None self.clicks_to_close = 5 self.window_should_close = False self.fullscreen = fullscreen self.monitor_idx = 0 self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.glfont.set_align_string(v_align='center') self.undist_img = None self.show_undistortion = False self.show_undistortion_switch = None try: camera_calibration = load_object( os.path.join(self.g_pool.user_dir, 'camera_calibration')) except: self.camera_intrinsics = None else: logger.info( 'Loaded camera calibration. Click show undistortion to verify.' ) logger.info( 'Hint: Lines in the real world should be straigt in the image.' ) same_name = camera_calibration[ 'camera_name'] == self.g_pool.capture.name same_resolution = camera_calibration[ 'resolution'] == self.g_pool.capture.frame_size if not (same_name and same_resolution): logger.warning( 'Loaded camera calibration but camera name and/or resolution has changed. Please re-calibrate.' ) K = camera_calibration['camera_matrix'] dist_coefs = camera_calibration['dist_coefs'] resolution = camera_calibration['resolution'] self.camera_intrinsics = K, dist_coefs, resolution
def init_ui(self): self.glfont = fs.Context() self.glfont.add_font("opensans", ui.get_opensans_font_path()) self.glfont.set_font("opensans") for i in range(self.channels): eeg_channel = EEG_Channel(i) timeline = eeg_channel.set_timeline(self.x, self.y, self.xlim, self.ylim, self.glfont) timeline.content_height *= 1 self.timelines.append(timeline) self.g_pool.user_timelines.append(timeline)
def init_ui(self): super().init_ui() self.menu.label = "Offline Calibration" self.glfont = fontstash.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_color_float((1., 1., 1., .8)) self.glfont.set_align_string(v_align='right', h_align='top') def jump_next_natural_feature(): self.manual_ref_positions.sort(key=lambda mr: mr['index']) current = self.g_pool.capture.get_frame_index() for nf in self.manual_ref_positions: if nf['index'] > current: self.g_pool.capture.seek_to_frame(nf['index']) self.g_pool.new_seek = True return logger.error('No further natural feature available') def clear_natural_features(): self.manual_ref_positions = [] self.menu.append( ui.Info_Text( '"Detection" searches for calibration markers in the world video.' )) # self.menu.append(ui.Button('Redetect', self.start_detection_task)) slider = ui.Slider('detection_progress', self, label='Detection Progress', setter=lambda _: _) slider.display_format = '%3.0f%%' self.menu.append(slider) self.menu.append( ui.Button('Jump to next natural feature', jump_next_natural_feature)) self.menu.append( ui.Switch('manual_ref_edit_mode', self, label="Natural feature edit mode")) self.menu.append( ui.Button('Clear natural features', clear_natural_features)) 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(glfwGetCurrentContext(), *glfwGetWindowSize(glfwGetCurrentContext()))
def init_ui(self): self.glfont = fontstash.Context() self.glfont.add_font("opensans", get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.glfont.set_align_string(v_align="center", h_align="middle") self.window_size = glfw.get_framebuffer_size(glfw.get_current_context()) self.tex = Render_Target(*self.window_size) self._socket = zmq_tools.Msg_Receiver( self.g_pool.zmq_ctx, self.g_pool.ipc_sub_url, self.subscriptions )
def open_window(self): if not self.window: self.input = {"button": None, "mouse": (0, 0)} # get glfw started if self.run_independently: glfw.init() glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE) self.window = glfw.create_window(self.window_size[0], self.window_size[1], self.name, None, None) else: self.window = glfw.create_window( self.window_size[0], self.window_size[1], self.name, None, glfw.get_current_context(), ) self.other_window = glfw.get_current_context() glfw.make_context_current(self.window) glfw.swap_interval(0) glfw.set_window_pos(self.window, window_position_default[0], window_position_default[1]) # Register callbacks window glfw.set_framebuffer_size_callback(self.window, self.on_resize) glfw.set_window_iconify_callback(self.window, self.on_iconify) glfw.set_key_callback(self.window, self.on_window_key) glfw.set_char_callback(self.window, self.on_window_char) glfw.set_mouse_button_callback(self.window, self.on_window_mouse_button) glfw.set_cursor_pos_callback(self.window, self.on_pos) glfw.set_scroll_callback(self.window, self.on_scroll) # get glfw started if self.run_independently: glutils.init() self.basic_gl_setup() self.sphere = glutils.Sphere(20) self.glfont = fs.Context() self.glfont.add_font("opensans", get_opensans_font_path()) self.glfont.set_size(18) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.on_resize(self.window, *glfw.get_framebuffer_size(self.window)) glfw.make_context_current(self.other_window)
def open_window(self): if not self.window: self.input = {"button": None, "mouse": (0, 0)} # get glfw started if self.run_independently: glfwInit() glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE) self.window = glfwCreateWindow(self.window_size[0], self.window_size[1], self.name, None) else: self.window = glfwCreateWindow( self.window_size[0], self.window_size[1], self.name, None, share=glfwGetCurrentContext(), ) self.other_window = glfwGetCurrentContext() glfwMakeContextCurrent(self.window) glfwSwapInterval(0) glfwSetWindowPos(self.window, window_position_default[0], window_position_default[1]) # Register callbacks window glfwSetFramebufferSizeCallback(self.window, self.on_resize) glfwSetWindowIconifyCallback(self.window, self.on_iconify) glfwSetKeyCallback(self.window, self.on_window_key) glfwSetCharCallback(self.window, self.on_window_char) glfwSetMouseButtonCallback(self.window, self.on_window_mouse_button) glfwSetCursorPosCallback(self.window, self.on_pos) glfwSetScrollCallback(self.window, self.on_scroll) # get glfw started if self.run_independently: glutils.init() self.basic_gl_setup() self.sphere = glutils.Sphere(20) self.glfont = fs.Context() self.glfont.add_font("opensans", get_opensans_font_path()) self.glfont.set_size(18) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.on_resize(self.window, *glfwGetFramebufferSize(self.window)) glfwMakeContextCurrent(self.other_window)
def __init__(self, g_pool, name="unnamed", saved_definition=None): self.g_pool = g_pool self.name = name self.markers = {} self.detected_markers = 0 self.defined = False self.build_up_status = 0 self.required_build_up = 90. self.detected = False self.m_to_screen = None self.m_from_screen = None self.camera_pose_3d = None self.use_distortion = True self.uid = str(time()) self.real_world_size = {'x': 1., 'y': 1.} self.heatmap = np.ones(0) self.heatmap_detail = .2 self.heatmap_texture = Named_Texture() self.gaze_history = deque() self.gaze_history_length = 1.0 # unit: seconds # window and gui vars self._window = None self.fullscreen = False self.window_should_open = False self.window_should_close = False self.gaze_on_srf = [ ] # points on surface for realtime feedback display self.fixations_on_srf = [] # fixations on surface self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(22) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.old_corners_robust = None if saved_definition is not None: self.load_from_dict(saved_definition) # UI Platform tweaks if system() == 'Linux': self.window_position_default = (0, 0) elif system() == 'Windows': self.window_position_default = (8, 90) else: self.window_position_default = (0, 0)
def init_gui(self): self.glfont = fontstash.Context() self.glfont.add_font('opensans', get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.glfont.set_align_string(v_align='center', h_align='middle') self.window_size = glfwGetFramebufferSize(glfwGetCurrentContext()) self.tex = Render_Target(*self.window_size) self.log_handler = Log_to_Callback(self.on_log) logger = logging.getLogger() logger.addHandler(self.log_handler) self.log_handler.setLevel(logging.INFO)
def init_ui(self): self.add_menu() self.menu.label = type(self).MENU_LABEL_TEXT for help_block in self.__doc__.split("\n\n"): help_str = help_block.replace("\n", " ").replace(" ", "").strip() self.menu.append(gl_ui.Info_Text(help_str)) color_legend_text = ui.color_from_segment.__doc__ color_legend_text = color_legend_text.strip() color_legend_text = color_legend_text.replace(" ", "") color_legend_text = color_legend_text.replace("\n-", "\n -") self.menu.append(gl_ui.Info_Text(color_legend_text)) self.glfont = fontstash.Context() self.glfont.add_font("opensans", gl_ui.get_opensans_font_path())
def __init__(self, marker_scale: float): # Public properties self.marker_scale = marker_scale self.is_marker_detected = False # Private state self.__state: _MarkerWindowState = MarkerWindowStateClosed() self.__window = GUIWindow() self.__window.add_observer("on_left_click", self._on_left_click) self.__window.add_observer("on_key_press_escape", self._on_key_press_escape) # Private font self.__glfont = fontstash.Context() self.__glfont.add_font("opensans", get_opensans_font_path()) self.__glfont.set_size(32) self.__glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.__glfont.set_align_string(v_align="center")
def init_ui(self): self.add_menu() self.menu.label = 'Offline Surface Tracker' self.add_button = ui.Thumb('add_surface',setter=lambda x: self.add_surface(),getter=lambda:False,label='A',hotkey='a') self.g_pool.quickbar.append(self.add_button) self.glfont = fontstash.Context() self.glfont.add_font('opensans', ui.get_opensans_font_path()) self.glfont.set_color_float((1., 1., 1., .8)) self.glfont.set_align_string(v_align='right', h_align='top') self.timeline = ui.Timeline('Surface Tracker', self.gl_display_cache_bars, self.draw_labels, self.timeline_line_height * (len(self.surfaces) + 1)) self.g_pool.user_timelines.append(self.timeline) self.update_gui_markers()