# cv2.findTransformECC() (sometimes) missing defaults

**URL:** <https://forum.opencv.org/t/cv2-findtransformecc-sometimes-missing-defaults/1870>\
**Category:** Python\
**Created:** [March 1, 2021, 1:06am UTC](https://forum.opencv.org/t/cv2-findtransformecc-sometimes-missing-defaults/1870 "2021-03-01T01:06:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtonti](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jtonti](https://forum.opencv.org/u/jtonti)\
**Post date:** [March 1, 2021, 1:06am UTC](https://forum.opencv.org/t/cv2-findtransformecc-sometimes-missing-defaults/1870/1 "2021-03-01T01:06:47Z")

</div>

It seems there might be a confusion among developers with allowing default parameters in the rather incredibly useful function cv2.findTransformECC(). (This has been going on since at least 2017.)

This function can automatically create an affine and even a perspective-distorting transform (a warp) between two images which can then be applied using cv2.warpPerspective() or cv2.warpAffine() to make them the same. (See [Learn openCV: Image Alignment (ECC) in OpenCV ( C++ / Python )](https://learnopencv.com/image-alignment-ecc-in-opencv-c-python/) for an excellent example.

The problem is that in several older versions of openCV and the version I’m currently using ‘4.5.1’ under Windows 10 Python 3.7.0 fails when the documented ‘optional’ arguments 6 or 7 are missing.  
When both arguments 6 and 7 are missing (as shown in nearly every example instantiation), this error is thrown:

> TypeError: findTransformECC() missing required argument ‘inputMask’ (pos 6)

When argument 7 is missing this error is thrown:

> TypeError: findTransformECC() missing required argument ‘gaussFiltSize’ (pos 7)

The help() documentation shows:

> …  
> inputMask An optional mask to indicate valid values of inputImage.  
> gaussFiltSize An optional value indicating size of gaussian blur filter; (DEFAULT: 5)

Note that the help (or the documentation) does not specify a default for inputMask. Specifying _None_ will satisfy this argument.  
The default (which sometimes isn’t applied if the argument 7 is missing) is specified as _5_, and applying an **odd** integer value here will satisfy.

Example:

> (correlationCoefficient, warp\_matrix) = cv2.findTransformECC(img0, img1, warp\_matrix, warp\_mode, tform\_termination\_criterial\_list, None, 15)

Good luck, and happy warping!

-Jim

---

<div class="post-metadata">

**Author:** ![laurent.berger](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@laurent.berger](https://forum.opencv.org/u/laurent.berger)\
**Post date:** [March 1, 2021, 11:24am UTC](https://forum.opencv.org/t/cv2-findtransformecc-sometimes-missing-defaults/1870/2 "2021-03-01T11:24:40Z")

</div>

Hi,  
You can post an issue

---

<div class="post-metadata">

**Author:** ![Supra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/supra/32/91_2.png) [@Supra](https://forum.opencv.org/u/Supra)\
**Post date:** [March 1, 2021, 12:39pm UTC](https://forum.opencv.org/t/cv2-findtransformecc-sometimes-missing-defaults/1870/3 "2021-03-01T12:39:11Z")

</div>

```auto
(correlationCoefficient, warp_matrix) = cv2.findTransformECC(img0, img1, warp_matrix, warp_mode, tform_termination_criterial_list, inputMask=None, gaussFiltSize=15)

```

---

<div class="post-metadata">

**Author:** ![Supra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/supra/32/91_2.png) [@Supra](https://forum.opencv.org/u/Supra)\
**Post date:** [March 1, 2021, 1:07pm UTC](https://forum.opencv.org/t/cv2-findtransformecc-sometimes-missing-defaults/1870/5 "2021-03-01T13:07:06Z")

</div>

If u’re encountered problem in postion 6. U can remove **inputMask=**

---

<div class="post-metadata">

**Author:** ![laurent.berger](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@laurent.berger](https://forum.opencv.org/u/laurent.berger)\
**Post date:** [March 1, 2021, 4:40pm UTC](https://forum.opencv.org/t/cv2-findtransformecc-sometimes-missing-defaults/1870/6 "2021-03-01T16:40:40Z")

</div>

I wrote a [PR](https://github.com/opencv/opencv/pull/19651) (two characters)  
It is merged now. You can build opencv and python binding yourself using cmake or wait for next opencv python release.
