image_stacking icon indicating copy to clipboard operation
image_stacking copied to clipboard

Missing required argument in cv2.findTransformECC()

Open virtualritz opened this issue 6 years ago • 2 comments

Traceback (most recent call last):
  File "auto_stack.py", line 121, in <module>
    stacked_image = stackImagesECC(file_list)
  File "auto_stack.py", line 25, in stackImagesECC
    s, M = cv2.findTransformECC(cv2.cvtColor(image,cv2.COLOR_BGR2GRAY), first_image, M, cv2.MOTION_HOMOGRAPHY)
TypeError: findTransformECC() missing required argument 'criteria' (pos 5)

virtualritz avatar Oct 31 '19 16:10 virtualritz

I had the same Problem!

wschwack avatar Nov 15 '19 11:11 wschwack

It seems that OpenCV made a pretty big change to their API. Here's a fix that worked for me.

ITER = 10000
eps = 1e-10
criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, ITER,  EPS)

try:
    cc, warp_matrix = cv2.findTransformECC(cv2.cvtColor(image,cv2.COLOR_BGR2GRAY), first_image, M, cv2.MOTION_HOMOGRAPHY, 
                                           criteria, inputMask=None, gaussFiltSize=1)
except TypeError:
    cc, warp_matrix = cv2.findTransformECC(cv2.cvtColor(image,cv2.COLOR_BGR2GRAY), first_image, M, cv2.MOTION_HOMOGRAPHY, criteria)

tyler-a-cox avatar Apr 30 '20 17:04 tyler-a-cox