Skip to content

Possible mistake in source code of function cv::fisheye::estimateNewCameraMatrixForUndistortRectify #22537

@stefan-spiss

Description

@stefan-spiss
System information (version)
  • OpenCV => 4.x
  • Operating System / Platform => Arch-Linux 64 Bit
  • Compiler => gcc 12.2.0
Detailed description

I had a look at the source code of the function cv::fisheye::estimateNewCameraMatrixForUndistortRectify and I think I found a mistake. In the source file fisheye.cpp in line 614 the optical center point should be converted to identity ratio. But in my understanding to do this, the y coordinate needs to be multiplied by the aspect_ratio and not the x coordinate. To convert all other points to identity ratio the y coordinate is used (see for-loop in lines 615-616). Also later in lines 641-642 the y coordinate is used to restore the aspect ratio of the resulting focal distance and the optical center point.

Code lines 613 - 616:

    // convert to identity ratio
    cn[0] *= aspect_ratio;
    for(size_t i = 0; i < points.total(); ++i)
        pptr[i][1] *= aspect_ratio;

In my opinion correct would be the following:

    // convert to identity ratio
    cn[1] *= aspect_ratio;
    for(size_t i = 0; i < points.total(); ++i)
        pptr[i][1] *= aspect_ratio;
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions