2

Context: I have a big 2mx2m arena on which 4 aruco markers are printed, their position from a corner of the arena is known and is fixed. Now I have another aruco marker on a robot moving over this arena. PS the position known are in 2d.

Problem: I want to find the position of the robot in the arena (wrt to the known corner of arena).I am using python for the same, first detecting markers from the image using DetectMarker() then estimating the pose of markers. The tvec values returned by the pose estimation function gives the position of marker wrt to the camera coordinate system, that works fine if the camera is perpendicular to the arena but when the camera is kept at an angle then there is a large error in the position.

Is my approach right? Consider the camera is calibrated well, what is the source of error?

rvec, tvec, _ = aruco.estimatePoseSingleMarkers(corners, actual_size, mtx, dist)
cv2.imshow('img',img) 
index = np.where(ids==0) # getting the known aruco marker


rotation_matrix[:3, :3], _ = cv2.Rodrigues(rvec[index]) # Computing Rotational Matrix 
for i in range(3):
   rotation_matrix[i][3]= tvec[index][0][i]  # Adding Translation Values to it
   inverse_rot = np.linalg.inv(rotation_matrix)  # Inversing the matrix
   for i,j,k in zip(ids,tvec,rvec):
        print(i,'POS:',j)   # prints id and tvec values
        pt[:3] = j.reshape(3,1)  
        rot_point = np.dot(inverse_rot,pt)  # Homogeneous matrix . tvec values
        print(rot_point[:3])  # The new position
        print(np.sqrt(rot_point[0]**2 + rot_point[1]**2 ))  # Distance

rotational_matrix is 4x4 matrix containing rotation, translation, which is used to transfer the coordinate system(from camera system) to one of the markers(known marker on arena, so that marker becomes the origin), and converting other points(tvecs in the camera system) to the marker system.

Homogeneous Coordinate transformation

Arena

  • do you see all the markers in a single image? If yes, you can perform a base-change (camera coordinate system to your arena coordinate system), or, if your scene is mostly planar, you could use perspective homographies to compute the ground coordinate system. – Micka Jun 17 '20 at 22:04
  • @Micka No, all markers may not be visible in a single frame but bot marker and a minimum of 1 reference marker are visible. I am trying to base-change by using the Homogeneous coordinate transformation formula( am not sure if this is the correct way or not), from camera reference system to marker reference(marker id 0) system and then calculating the position of bot marker. – Ayush Patel Jun 18 '20 at 07:38
  • I think it is necessary to reconstruct the arena coordinate system from a single camera image (at least 3 non-colinear arena markers or orientation points necessary?). Or is a single aruco marker pose enough, because you know the orientation of the marker in the arena? – Micka Jun 18 '20 at 08:53
  • @Micka if you take a look at sample arena(it's flat and is required to be placed on the ground) and the camera frame can be any part of it or it completely, I know their(arena markers) orientation and position in the arena (in cm), I want to find out my bot position on the arena(in cm). So basically in arena coordinate system, all the markers should lie on the x-y plane, and z be 0 but due to some projection error or improper calibration it isn't 0, so do you suggest to get more arena marker for better accuracy? – Ayush Patel Jun 18 '20 at 11:25
  • so from a single marker you can reconstruct the arena coordinate system? So if you know that a point is in [x,y] of a single marker coordinate system, you can compute the [X,Y] in global arena coordinate system? – Micka Jun 18 '20 at 11:34
  • @Micka Yes if I know [x,y] of any marker in marker coordinate system, can compute [X,Y] in global arena coordinate system by just adding/subtracting the global arena position of that marker( in single marker coordinate system origin lies at the centre of that particular arena marker).in this example say that the arena marker lies at [20,50] in global arena coordinates, and bot marker is [10,10,0] from that arena marker then the position of the bot in global arena coordinates will be [30,60] – Ayush Patel Jun 18 '20 at 14:04
  • ok, then with the pose of an arena marker in camera coordinates (from solvePnp) and the pose of an object's marker in camera coordinates it will be possible to transform the object to marker coordinate system and from there to arena cordinates. The magic word here is vector basis change – Micka Jun 18 '20 at 14:30
  • @Micka Yes, this is whats happening right now, but i am not using solvePnP to get pose of arena markers, i am getting the pose from the aruco.estimatePoseSingleMarkers() function (it uses solvePnP). Do you think if i do the solvePnP part manually instead of using this function, will give more accuracy? – Ayush Patel Jun 19 '20 at 06:45
  • probabky not but I dont have experience with aruco markers, sorry. – Micka Jun 19 '20 at 06:57

0 Answers0