aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2024-04-23 15:40:50 +0200
committerThéo de la Hogue2024-04-23 15:40:50 +0200
commitfd7ada1093ac81344777b991731fa62c07aaca4c (patch)
tree0a167ced15289584263df3e8a5a37cd215423a08 /src
parent354fb9b6e763f0834a917fc01b0f63eccd382c42 (diff)
downloadargaze-fd7ada1093ac81344777b991731fa62c07aaca4c.zip
argaze-fd7ada1093ac81344777b991731fa62c07aaca4c.tar.gz
argaze-fd7ada1093ac81344777b991731fa62c07aaca4c.tar.bz2
argaze-fd7ada1093ac81344777b991731fa62c07aaca4c.tar.xz
Adapt display to windows dimension.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/__main__.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py
index 2091bfd..091b660 100644
--- a/src/argaze/__main__.py
+++ b/src/argaze/__main__.py
@@ -34,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('-x', '--display', metavar='DISPLAY', nargs="+", type=int, default=[1920, 1080], help='adapt windows to display dimension')
parser.add_argument('--no-window', action='store_true', default=False, help='disable window mode')
args = parser.parse_args()
@@ -53,6 +54,17 @@ if args.pipe_path is not None:
logging.info('%s pipe opened', args.pipe_path)
+def display(name, image, factor):
+ """Adapt image to display dimension."""
+
+ display_size = tuple(args.display)
+ height, width, _ = image.shape
+ image_ratio = width/height
+
+ new_image_size = (int(display_size[1] * factor * image_ratio), int(display_size[1] * factor))
+
+ cv2.imshow(name, cv2.resize(image, dsize=new_image_size, interpolation=cv2.INTER_LINEAR))
+
# Load context from JSON file
with load(args.context_file) as context:
@@ -97,14 +109,14 @@ with load(args.context_file) as context:
if not args.no_window:
# Display context
- cv2.imshow(context.name, context.image())
+ display(context.name, context.image(), 0.75)
# Head-mounted eye tracker case: display environment frames image
if issubclass(type(context.pipeline), ArCamera):
for scene_frame in context.pipeline.scene_frames():
- cv2.imshow(scene_frame.name, scene_frame.image())
+ display(scene_frame.name, scene_frame.image(), 0.5)
# Key interaction
key_pressed = cv2.waitKey(10)