From a8f92d1e670cfa3231e3d1315d6b6cb98ee4c2cc Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Thu, 18 Jul 2024 01:50:40 +0200 Subject: Removing useless next and previous playback control. --- .../advanced_topics/context_definition.md | 12 +++-- src/argaze/ArFeatures.py | 10 ---- src/argaze/__main__.py | 10 ---- src/argaze/utils/contexts/OpenCV.py | 57 ++++++---------------- 4 files changed, 21 insertions(+), 68 deletions(-) diff --git a/docs/user_guide/eye_tracking_context/advanced_topics/context_definition.md b/docs/user_guide/eye_tracking_context/advanced_topics/context_definition.md index 17dfea9..a543bc7 100644 --- a/docs/user_guide/eye_tracking_context/advanced_topics/context_definition.md +++ b/docs/user_guide/eye_tracking_context/advanced_topics/context_definition.md @@ -7,7 +7,7 @@ The [ArContext](../../../argaze.md/#argaze.ArFeatures.ArContext) class interface Besides, there is also a [DataCaptureContext](../../../argaze.md/#argaze.ArFeatures.DataCaptureContext) class that inherits from [ArContext](../../../argaze.md/#argaze.ArFeatures.ArContext) and that defines an abstract *calibrate* method to write specific device calibration process. -In the same way, there is a [DataPlaybackContext](../../../argaze.md/#argaze.ArFeatures.DataPlaybackContext) class that inherits from [ArContext](../../../argaze.md/#argaze.ArFeatures.ArContext) and that defines abstract *previous* and *next* playback methods to move into record's frames and also defines *duration* and *progression* properties to get information about a record length and playback advancement. +In the same way, there is a [DataPlaybackContext](../../../argaze.md/#argaze.ArFeatures.DataPlaybackContext) class that inherits from [ArContext](../../../argaze.md/#argaze.ArFeatures.ArContext) and that defines *duration* and *progression* properties to get information about a record length and playback advancement. Finally, a specific eye tracking context can be defined into a Python file by writing a class that inherits either from [ArContext](../../../argaze.md/#argaze.ArFeatures.ArContext), [DataCaptureContext](../../../argaze.md/#argaze.ArFeatures.DataCaptureContext) or [DataPlaybackContext](../../../argaze.md/#argaze.ArFeatures.DataPlaybackContext) class. @@ -182,12 +182,14 @@ class DataPlaybackExample(ArFeatures.DataPlaybackContext): # Stop playback threads threading.Thread.join(self.__data_thread) - def previous(self): - """Go to previous camera image frame.""" + @property + def duration(self) -> int|float: + """Get data duration.""" ... - def next(self): - """Go to next camera image frame.""" + @property + def progression(self) -> float: + """Get data playback progression between 0 and 1.""" ... ``` diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 3eb1cda..cab4532 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -1731,16 +1731,6 @@ class DataPlaybackContext(ArContext): super().__init__() self._image_parameters = {**DEFAULT_ARCONTEXT_IMAGE_PARAMETERS, **DEFAULT_DATA_PLAYBACK_CONTEXT_IMAGE_PARAMETERS} - - def previous(self): - """Go to previous frame""" - - raise NotImplementedError - - def next(self): - """Go to next frame""" - - raise NotImplementedError @property def duration(self) -> int|float: diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py index f759be0..a88e3c5 100644 --- a/src/argaze/__main__.py +++ b/src/argaze/__main__.py @@ -236,16 +236,6 @@ def load_context(args): else: context.pause() - - # Select previous image with left arrow - if key_pressed == 2: - - context.previous() - - # Select next image with right arrow - if key_pressed == 3: - - context.next() # Window mode off else: diff --git a/src/argaze/utils/contexts/OpenCV.py b/src/argaze/utils/contexts/OpenCV.py index 9947b7c..908f91d 100644 --- a/src/argaze/utils/contexts/OpenCV.py +++ b/src/argaze/utils/contexts/OpenCV.py @@ -134,11 +134,6 @@ class Movie(Cursor, ArFeatures.DataPlaybackContext): def __read(self): """Iterate on movie images.""" - # Init image selection - _, current_image = self.__movie.read() - current_image_time = self.__movie.get(cv2.CAP_PROP_POS_MSEC) - self.__next_image_index = 0 #int(self.__start * self.__movie_fps) - while self.is_running(): # Check pause event (and stop event) @@ -148,29 +143,26 @@ class Movie(Cursor, ArFeatures.DataPlaybackContext): time.sleep(1) - # Select a new image and detect markers once - if self.__next_image_index != self.__current_image_index or self.__refresh: - - self.__movie.set(cv2.CAP_PROP_POS_FRAMES, self.__next_image_index) - - success, image = self.__movie.read() + # Read image + success, image = self.__movie.read() - if success: + if success: - # Refresh once - self.__refresh = False + # Refresh once + self.__refresh = False - self.__current_image_index = self.__movie.get(cv2.CAP_PROP_POS_FRAMES) - 1 - current_image_time = self.__movie.get(cv2.CAP_PROP_POS_MSEC) + #self.__current_image_index = self.__movie.get(cv2.CAP_PROP_POS_FRAMES) - 1 + current_image_time = self.__movie.get(cv2.CAP_PROP_POS_MSEC) - # Timestamp image - image = DataFeatures.TimestampedImage(image, timestamp=current_image_time) + # Timestamp image + image = DataFeatures.TimestampedImage(image, timestamp=current_image_time) - # Process movie image - self._process_camera_image(timestamp=current_image_time, image=image) + # Process movie image + self._process_camera_image(timestamp=current_image_time, image=image) - # Wait - time.sleep(1 / self.__movie_fps) + # Wait for half frame time + # TODO: Consider camera image processing time to adapt waiting time + time.sleep(0.5 / self.__movie_fps) @DataFeatures.PipelineStepExit def __exit__(self, exception_type, exception_value, exception_traceback): @@ -186,27 +178,6 @@ class Movie(Cursor, ArFeatures.DataPlaybackContext): # Stop reading thread threading.Thread.join(self.__reading_thread) - def refresh(self): - """Refresh current frame.""" - self.__refresh = True - - def previous(self): - """Go to previous frame.""" - self.__next_image_index -= 1 - - # Clip image index - if self.__next_image_index < 0: - self.__next_image_index = 0 - - def next(self): - """Go to next frame.""" - - self.__next_image_index += 1 - - # Clip image index - if self.__next_image_index < 0: - self.__next_image_index = 0 - @property def duration(self) -> int|float: """Get movie duration.""" -- cgit v1.1