At work I had to make a custom image registration pipeline, that uses only 2 degrees of freedom, so just x,y translation. OpenCV did not have anything that did this, but a python library called Kornia does this well.
It can do dense translation, translation + rotation, Affine, and Homography alignment; I've used it in the past to do sub-pixel Aruco/AprilTag alignment (and I'd probably also use it for astrophotography).
https://kornia-tutorials.readthedocs.io/en/latest/image_regi...