Skip to content

fix: mark distCoeffs/R/D as optional Python type stubs for calib3d functions#27564

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
inventshah:refine-calib3d-distCoeffs-py-type
Aug 1, 2025
Merged

fix: mark distCoeffs/R/D as optional Python type stubs for calib3d functions#27564
asmorkalov merged 1 commit intoopencv:4.xfrom
inventshah:refine-calib3d-distCoeffs-py-type

Conversation

@inventshah
Copy link
Copy Markdown
Contributor

Fixes #27563. Extends make_optional_arg to support making multiple arguments optional, and overload sets with different parameter names (for findEssentialMat).

Example before patch:

def getOptimalNewCameraMatrix(cameraMatrix: cv2.typing.MatLike, distCoeffs: cv2.typing.MatLike, imageSize: cv2.typing.Size, alpha: float, newImgSize: cv2.typing.Size = ..., centerPrincipalPoint: bool = ...) -> tuple[cv2.typing.MatLike, cv2.typing.Rect]: ...

Example after patch:

def getOptimalNewCameraMatrix(cameraMatrix: cv2.typing.MatLike, distCoeffs: cv2.typing.MatLike | None, imageSize: cv2.typing.Size, alpha: float, newImgSize: cv2.typing.Size = ..., centerPrincipalPoint: bool = ...) -> tuple[cv2.typing.MatLike, cv2.typing.Rect]: ...

I wonder if introducing a new modifier, to the effect of "argument is nullable", in C++ would be better than adding these API refinements...

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@inventshah
Copy link
Copy Markdown
Contributor Author

CI failure looks unrelated -- in videoio tests on Linux x64 Debug

@inventshah inventshah force-pushed the refine-calib3d-distCoeffs-py-type branch from 9d7bce8 to fe211f0 Compare July 28, 2025 00:06
@inventshah inventshah force-pushed the refine-calib3d-distCoeffs-py-type branch from fe211f0 to 4ba3d47 Compare July 28, 2025 13:40
@asmorkalov asmorkalov merged commit ca053bb into opencv:4.x Aug 1, 2025
52 of 55 checks passed
@asmorkalov asmorkalov mentioned this pull request Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calib3d functions missing | None on distCoeffs in Python type stubs

3 participants