Reputation: 23
I am trying to calculate the distance between two Aruco markers in Python. I have code that can calculate the pose of one marker but I am not sure how to move from there. Is there anyone that has done something similar or can point me in the right direction?
Thank you!
Upvotes: 2
Views: 1736
Reputation: 142
You can find the distance between the markers by calculating the distance between the corners of the detected markers. The following will give you the corners and the co-ordinates of that corner.
corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict, parameters=arucoParameters)
x1 = int (corners[0][0][0][0])
y1 = int (corners[0][0][0][1])
Similarly you can find the co-ordinates of the corner of the other marker (x2,y2).
import math
def calculateDistance(x1,y1,x2,y2):
dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
return dist
print calculateDistance(x1, y1, x2, y2)
This code will give the distance between the two corners
Upvotes: 2