I need to align two (actually hundreds of) images and I'm at a loss on how to do that in Python with OpenCV (which I have never heard of before). It looks like I should first estimate the transformation to apply as follows, and then apply it to one of the image (rinse and repeat hundreds of times). However even the simplest
import cv2img1 = cv2.imread("img1.jpg", cv2.IMREAD_COLOR)img2 = cv2.imread("img2.jpg", cv2.IMREAD_COLOR)cv2.estimateAffinePartial2D(img1, img2)
fails with
cv2.error: OpenCV(4.9.0) /io/opencv/modules/calib3d/src/ptsetreg.cpp:1108: error: (-215:Assertion failed) count >= 0 && to.checkVector(2) == count in function 'estimateAffinePartial2D'
Stack overflow and OpenCV forum has a few questions about this problem but no solution, other than the one mentioned at OpenCV estimateAffine3D failes with cryptic error message (which is even more cryptic than the error message itself).
How to do that estimation in Python?
EDIT:
$ pythonPython 3.8.18 (default, Aug 25 2023, 13:20:30) [GCC 11.4.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import cv2>>> cv2.__version__'4.9.0'