diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/ArFeatures.py | 34 | ||||
-rw-r--r-- | src/argaze/__main__.py | 18 | ||||
-rw-r--r-- | src/argaze/utils/contexts/OpenCV.py | 14 | ||||
-rw-r--r-- | src/argaze/utils/contexts/TobiiProGlasses2.py | 12 | ||||
-rw-r--r-- | src/argaze/utils/demo/tobii_segment_playback_context.json (renamed from src/argaze/utils/demo/tobii_post_processing_context.json) | 4 |
5 files changed, 41 insertions, 41 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 8d9eceb..a36cb94 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -1521,7 +1521,7 @@ class ArContext(DataFeatures.PipelineStepObject): self._image_parameters = DEFAULT_ARCONTEXT_IMAGE_PARAMETERS @property - def pipeline(self) -> DataFeatures.PipelineStepObject: + def pipeline(self) -> ArFrame|ArCamera: """ArFrame used to process gaze data or ArCamera used to process gaze data and video of environment.""" return self.__pipeline @@ -1538,7 +1538,7 @@ class ArContext(DataFeatures.PipelineStepObject): return self.__exceptions def as_dict(self) -> dict: - """Export ArContext properties as dictionary.""" + """Export context properties as dictionary.""" return { **DataFeatures.PipelineStepObject.as_dict(self), @@ -1548,13 +1548,13 @@ class ArContext(DataFeatures.PipelineStepObject): @DataFeatures.PipelineStepEnter def __enter__(self): - """Enter into ArContext.""" + """Enter into context.""" return self @DataFeatures.PipelineStepExit def __exit__(self, exception_type, exception_value, exception_traceback): - """Exit from ArContext.""" + """Exit from context.""" pass def _process_gaze_position(self, timestamp: int | float, x: int | float = None, y: int | float = None, precision: int | float = None): @@ -1709,24 +1709,24 @@ class ArContext(DataFeatures.PipelineStepObject): @DataFeatures.PipelineStepMethod def pause(self): - """Pause pipeline processing.""" + """Pause context.""" self._pause_event.set() def is_paused(self) -> bool: - """Is pipeline processing paused?""" + """Is context paused?""" return self._pause_event.is_set() @DataFeatures.PipelineStepMethod def resume(self): - """Resume pipeline processing.""" + """Resume context.""" self._pause_event.clear() -class LiveProcessingContext(ArContext): +class DataCaptureContext(ArContext): """ - Defines abstract live data processing context. + Defines abstract data capture context. """ @DataFeatures.PipelineStepInit @@ -1739,14 +1739,14 @@ class LiveProcessingContext(ArContext): raise NotImplementedError -# Define default PostProcessingContext image parameters -DEFAULT_POST_PROCESSING_CONTEXT_IMAGE_PARAMETERS = { +# Define default DataPlaybackContext image parameters +DEFAULT_DATA_PLAYBACK_CONTEXT_IMAGE_PARAMETERS = { "draw_progression": True } -class PostProcessingContext(ArContext): +class DataPlaybackContext(ArContext): """ - Defines abstract post data processing context. + Defines abstract data playback context. """ @DataFeatures.PipelineStepInit @@ -1754,7 +1754,7 @@ class PostProcessingContext(ArContext): super().__init__() - self._image_parameters = {**DEFAULT_ARCONTEXT_IMAGE_PARAMETERS, **DEFAULT_POST_PROCESSING_CONTEXT_IMAGE_PARAMETERS} + self._image_parameters = {**DEFAULT_ARCONTEXT_IMAGE_PARAMETERS, **DEFAULT_DATA_PLAYBACK_CONTEXT_IMAGE_PARAMETERS} def previous(self): """Go to previous frame""" @@ -1774,19 +1774,19 @@ class PostProcessingContext(ArContext): @property def progression(self) -> float: - """Get data processing progression between 0 and 1.""" + """Get data playback progression between 0 and 1.""" raise NotImplementedError @DataFeatures.PipelineStepImage def image(self, draw_progression: bool = True, **kwargs): """ - Get pipeline image with post processing information. + Get pipeline image with data playback information. Parameters: draw_progression: draw progress bar """ - logging.debug('PostProcessingContext.image %s', self.name) + logging.debug('DataPlaybackContext.image %s', self.name) image = super().image(**kwargs) height, width, _ = image.shape diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py index 76e9664..f759be0 100644 --- a/src/argaze/__main__.py +++ b/src/argaze/__main__.py @@ -27,7 +27,7 @@ import stat from . import load from .DataFeatures import SharedObjectBusy -from .ArFeatures import ArCamera, ArContext, PostProcessingContext, LiveProcessingContext +from .ArFeatures import ArCamera, ArContext, DataPlaybackContext, DataCaptureContext from .utils.UtilsFeatures import print_progress_bar import cv2 @@ -68,7 +68,7 @@ def load_context(args): # Blanck line info_stack += 1 - if issubclass(type(context), LiveProcessingContext): + if issubclass(type(context), DataCaptureContext): info_stack += 1 cv2.putText(image, f'Press Enter to start calibration', (int(width/4)+20, int(height/3)+(info_stack*40)), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA) @@ -76,7 +76,7 @@ def load_context(args): info_stack += 1 cv2.putText(image, f'Press r to start/stop recording', (int(width/4)+20, int(height/3)+(info_stack*40)), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA) - if issubclass(type(context), PostProcessingContext): + if issubclass(type(context), DataPlaybackContext): info_stack += 1 cv2.putText(image, f'Press Space bar to pause/resume processing', (int(width/4)+20, int(height/3)+(info_stack*40)), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA) @@ -199,8 +199,8 @@ def load_context(args): raise KeyboardInterrupt() - # Keys specific to live processing contexts - if issubclass(type(context), LiveProcessingContext): + # Keys specific to data capture contexts + if issubclass(type(context), DataCaptureContext): # Enter: start calibration if key_pressed == 13: @@ -222,10 +222,10 @@ def load_context(args): context.create_recording() context.start_recording() - # Keys specific to post processing contexts - if issubclass(type(context), PostProcessingContext): + # Keys specific to data playback contexts + if issubclass(type(context), DataPlaybackContext): - # Space bar: pause/resume pipeline processing + # Space bar: pause/resume data playback if key_pressed == 32: @@ -250,7 +250,7 @@ def load_context(args): # Window mode off else: - if issubclass(type(context), PostProcessingContext): + if issubclass(type(context), DataPlaybackContext): prefix = f'Progression' suffix = f'| {int(context.progression*context.duration * 1e-3)}s in {int(time.time()-start_time)}s' diff --git a/src/argaze/utils/contexts/OpenCV.py b/src/argaze/utils/contexts/OpenCV.py index 273705a..ff3ed82 100644 --- a/src/argaze/utils/contexts/OpenCV.py +++ b/src/argaze/utils/contexts/OpenCV.py @@ -27,7 +27,7 @@ from argaze import ArFeatures, DataFeatures class Cursor(ArFeatures.ArContext): - """Process cursor position over OpenCV window. + """Capture cursor position over OpenCV window. !!! warning It is assumed that an OpenCV window with the same name than the context is used to display context's pipeline image. @@ -36,7 +36,7 @@ class Cursor(ArFeatures.ArContext): @DataFeatures.PipelineStepInit def __init__(self, **kwargs): - # Init LiveProcessingContext class + # Init DataCaptureContext class super().__init__() @DataFeatures.PipelineStepEnter @@ -75,7 +75,7 @@ class Cursor(ArFeatures.ArContext): class Movie(Cursor): - """Process movie images and cursor position over OpenCV window. + """Playback movie images and capture cursor position over OpenCV window. !!! warning It is assumed that an OpenCV window with the same name than the context is used to display context's pipeline image. @@ -139,10 +139,10 @@ class Movie(Cursor): current_image_time = self.__movie.get(cv2.CAP_PROP_POS_MSEC) self.__next_image_index = 0 #int(self.__start * self.__movie_fps) - while not self._stop_event.is_set(): + while self.is_running(): # Check pause event (and stop event) - while self._pause_event.is_set() and not self._stop_event.is_set(): + while self.is_paused() and self.is_running(): logging.debug('> reading is paused at %i', current_image_time) @@ -182,7 +182,7 @@ class Movie(Cursor): # Exit from Cursor context super().__exit__(exception_type, exception_value, exception_traceback) - # Close data stream + # Close data capture self.stop() # Stop reading thread @@ -217,7 +217,7 @@ class Movie(Cursor): @property def progression(self) -> float: - """Get movie processing progression between 0 and 1.""" + """Get movie playback progression between 0 and 1.""" if self.__current_image_index is not None: diff --git a/src/argaze/utils/contexts/TobiiProGlasses2.py b/src/argaze/utils/contexts/TobiiProGlasses2.py index 3dd0161..80c4bdc 100644 --- a/src/argaze/utils/contexts/TobiiProGlasses2.py +++ b/src/argaze/utils/contexts/TobiiProGlasses2.py @@ -330,12 +330,12 @@ class TobiiJsonDataParser(): return MarkerPosition(data['marker3d'], data['marker2d']) -class LiveStream(ArFeatures.LiveProcessingContext): +class LiveStream(ArFeatures.DataCaptureContext): @DataFeatures.PipelineStepInit def __init__(self, **kwargs): - # Init LiveProcessingContext class + # Init DataCaptureContext class super().__init__() # Init private attributes @@ -1067,9 +1067,9 @@ class LiveStream(ArFeatures.LiveProcessingContext): @DataFeatures.PipelineStepImage def image(self, **kwargs): """ - Get pipeline image with live processing information. + Get pipeline image with data capture information. """ - logging.debug('LiveProcessingContext.image %s', self.name) + logging.debug('DataCaptureContext.image %s', self.name) image = super().image(**kwargs) height, width, _ = image.shape @@ -1131,7 +1131,7 @@ class LiveStream(ArFeatures.LiveProcessingContext): return image -class PostProcessing(ArFeatures.PostProcessingContext): +class SegmentPlayback(ArFeatures.DataPlaybackContext): @DataFeatures.PipelineStepInit def __init__(self, **kwargs): @@ -1519,6 +1519,6 @@ class PostProcessing(ArFeatures.PostProcessingContext): @property def progression(self) -> float: - """Get data processing progression between 0 and 1.""" + """Get data playback progression between 0 and 1.""" return self.__progression
\ No newline at end of file diff --git a/src/argaze/utils/demo/tobii_post_processing_context.json b/src/argaze/utils/demo/tobii_segment_playback_context.json index 7a73512..d481b23 100644 --- a/src/argaze/utils/demo/tobii_post_processing_context.json +++ b/src/argaze/utils/demo/tobii_segment_playback_context.json @@ -1,6 +1,6 @@ { - "argaze.utils.contexts.TobiiProGlasses2.PostProcessing" : { - "name": "Tobii Pro Glasses 2 post-processing", + "argaze.utils.contexts.TobiiProGlasses2.SegmentPlayback" : { + "name": "Tobii Pro Glasses 2 segment playback", "segment": "./src/argaze/utils/demo/tobii_record/segments/1", "pipeline": "aruco_markers_pipeline.json" } |