aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2023-04-25 18:22:42 +0200
committerThéo de la Hogue2023-04-25 18:22:42 +0200
commit441c250d5a0901cea0ecf580bba8f6434a2e401b (patch)
tree9d67266021ced5f2dde9082eec95ef5b9f1f9ea9 /src
parentec7a6b51efe4439994f2492441444db7c25c01f4 (diff)
downloadargaze-441c250d5a0901cea0ecf580bba8f6434a2e401b.zip
argaze-441c250d5a0901cea0ecf580bba8f6434a2e401b.tar.gz
argaze-441c250d5a0901cea0ecf580bba8f6434a2e401b.tar.bz2
argaze-441c250d5a0901cea0ecf580bba8f6434a2e401b.tar.xz
Improving marker color display.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/utils/environment_edit.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/argaze/utils/environment_edit.py b/src/argaze/utils/environment_edit.py
index 29fe384..ce6691c 100644
--- a/src/argaze/utils/environment_edit.py
+++ b/src/argaze/utils/environment_edit.py
@@ -137,9 +137,14 @@ def main():
# Detect markers
ar_environment.aruco_detector.detect_markers(video_frame)
- # Draw focus area
- cv2.rectangle(video_frame, (int(frame_width/6), 0), (int(frame_width*(1-1/6)), int(frame_height)), (255, 150, 150), 1)
-
+ # Edit marker's color
+ for i, m in ar_environment.aruco_detector.detected_markers.items():
+
+ m.color = list(itertools.permutations([0, 255, 255]))[i]
+
+ # Draw center
+ cv2.circle(video_frame, m.center.astype(int), 5, m.color, -1)
+
# Write timing
cv2.rectangle(video_frame, (0, 0), (frame_width, 50), (63, 63, 63), -1)
cv2.putText(video_frame, f'Time: {int(current_frame_time)} ms', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
@@ -180,7 +185,8 @@ def main():
selected_marker = ar_environment.aruco_detector.detected_markers[selected_marker_id]
# Write selected marker id
- cv2.putText(info_frame, f'Selected marker #{selected_marker.identifier}', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+ cv2.rectangle(info_frame, (0, 0), (1000, 50), selected_marker.color, -1)
+ cv2.putText(info_frame, f'Selected marker #{selected_marker.identifier}', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 1, cv2.LINE_AA)
# Estimate selected marker pose
ar_environment.aruco_detector.estimate_markers_pose([selected_marker_id])
@@ -202,7 +208,7 @@ def main():
# Retreive selected marker place
selected_place = ar_scene.aruco_scene.places[selected_marker_id]
- cv2.putText(info_frame, f'Edited place #{selected_place.marker.identifier}', (520, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+ cv2.putText(info_frame, f'Edited place #{selected_place.marker.identifier}', (520, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 1, cv2.LINE_AA)
# On right click
if right_button:
@@ -244,7 +250,6 @@ def main():
cv2.putText(info_frame, f'{R[1][0]:.3f} {R[1][1]:.3f} {R[1][2]:.3f}', (540, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 1, cv2.LINE_AA)
cv2.putText(info_frame, f'{R[2][0]:.3f} {R[2][1]:.3f} {R[2][2]:.3f}', (540, 240), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 1, cv2.LINE_AA)
-
# Write edited place translation vector
T = edited_place.translation
cv2.putText(info_frame, f'Translation vector:', (520, 320), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
@@ -269,7 +274,7 @@ def main():
aoi_scene_projection = ar_scene.project(tvec, rmat, visual_hfov=TobiiSpecifications.VISUAL_HFOV)
# Draw AOI scene projection with gaze
- aoi_scene_projection.draw_circlecast(video_frame, gaze_position)
+ aoi_scene_projection.draw_circlecast(video_frame, gaze_position, base_color=selected_marker.color, looked_color=selected_marker.color)
# Catch missing selected marker
except KeyError:
@@ -279,7 +284,7 @@ def main():
# No marker selected
else:
- cv2.putText(info_frame, f'Left click on marker to select it', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+ cv2.putText(info_frame, f'Left click on marker to select it', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA)
# Estimate all marker's pose
ar_environment.aruco_detector.estimate_markers_pose()
@@ -287,17 +292,14 @@ def main():
# Check markers consistency
consistent_markers, unconsistent_markers, unconsistencies = ar_scene.aruco_scene.check_markers_consistency(ar_environment.aruco_detector.detected_markers, ar_scene.angle_tolerance, ar_scene.distance_tolerance)
- # Edit marker's color
+ # Set unconsistent marker color to red
for i, m in ar_environment.aruco_detector.detected_markers.items():
-
- m.color = list(itertools.permutations([0, 255, 255]))[i]
-
- # Draw center
- cv2.circle(video_frame, m.center.astype(int), 5, m.color, -1)
-
- # Set unconsistent marker color to red
if i in list(unconsistent_markers.keys()):
m.color = (0, 0, 255)
+
+ # Write unconsistencies
+ for i, (label, value) in enumerate(unconsistencies.items()):
+ cv2.putText(info_frame, f'Unconsistent {label}: {value:.3f}', (20, 120+ i*40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 1, cv2.LINE_AA)
# Single marker scene pose estimation
if pose_mode == 0: