'Least squares solution for uneven point sets

The standard least-squares problem is easy to solve with singular value decomposition (SVD), and there exists a closed form solution. It is for example used in the 8-point algorithm for extrinsic camera calibration. Here is a quick visualization of the problem.

enter image description here

But my problem is a little different. I could solve it iteratively, but I would prefer (if possible) a closed form solution.
My problem is that I do not have equal number of points in both coordinate system. I would argue, a least squares solution does still exist. So is this also possible to derive this mathematically? I am afraid my mathematical talent does not cover this derivation.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source