From bc60c825b4b91954b9506132e805c744fe862e58 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Wed, 5 Jul 2023 16:44:26 +0200 Subject: Updating ArFeatures changes. --- src/argaze/utils/demo_ar_features_run.py | 46 ++++++++++++---------- .../demo_environment/demo_ar_features_setup.json | 16 ++++---- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/argaze/utils/demo_ar_features_run.py b/src/argaze/utils/demo_ar_features_run.py index d7854e3..6151188 100644 --- a/src/argaze/utils/demo_ar_features_run.py +++ b/src/argaze/utils/demo_ar_features_run.py @@ -45,12 +45,10 @@ def main(): timestamp = int((time.time() - start_time) * 1e3) # Project gaze position into environment - for scene_name, scene_looking_data in ar_environment.look(timestamp, GazeFeatures.GazePosition((x, y))): + for frame, look_data in ar_environment.look(timestamp, GazeFeatures.GazePosition((x, y))): - for frame_name, frame_looking_data in scene_looking_data: - - # Do nothing with frame looking data - pass + # Do nothing with look data + pass # Attach mouse callback to window cv2.setMouseCallback(ar_environment.name, on_mouse_event) @@ -69,34 +67,40 @@ def main(): if success: - # Try to detect and project environment - try: + # Detect and project environment + detection_time, exceptions = ar_environment.detect_and_project(video_image) + + # Create environment image + environment_image = ar_environment.image + + # Write detection fps + cv2.rectangle(environment_image, (0, 0), (420, 50), (63, 63, 63), -1) + cv2.putText(environment_image, f'Detection fps: {1e3/detection_time:.1f}', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA) - ar_environment.detect_and_project(video_image) + # Handle exceptions + for i, (scene_name, e) in enumerate(exceptions.items()): - # Catch errors - except (ArFeatures.PoseEstimationFailed, ArFeatures.SceneProjectionFailed) as e: + # Write errors + cv2.rectangle(environment_image, (0, (i+1)*50), (720, (i+2)*50), (127, 127, 127), -1) + cv2.putText(environment_image, f'{scene_name} error: {e}', (20, (i+1)*90), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - cv2.rectangle(video_image, (0, 50), (700, 100), (127, 127, 127), -1) - cv2.putText(video_image, f'Error: {e}', (20, 80), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - - # Draw environment - ar_environment.draw(video_image) + # Draw environment info + ar_environment.draw(environment_image) # Display environment - cv2.imshow(ar_environment.name, video_image) + cv2.imshow(ar_environment.name, environment_image) - # Draw and display each frames in separate window - for scene_name, frame_name, frame in ar_environment.frames: + # Draw and display each aoi frames + for aoi_frame in ar_environment.aoi_frames: # Create frame image - frame_image = frame.image + aoi_frame_image = aoi_frame.image # Draw frame info - frame.draw(frame_image) + aoi_frame.draw(aoi_frame_image) # Display frame - cv2.imshow(f'{scene_name}:{frame_name}', frame_image) + cv2.imshow(f'{aoi_frame.parent.name}:{aoi_frame.name}', aoi_frame_image) # Stop by pressing 'Esc' key if cv2.waitKey(10) == 27: diff --git a/src/argaze/utils/demo_environment/demo_ar_features_setup.json b/src/argaze/utils/demo_environment/demo_ar_features_setup.json index 0081ccf..3e030f8 100644 --- a/src/argaze/utils/demo_environment/demo_ar_features_setup.json +++ b/src/argaze/utils/demo_environment/demo_ar_features_setup.json @@ -12,18 +12,18 @@ "aprilTagDeglitch": 1 } }, + "camera_frame": { + "gaze_movement_identifier": { + "DispersionThresholdIdentification": { + "deviation_max_threshold": 50, + "duration_min_threshold": 200 + } + } + }, "scenes": { "AR Scene Demo" : { "aruco_scene": "aruco_scene.obj", "aoi_3d_scene": "aoi_3d_scene.obj", - "camera_frame": { - "gaze_movement_identifier": { - "DispersionThresholdIdentification": { - "deviation_max_threshold": 50, - "duration_min_threshold": 200 - } - } - }, "aoi_frames": { "GrayRectangle": { "size": [640, 480], -- cgit v1.1