I'm implementing 2D ICP(Iterative Closest Point). I tried to use point-to-point distance but the loss is large.
In fact, the loss between two adjacent frames is acceptable but, for example, when I calculate loss between frame1 and frame20 it becomes large.
I'm trying to replace point-to-point with point-to-plane, but I don't know how to implement it. For point-to-point, I can use SVD like below:
# Compute the centers of both point clouds
p = np.mat([np.average(left1_x), np.average(left1_y)], dtype=np.float64) # Last frame
q = np.mat([np.average(left2_x), np.average(left2_y)], dtype=np.float64) # Current frame
# Compute the matrix
Q = np.zeros((2, 2), dtype=np.float64)
for j in range(len(nearest)):
Q += np.matmul(np.mat([left2_x[j], left2_y[j]]).T - q.T, np.mat([left1_x[j], left1_y[j]]) - p)
U, _, V_T = np.linalg.svd(Q)
# Rotation
R = np.matmul(V_T, U.T)
# Translation
t = p.T - np.matmul(R, q.T)
But for point-to-plane, how can I find the plane from the point cloud and how to calculate rotation and translation matrix?