-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Bug in fisheye undistortPoints in v3.4.0 and prior #19138
Copy link
Copy link
Closed
Labels
Description
System information (version)
- OpenCV => 3.4.0
- Operating System / Platform => Linux 64 bit
- Compiler => binary from PyPI, but has also been reproduced with gcc 7.5.0
Detailed description
The fisheye::undistortPoints produces different values for the same input data between version 3.4.0 and 3.4.1, and the output in 3.4.0 does not come back to the original points when sent to fisheye::distortPoints (i.e. it does not compute the correct inverse).
In 3.4.1 the undistortion switched to Newtons method from a simple fixed point iteration. Since there is no convergence check in the method, the most likely explanation is that the fixed point iteration does not converge for some input data.
I'm aware that this is an old version by now, but I haven't seen this bug reported anywhere, and it's present in the version of opencv that is installed in Ubuntu 18.04 LTS.
Steps to reproduce
import cv2 as cv
import numpy as np
print("opencv version " + cv.__version__)
T = np.float64
K = np.array([[1, 0, 1],
[0, 1, 1],
[0, 0, 1]], T)
D = np.array([1, 0, 0, 0], T)
original = np.array([[[0.0, 0.0]]], T)
undistorted = cv.fisheye.undistortPoints(original, K, D)
distorted = cv.fisheye.distortPoints(undistorted, K, D)
print("original = " + np.array_str(original))
print("undistorted = " + np.array_str(undistorted))
print("distorted = " + np.array_str(distorted))
print("Error = %.8f" % np.linalg.norm(original.squeeze() - distorted.squeeze(), np.inf) )Output with v3.4.0:
opencv version 3.4.0
original = [[[0. 0.]]]
undistorted = [[[-0.87594343 -0.87594343]]]
distorted = [[[-0.13175599 -0.13175599]]]
Error = 0.13175599
Output with v3.4.1:
opencv version 3.4.1
original = [[[0. 0.]]]
undistorted = [[[-0.77947204 -0.77947204]]]
distorted = [[[0. 0.]]]
Error = 0.00000000
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
answers.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc
Reactions are currently unavailable