I am trying to detect a chessboard using 8 aruco markers, opencv and python. The marker detection works fine, but as soon as a player makes a move, at least one of the markers will usually be covered by their arm. Since most of the markers can still be detected, an estimation of the point given the position of the other markers should be possible. To illustrate my setup I have linked a picture. Correct Marker Points
My first attempts to predict a missing point were to try to compute the unknown transition matrix from world to image space. To represent the 8 marker corner positions the world space coordinates [1,0,0], [1,50,0], [1,75,0], [1,100,0], [1,0,100], [1,0,50], [1,75,100] and [1,100,100] were used. These are therefore always known and represented by matrix W. The screen space coordinates of the marker points are computed by opencv and represented by matrix S. For the sake of argument, lets pretend one marker was not detected and the point needs to be estimated. The transformation matrix from W to S (i.e. solving W * X = S for X) was then computed for the given 7 points and to estimate the missing point the world space coordinates were multiplied with X. The problem is that X does not incorporate the perspective transformation and therefore incorrectly projects an estimated point. To illustrate this a second picture is linked where all points were correctly detected, but are then projected by the projection matrix X. Incorrect Marker Points
A quick snippet of python code which shows how X is computed and points projected:
ids = [81,277,939,275,683,677,335,981]
corner_world_coord = {
683: [1,0,0],
275: [1,50,0],
939: [1,75,0],
81: [1,100,0],
335: [1,0,100],
677: [1,50,100],
277: [1,75,100],
981: [1,100,100]
}
W = [corner_world_coord[i] for i in ids]
S = [aruco_corners[i] for i in ids]
X, res, _, _ = np.linalg.lstsq(W,S)
estimate = np.zeros(len(ids))
for idx, corner in enumerate(W):
estimate[idx] = np.dot(corner,X)
The residual of the least square error computation of X is always equal to 0. My question therefore is, is there a way to compute the screen coordinates of a missing point, given the world space and screen space coordinates of multiple other points?