def __init__( self, g_pool, optimize_markers_3d_model=False, optimize_camera_intrinsics=True, open_visualization_window=False, show_camera_trace_in_3d_window=False, render_markers=True, show_marker_id_in_main_window=False, window_size=(1000, 1000), window_position=(90, 90), ): super().__init__(g_pool) self._task_manager = PluginTaskManager(plugin=self) self._online_settings = storage.OnlineSettings(( optimize_markers_3d_model, optimize_camera_intrinsics, open_visualization_window, show_camera_trace_in_3d_window, render_markers, show_marker_id_in_main_window, window_size, window_position, )) self._setup_storages() self._setup_controllers() self._setup_renderers() self._setup_menus()
def __init__(self, g_pool): super().__init__(g_pool) self._task_manager = PluginTaskManager(plugin=self) self._current_recording_uuid = str( PupilRecording(g_pool.rec_dir).meta_info.recording_uuid) self._setup_storages() self._setup_controllers() self._setup_renderers() self._setup_menus() self._setup_timelines()
def __init__(self, g_pool): super().__init__(g_pool) self._task_manager = PluginTaskManager(plugin=self) self._current_recording_uuid = self._load_recording_uuid_from_info_csv( ) self._setup_storages() self._setup_controllers() self._setup_renderers() self._setup_menus() self._setup_timelines()
def __init__( self, plugin, storage: model.Classified_Segment_Storage, on_started: t.Callable[[], None] = nop, on_status: t.Callable[[str], None] = nop, on_progress: t.Callable[[float], None] = nop, on_exception: t.Callable[[Exception], None] = nop, on_completed: t.Callable[[], None] = nop, on_canceled_or_killed: t.Callable[[], None] = nop, on_ended: t.Callable[[], None] = nop, ): self.g_pool = plugin.g_pool self.storage = storage self.task_manager = PluginTaskManager(plugin) self.eye_movement_task = None self._on_started = on_started self._on_status = on_status self._on_progress = on_progress self._on_exception = on_exception self._on_completed = on_completed self._on_canceled_or_killed = on_canceled_or_killed self._on_ended = on_ended
def __init__(self, g_pool): super().__init__(g_pool) self.inject_plugin_dependencies() self._task_manager = PluginTaskManager(plugin=self) self._recording_uuid = PupilRecording( g_pool.rec_dir).meta_info.recording_uuid self._setup_storages() self._setup_controllers() self._setup_ui() self._setup_timelines() self._pupil_changed_listener = data_changed.Listener("pupil_positions", g_pool.rec_dir, plugin=self) self._pupil_changed_listener.add_observer( "on_data_changed", self._calculate_all_controller.calculate_all)
def __init__( self, plugin, storage: model.Classified_Segment_Storage, on_started: t.Callable[[], None] = nop, on_status: t.Callable[[str], None] = nop, on_progress: t.Callable[[float], None] = nop, on_exception: t.Callable[[Exception], None] = nop, on_completed: t.Callable[[], None] = nop, on_canceled_or_killed: t.Callable[[], None] = nop, on_ended: t.Callable[[], None] = nop, ): self.g_pool = plugin.g_pool self.storage = storage self.task_manager = PluginTaskManager(plugin) self.eye_movement_task = None self._on_started = on_started self._on_status = on_status self._on_progress = on_progress self._on_exception = on_exception self._on_completed = on_completed self._on_canceled_or_killed = on_canceled_or_killed self._on_ended = on_ended
class Eye_Movement_Offline_Controller: def __init__( self, plugin, storage: model.Classified_Segment_Storage, on_started: t.Callable[[], None] = nop, on_status: t.Callable[[str], None] = nop, on_progress: t.Callable[[float], None] = nop, on_exception: t.Callable[[Exception], None] = nop, on_completed: t.Callable[[], None] = nop, on_canceled_or_killed: t.Callable[[], None] = nop, on_ended: t.Callable[[], None] = nop, ): self.g_pool = plugin.g_pool self.storage = storage self.task_manager = PluginTaskManager(plugin) self.eye_movement_task = None self._on_started = on_started self._on_status = on_status self._on_progress = on_progress self._on_exception = on_exception self._on_completed = on_completed self._on_canceled_or_killed = on_canceled_or_killed self._on_ended = on_ended @property def min_data_confidence(self) -> float: try: return self.g_pool.min_data_confidence except AttributeError: return MIN_DATA_CONFIDENCE_DEFAULT def classify(self, *args, **kwargs): """ classify eye movement """ if self.g_pool.app == "exporter": return utils.logger.info("Gaze postions changed. Recalculating.") if self.eye_movement_task and self.eye_movement_task.running: self.eye_movement_task.kill(grace_period=1) capture = model.Immutable_Capture(self.g_pool.capture) min_data_confidence = self.min_data_confidence gaze_data: utils.Gaze_Data = [ gp.serialized for gp in self.g_pool.gaze_positions if gp["confidence"] > min_data_confidence ] self.eye_movement_task = worker.Offline_Detection_Task( args=(capture, gaze_data)) self.task_manager.add_task(self.eye_movement_task) self.eye_movement_task.add_observers( on_started=self._on_task_started, on_yield=self._on_task_yield, on_completed=self._on_task_completed, on_ended=self._on_task_ended, on_exception=self._on_task_exception, on_canceled_or_killed=self._on_task_canceled_or_killed, ) self.eye_movement_task.start() def _on_task_started(self): self.storage.clear() self._on_started() self._on_progress(0.0) def _on_task_yield(self, yield_value): status, serialized = yield_value if status: self._on_status(status) if serialized: segment = model.Classified_Segment.from_msgpack(serialized) self.storage.add(segment) current_ts = segment.end_frame_timestamp total_start_ts = self.g_pool.timestamps[0] total_end_ts = self.g_pool.timestamps[-1] current_duration = current_ts - total_start_ts total_duration = total_end_ts - total_start_ts progress = max(0.0, min(current_duration / total_duration, 1.0)) self._on_progress(progress) def _on_task_exception(self, exception: Exception): self._on_exception(exception) self._on_task_completed(None) def _on_task_completed(self, _: None): self.storage.finalize() status = "{} segments detected".format(len(self.storage)) self._on_status(status) self._on_progress(1.0) self._on_completed() def _on_task_canceled_or_killed(self): self._on_canceled_or_killed() def _on_task_ended(self): self._on_ended()
class Eye_Movement_Offline_Controller: def __init__( self, plugin, storage: model.Classified_Segment_Storage, on_started: t.Callable[[], None] = nop, on_status: t.Callable[[str], None] = nop, on_progress: t.Callable[[float], None] = nop, on_exception: t.Callable[[Exception], None] = nop, on_completed: t.Callable[[], None] = nop, on_canceled_or_killed: t.Callable[[], None] = nop, on_ended: t.Callable[[], None] = nop, ): self.g_pool = plugin.g_pool self.storage = storage self.task_manager = PluginTaskManager(plugin) self.eye_movement_task = None self._on_started = on_started self._on_status = on_status self._on_progress = on_progress self._on_exception = on_exception self._on_completed = on_completed self._on_canceled_or_killed = on_canceled_or_killed self._on_ended = on_ended @property def min_data_confidence(self) -> float: try: return self.g_pool.min_data_confidence except AttributeError: return MIN_DATA_CONFIDENCE_DEFAULT def classify(self, *args, **kwargs): """ classify eye movement """ if self.g_pool.app == "exporter": return utils.logger.info("Gaze postions changed. Recalculating.") if self.eye_movement_task and self.eye_movement_task.running: self.eye_movement_task.kill(grace_period=1) capture = model.Immutable_Capture(self.g_pool.capture) min_data_confidence = self.min_data_confidence gaze_data: utils.Gaze_Data = [ gp.serialized for gp in self.g_pool.gaze_positions if gp["confidence"] > min_data_confidence ] self.eye_movement_task = worker.Offline_Detection_Task( args=(capture, gaze_data) ) self.task_manager.add_task(self.eye_movement_task) self.eye_movement_task.add_observers( on_started=self._on_task_started, on_yield=self._on_task_yield, on_completed=self._on_task_completed, on_ended=self._on_task_ended, on_exception=self._on_task_exception, on_canceled_or_killed=self._on_task_canceled_or_killed, ) self.eye_movement_task.start() def _on_task_started(self): self.storage.clear() self._on_started() self._on_progress(0.0) def _on_task_yield(self, yield_value): status, serialized = yield_value if status: self._on_status(status) if serialized: segment = model.Classified_Segment.from_msgpack(serialized) self.storage.add(segment) current_ts = segment.end_frame_timestamp total_start_ts = self.g_pool.timestamps[0] total_end_ts = self.g_pool.timestamps[-1] current_duration = current_ts - total_start_ts total_duration = total_end_ts - total_start_ts progress = max(0.0, min(current_duration / total_duration, 1.0)) self._on_progress(progress) def _on_task_exception(self, exception: Exception): self._on_exception(exception) def _on_task_completed(self, _: None): self.storage.finalize() status = "{} segments detected".format(len(self.storage)) self._on_status(status) self._on_progress(1.0) self._on_completed() def _on_task_canceled_or_killed(self): self._on_canceled_or_killed() def _on_task_ended(self): self._on_ended()