opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

Wrong return type in the python bindings of `MaperGrad*.calculate` methods

Open vlsd opened this issue 3 years ago • 0 comments

System information (version)
  • OpenCV => opencv-contrib-python==4.6.0.66
  • Operating System / Platform => macOS Monterey, version 12.4
  • Compiler => Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Detailed description

Based on the documentation, I expect that calling reg.MapperGradShift.calculate(img1, img2) would return a MapShift object, on which I can call .getShift() to obtain the estimated shift.

The function instead returns a Map object, which is a base abstract class, and does not have the .getShift() method or any information stored about the estimated transformation that was just calculated.

As a workaround, I can wrap my mapper into a MapperPyramid object, call calculate on that, and cast the result to a MapShift object using reg.MapTypeCaster. However, from reading the documentation, this doesn't seem to be necessary.

  • operating system:
  • architecture: arm64 (Apple M1 Pro)
  • opencv-python version:
Steps to reproduce

The image can be anything, it doesn't matter.

import cv2 as cv

img1 = cv.imread('image.jpg')
img2 = cv.imread('image.jpg')

mapper = cv.reg.MapperGradShift()
map = mapper.calculate(img1, img2)

print(map.getShift())

will result in an AttributeError() since the map object doesn't have the getShift() method.

Issue submission checklist
  • [x] I report the issue, it's not a question
  • [x] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • [x] I updated to the latest OpenCV version and the issue is still there
  • [x] There is reproducer code and related data files: videos, images, onnx, etc

vlsd avatar Aug 01 '22 22:08 vlsd