aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2024-04-23 11:37:22 +0200
committerThéo de la Hogue2024-04-23 11:37:22 +0200
commitce2767d1b6bc21795ec9bf22ce341b1391585905 (patch)
tree44af092f6485a3888fda05fcc12eaf01d1714221
parentf4914d604e8652b45fba4272ebabbeecce95595c (diff)
downloadargaze-ce2767d1b6bc21795ec9bf22ce341b1391585905.zip
argaze-ce2767d1b6bc21795ec9bf22ce341b1391585905.tar.gz
argaze-ce2767d1b6bc21795ec9bf22ce341b1391585905.tar.bz2
argaze-ce2767d1b6bc21795ec9bf22ce341b1391585905.tar.xz
Adding no-window option.
-rw-r--r--src/argaze/__main__.py48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py
index 5c16f39..f5c5f1c 100644
--- a/src/argaze/__main__.py
+++ b/src/argaze/__main__.py
@@ -24,7 +24,8 @@ import contextlib
import os
from . import load
-from .ArFeatures import ArCamera, ArContext
+from .ArFeatures import ArCamera, ArContext, PostProcessingContext, LiveProcessingContext
+from .utils.UtilsFeatures import print_progress_bar
import cv2
@@ -33,6 +34,7 @@ parser = argparse.ArgumentParser(description=__doc__.split('-')[0])
parser.add_argument('context_file', metavar='CONTEXT_FILE', type=str, help='JSON context filepath')
parser.add_argument('-v', '--verbose', action='store_true', default=False, help='enable verbose mode to print information in console')
parser.add_argument('-p', '--pipe_path', metavar='PIPE_PATH', type=str, default=None, help='enable pipe communication to execute external commands')
+parser.add_argument('--no-window', action='store_true', default=False, help='disable window mode')
args = parser.parse_args()
@@ -63,8 +65,10 @@ with load(args.context_file) as context:
print(context)
- # Create a window to display context
- cv2.namedWindow(context.name, cv2.WINDOW_AUTOSIZE)
+ if not args.no_window:
+
+ # Create a window to display context
+ cv2.namedWindow(context.name, cv2.WINDOW_AUTOSIZE)
# Waiting for 'ctrl+C' interruption
with contextlib.suppress(KeyboardInterrupt), os.fdopen(pipe_file) if args.pipe_path is not None else contextlib.nullcontext() as pipe:
@@ -89,28 +93,29 @@ with load(args.context_file) as context:
logging.error('%s', e)
- # Display context
- cv2.imshow(context.name, context.image())
+ # Window mode on
+ if not args.no_window:
- # Head-mounted eye tracker case: display environment frames image
- if issubclass(type(context.pipeline), ArCamera):
+ # Display context
+ cv2.imshow(context.name, context.image())
- for scene_frame in context.pipeline.scene_frames():
+ # Head-mounted eye tracker case: display environment frames image
+ if issubclass(type(context.pipeline), ArCamera):
- cv2.imshow(scene_frame.name, scene_frame.image())
+ for scene_frame in context.pipeline.scene_frames():
- # Key interaction
- key_pressed = cv2.waitKey(10)
+ cv2.imshow(scene_frame.name, scene_frame.image())
- # Esc: close window
- if key_pressed == 27:
+ # Key interaction
+ key_pressed = cv2.waitKey(10)
- raise KeyboardInterrupt()
+ # Esc: close window
+ if key_pressed == 27:
- # Space bar: pause/resume pipeline processing
- if key_pressed == 32:
+ raise KeyboardInterrupt()
- try:
+ # Space bar: pause/resume pipeline processing
+ if key_pressed == 32:
if context.is_paused():
@@ -120,9 +125,14 @@ with load(args.context_file) as context:
context.pause()
- except NotImplementedError:
+ # Window mode off
+ else:
+
+ if issubclass(type(context), PostProcessingContext):
+
+ print_progress_bar(context.progression, 1., prefix = 'Progression', suffix = '', length = 100)
+
- pass
# Stop frame display
cv2.destroyAllWindows()