Skip to content

'warpAffine' different behaviour with version 4.12 and 4.13 #1207

@DylanMMarques

Description

@DylanMMarques

Hello,

warpAffine has different behaviour in version 4.12 and 4.13.

import numpy as np
import cv2
input = np.ones((100,100))
pts = np.float32([[1,1],
                  [1,2],
                  [3,4]])
translation_factor = 50
t_cv2 = cv2.getAffineTransform(pts, pts+translation_factor)
out = cv2.warpAffine(
    input,
    t_cv2,
    (200,200),
    flags=cv2.INTER_NEAREST,
    borderMode=cv2.BORDER_CONSTANT,
    borderValue=(0.0,),
)

with:

Package       Version
------------- ---------
numpy         2.2.6
opencv-python 4.12.0.88
pip           24.0
setuptools    79.0.1

Image of out:
Image

with:

Package       Version
------------- ---------
numpy         2.4.2
opencv-python 4.13.0.92
pip           24.0
setuptools    79.0.1

Image of out:
Image

The issue is that in version 4.13, warpAffine translates the image by -translation_factor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions