diff options
-rw-r--r-- | src/argaze/utils/demo_aruco_markers_run.py | 20 | ||||
-rw-r--r-- | src/argaze/utils/demo_gaze_analysis_run.py | 31 |
2 files changed, 18 insertions, 33 deletions
diff --git a/src/argaze/utils/demo_aruco_markers_run.py b/src/argaze/utils/demo_aruco_markers_run.py index 87b4bc3..c8b140c 100644 --- a/src/argaze/utils/demo_aruco_markers_run.py +++ b/src/argaze/utils/demo_aruco_markers_run.py @@ -17,23 +17,19 @@ from argaze.ArUcoMarkers import ArUcoCamera from argaze.utils import UtilsFeatures import cv2 -import numpy -def main(): - """ - Load ArUcoCamera from .json file, detect ArUco markers into camera device images and project it. - """ +current_directory = os.path.dirname(os.path.abspath(__file__)) - current_directory = os.path.dirname(os.path.abspath(__file__)) +# Manage arguments +parser = argparse.ArgumentParser(description=__doc__.split('-')[0]) +parser.add_argument('configuration', metavar='CONFIGURATION', type=str, help='configuration filepath') +parser.add_argument('-s', '--source', metavar='SOURCE', type=str, default='0', help='video capture source (a number to select camera device or a filepath to load a movie)') +args = parser.parse_args() - # Manage arguments - parser = argparse.ArgumentParser(description=main.__doc__.split('-')[0]) - parser.add_argument('aruco_camera', metavar='ARUCO_CAMERA', type=str, help='ArUco camera filepath') - parser.add_argument('-s', '--source', metavar='SOURCE', type=str, default='0', help='video capture source (a number to select camera device or a filepath to load a movie)') - args = parser.parse_args() +def main(): # Load ArUcoCamera - aruco_camera = ArUcoCamera.ArUcoCamera.from_json(args.aruco_camera) + aruco_camera = ArUcoCamera.ArUcoCamera.from_json(args.configuration) # Create a window to display ArUcoCamera cv2.namedWindow(aruco_camera.name, cv2.WINDOW_AUTOSIZE) diff --git a/src/argaze/utils/demo_gaze_analysis_run.py b/src/argaze/utils/demo_gaze_analysis_run.py index 2dcc00e..5b20864 100644 --- a/src/argaze/utils/demo_gaze_analysis_run.py +++ b/src/argaze/utils/demo_gaze_analysis_run.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -""" """ +"""Gaze analysis pipeline demo script.""" __author__ = "Théo de la Hogue" __credits__ = [] @@ -8,34 +8,27 @@ __copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)" __license__ = "BSD" import argparse +import contextlib import os import time from argaze import ArFeatures, GazeFeatures -from argaze.AreaOfInterest import AOIFeatures from argaze.GazeAnalysis import * from argaze.utils import UtilsFeatures import cv2 -import numpy -import pandas -def main(): - """ - Load ArFrame from .json file and use mouse pointer to simulate gaze positions. - """ - - current_directory = os.path.dirname(os.path.abspath(__file__)) +current_directory = os.path.dirname(os.path.abspath(__file__)) - print(current_directory) +# Manage arguments +parser = argparse.ArgumentParser(description=__doc__.split('-')[0]) +parser.add_argument('configuration', metavar='CONFIGURATION', type=str, help='configuration filepath') +args = parser.parse_args() - # Manage arguments - parser = argparse.ArgumentParser(description=main.__doc__.split('-')[0]) - parser.add_argument('frame', metavar='FRAME', type=str, help='ar frame filepath') - args = parser.parse_args() +def main(): # Load ArFrame - ar_frame = ArFeatures.ArFrame.from_json(args.frame) + ar_frame = ArFeatures.ArFrame.from_json(args.configuration) # Create a window to display ArCamera cv2.namedWindow(ar_frame.name, cv2.WINDOW_AUTOSIZE) @@ -66,7 +59,7 @@ def main(): cv2.setMouseCallback(ar_frame.name, on_mouse_event) # Waiting for 'ctrl+C' interruption - try: + with contextlib.suppress(KeyboardInterrupt): # Draw frame and mouse position analysis while True: @@ -249,10 +242,6 @@ def main(): if key_pressed == 27: break - # Stop on 'ctrl+C' interruption - except KeyboardInterrupt: - pass - # Stop frame image display cv2.destroyAllWindows() |