@@ -21,7 +21,9 @@ def __init__(self, camera_name: str):
2121 # base frame to camera, world to base frame
2222 self ._extrinsics : np .ndarray [tuple [typing .Literal [4 ], typing .Literal [4 ]], np .dtype [np .float64 ]] | None = None
2323 self .camera_name = camera_name
24- self .tag_to_world = common .Pose (rpy_vector = [np .pi , 0 , - np .pi / 2 ], translation = [0.145 , 0 , 0 ]).pose_matrix ()
24+ self .tag_to_world = common .Pose (
25+ rpy_vector = np .array ([np .pi , 0 , - np .pi / 2 ]), translation = np .array ([0.145 , 0 , 0 ])
26+ ).pose_matrix ()
2527
2628 def calibrate (
2729 self ,
@@ -46,13 +48,11 @@ def calibrate(
4648 frames .append (sample .camera .color .data .copy ())
4749 print (frames )
4850
49- last_frame , tag_to_cam = get_average_marker_pose (
50- frames , intrinsics = intrinsics , calib_tag_id = 9 , show_live_window = True
51- )
51+ _ , tag_to_cam = get_average_marker_pose (frames , intrinsics = intrinsics , calib_tag_id = 9 , show_live_window = False )
5252
5353 cam_to_world = self .tag_to_world @ np .linalg .inv (tag_to_cam )
5454 world_to_cam = np .linalg .inv (cam_to_world )
55- self ._extrinsics = world_to_cam
55+ self ._extrinsics = world_to_cam # type: ignore
5656 return True
5757
5858 def get_extrinsics (self ) -> np .ndarray [tuple [typing .Literal [4 ], typing .Literal [4 ]], np .dtype [np .float64 ]] | None :
@@ -82,8 +82,7 @@ def get_average_marker_pose(
8282 continue
8383
8484 for corner in marker_det .corners :
85- corner = corner .astype (int )
86- cv2 .circle (frame , tuple (corner ), 5 , (0 , 0 , 255 ), - 1 )
85+ cv2 .circle (frame , tuple (corner .astype (int )), 5 , (0 , 0 , 255 ), - 1 )
8786
8887 poses .append (pose )
8988
@@ -92,7 +91,7 @@ def get_average_marker_pose(
9291 camera_matrix = intrinsics [:3 , :3 ]
9392
9493 if show_live_window :
95- cv2 .drawFrameAxes (frame , camera_matrix , None , pose [:3 , :3 ], pose [:3 , 3 ], 0.1 )
94+ cv2 .drawFrameAxes (frame , camera_matrix , None , pose [:3 , :3 ], pose [:3 , 3 ], 0.1 ) # type: ignore
9695 # show frame
9796 cv2 .imshow ("frame" , frame )
9897
@@ -107,12 +106,9 @@ def get_average_marker_pose(
107106 cv2 .destroyAllWindows ()
108107
109108 # calculate the average marker pose
110- poses = np .array (poses )
111109 avg_pose = np .mean (poses , axis = 0 )
112110 logger .info (f"Average pose: { avg_pose } " )
113111
114- # paint avg pose on last frame
115- # cv2.drawFrameAxes(last_frame, camera_matrix, None, avg_pose[:3, :3], avg_pose[:3, 3], 0.1) # type: ignore
116112 return last_frame , avg_pose
117113
118114
0 commit comments