aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-04-29 22:27:24 +0200
committerThéo de la Hogue2023-04-29 22:27:24 +0200
commit7d4efc5160b47e6e586e4d69ae6f86af3af802a4 (patch)
tree757fdb5f2f4a8c4653d537f1a672c20328856ffc
parent97bfe8aa03751d1bc8552277c6935b2763fa2446 (diff)
downloadargaze-7d4efc5160b47e6e586e4d69ae6f86af3af802a4.zip
argaze-7d4efc5160b47e6e586e4d69ae6f86af3af802a4.tar.gz
argaze-7d4efc5160b47e6e586e4d69ae6f86af3af802a4.tar.bz2
argaze-7d4efc5160b47e6e586e4d69ae6f86af3af802a4.tar.xz
Highlithing hovered marker.
-rw-r--r--src/argaze/utils/environment_edit.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/argaze/utils/environment_edit.py b/src/argaze/utils/environment_edit.py
index 6b2c354..aa208e5 100644
--- a/src/argaze/utils/environment_edit.py
+++ b/src/argaze/utils/environment_edit.py
@@ -106,6 +106,7 @@ def main():
# Init marker selection
selected_marker_id = -1
+ hovered_marker_id = -1
# Init place edition
place_edit = {}
@@ -142,6 +143,9 @@ def main():
# Detect markers
ar_environment.aruco_detector.detect_markers(video_frame)
+ # Write detected markers
+ cv2.putText(video_frame, f'{list(ar_environment.aruco_detector.detected_markers.keys())}', (20, frame_height-80), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+
# Draw gray panel on top
cv2.rectangle(video_frame, (0, 0), (frame_width, 50), (63, 63, 63), -1)
@@ -165,19 +169,22 @@ def main():
# Handle marker selection on left click
if len(ar_environment.aruco_detector.detected_markers) > 0:
- # Update selected marker id by left clicking on marker
+ # Update selected and hovered markers id
+ selected_marker_id = -1
+ hovered_marker_id = -1
for (marker_id, marker) in ar_environment.aruco_detector.detected_markers.items():
marker_aoi = marker.corners.reshape(4, 2).view(AOIFeatures.AreaOfInterest)
+ # Select by left clicking on marker
if marker_aoi.contains_point(left_click):
selected_marker_id = marker_id
- break
-
- else:
- selected_marker_id = -1
+ # Hover by pointing on marker
+ if marker_aoi.contains_point(pointer):
+
+ hovered_marker_id = marker_id
# Edit marker's color
color_list = list(itertools.permutations([0, 255, 255]))
@@ -186,7 +193,12 @@ def main():
m.color = color_list[i%len(color_list)]
- if selected_marker_id >= 0 and i != selected_marker_id:
+ if i == selected_marker_id or i == hovered_marker_id:
+ continue
+
+ if hovered_marker_id > 0:
+ m.color = (0, 0, 0)
+ else:
m.color = (127, 127, 127)
# Draw center
@@ -322,10 +334,13 @@ 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)
- # Set unconsistent marker color to red
- for i, m in ar_environment.aruco_detector.detected_markers.items():
- if i in list(unconsistent_markers.keys()):
- m.color = (0, 0, 255)
+ # No marker hovered
+ if hovered_marker_id < 0:
+
+ # Set unconsistent marker color to red
+ for i, m in ar_environment.aruco_detector.detected_markers.items():
+ if i in list(unconsistent_markers.keys()) and i != hovered_marker_id:
+ m.color = (0, 0, 255)
# Write unconsistencies
line = 0