diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/ArUcoMarkers/ArUcoMarker.py | 2 | ||||
-rw-r--r-- | src/argaze/utils/tobii_segment_aruco_aoi_edit.py | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoMarker.py b/src/argaze/ArUcoMarkers/ArUcoMarker.py index 9d4a53e..ef03ffd 100644 --- a/src/argaze/ArUcoMarkers/ArUcoMarker.py +++ b/src/argaze/ArUcoMarkers/ArUcoMarker.py @@ -34,7 +34,7 @@ class ArUcoMarker(): """Estimated 3D corners positions in camera world referential.""" @property - def center(self, i) -> numpy.array: + def center(self) -> numpy.array: """Get 2D center position in camera image referential.""" return self.corners[0].mean(axis=0) diff --git a/src/argaze/utils/tobii_segment_aruco_aoi_edit.py b/src/argaze/utils/tobii_segment_aruco_aoi_edit.py index 57ac756..2fc1e2b 100644 --- a/src/argaze/utils/tobii_segment_aruco_aoi_edit.py +++ b/src/argaze/utils/tobii_segment_aruco_aoi_edit.py @@ -173,7 +173,7 @@ def main(): right_click = pointer - cv.setMouseCallback(f'Segment {tobii_segment.get_id()} ArUco marker editor', on_mouse_event) + cv.setMouseCallback(f'Segment {tobii_segment.id} ArUco marker editor', on_mouse_event) # Frame selector loop frame_index = 0 @@ -214,18 +214,18 @@ def main(): visu_frame = video_frame.copy() # Draw markers and pose estimation - aruco_tracker.draw(visu_frame.matrix) + aruco_tracker.draw_tracked_markers(visu_frame.matrix) # Project 3D scene on each video frame and the visualisation frame - if aruco_tracker.markers_number(): + if len(aruco_tracker.tracked_markers.keys()) > 0: # Write detected marker ids - cv.putText(visu_frame.matrix, f'Detected markers: {aruco_tracker.get_markers_ids()}', (20, visu_frame.height - 40), cv.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv.LINE_AA) + cv.putText(visu_frame.matrix, f'Detected markers: {list(aruco_tracker.tracked_markers.keys())}', (20, visu_frame.height - 40), cv.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv.LINE_AA) # Update selected marker id by left_clicking on marker - for (i, marker_id) in enumerate(aruco_tracker.get_markers_ids()): + for (marker_id, marker) in aruco_tracker.tracked_markers.items(): - marker_aoi = numpy.array(aruco_tracker.get_marker_corners(i)).view(AOIFeatures.AreaOfInterest) + marker_aoi = marker.corners.reshape(4, 2).view(AOIFeatures.AreaOfInterest) if marker_aoi.looked(left_click): @@ -238,7 +238,7 @@ def main(): try: # Retreive marker index - selected_marker_index = aruco_tracker.get_marker_index(selected_marker_id) + selected_marker = aruco_tracker.tracked_markers[selected_marker_id] if aoi3D_scene == None: raise UserWarning('No AOI 3D scene') @@ -249,7 +249,7 @@ def main(): # Edit scene if aoi3D_scene_edit != None: - marker_x, marker_y = aruco_tracker.get_marker_center(selected_marker_index) + marker_x, marker_y = selected_marker.center if right_button: @@ -300,7 +300,7 @@ def main(): # DON'T APPLY CAMERA DISTORSION : it projects points which are far from the frame into it # This hack isn't realistic but as the gaze will mainly focus on centered AOI, where the distorsion is low, it is acceptable. - aoi2D_video_scene = aoi3D_scene_edited.project(aruco_tracker.get_marker_translation(selected_marker_index), aruco_tracker.get_marker_rotation(selected_marker_index), aruco_camera.get_K()) + aoi2D_video_scene = aoi3D_scene_edited.project(selected_marker.translation, selected_marker.rotation, aruco_camera.K) # Draw aoi scene aoi2D_video_scene.draw_raycast(visu_frame.matrix, gaze_position) @@ -310,7 +310,7 @@ def main(): cv.putText(visu_frame.matrix, f'Marker {selected_marker_id}: {e}', (20, 120), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 1, cv.LINE_AA) - except ValueError: + except KeyError: # Write error if selected_marker_id >= 0: @@ -413,7 +413,7 @@ def main(): force_update = True # Display video - cv.imshow(f'Segment {tobii_segment.get_id()} ArUco marker editor', visu_frame.matrix) + cv.imshow(f'Segment {tobii_segment.id} ArUco marker editor', visu_frame.matrix) # Wait 1 second time.sleep(1) |