aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2024-04-02 22:42:24 +0200
committerThéo de la Hogue2024-04-02 22:42:24 +0200
commit45aedc77e26c1c99061da6ea923ed11b36537829 (patch)
tree5087518616d59220655830a3c4dd718b51b67e60
parent0a9a3d0b216a1a10bcef33e51d98f62f1777bc0d (diff)
downloadargaze-45aedc77e26c1c99061da6ea923ed11b36537829.zip
argaze-45aedc77e26c1c99061da6ea923ed11b36537829.tar.gz
argaze-45aedc77e26c1c99061da6ea923ed11b36537829.tar.bz2
argaze-45aedc77e26c1c99061da6ea923ed11b36537829.tar.xz
Adding __exit__ method.
-rw-r--r--src/argaze/utils/contexts/OpenCV.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/argaze/utils/contexts/OpenCV.py b/src/argaze/utils/contexts/OpenCV.py
index a65d40e..25b3dd7 100644
--- a/src/argaze/utils/contexts/OpenCV.py
+++ b/src/argaze/utils/contexts/OpenCV.py
@@ -31,7 +31,7 @@ class Window(ArFeatures.ArContext):
@DataFeatures.PipelineStepInit
def __init__(self, **kwargs):
- # Init ArContext classe
+ # Init ArContext class
super().__init__()
@DataFeatures.PipelineStepEnter
@@ -50,6 +50,14 @@ class Window(ArFeatures.ArContext):
return self
+ @DataFeatures.PipelineStepExit
+ def __exit__(self, exception_type, exception_value, exception_traceback):
+
+ logging.info('OpenCV context stops...')
+
+ # Delete window
+ cv2.destroyAllWindows()
+
def __on_mouse_event(self, event, x, y, flags, param):
"""Process pointer position."""
@@ -59,4 +67,4 @@ class Window(ArFeatures.ArContext):
self._process_gaze_position(
timestamp = int((time.time() - self.__start_time) * 1e3),
x = x,
- y = y) \ No newline at end of file
+ y = y)