Skip to content

feat: add highgui functions to typing stubs#24061

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
VadimLevin:dev/vlevin/python-typing-highgui-refinement
Jul 26, 2023
Merged

feat: add highgui functions to typing stubs#24061
asmorkalov merged 1 commit intoopencv:4.xfrom
VadimLevin:dev/vlevin/python-typing-highgui-refinement

Conversation

@VadimLevin
Copy link
Copy Markdown
Contributor

@VadimLevin VadimLevin commented Jul 26, 2023

Manually add typing stubs for functions defined in cv2_highgui.hpp:

  • createTrackbar

     def createTrackbar(trackbarName: str,
                   windowName: str,
                   value: int,
                   count: int,
                   onChange: Callable[[int], None]) -> None: ...
  • createButton

    def createButton(buttonName: str,
                     onChange: Callable[[tuple[int] | tuple[int, Any]], None],
                     userData: Any | None = ...,
                     buttonType: int = ...,
                     initialButtonState: int = ...) -> None: ...
  • setMouseCallback

    def setMouseCallback(
        windowName: str,
        onMouse: Callback[[int, int, int, int, Any | None], None],
        param: Any | None = ...
    ) -> None: ...

closes opencv/opencv-python#875

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

Manually add typing stubs for functions defined in `cv2_highgui.hpp`:
- `createTrackbar`

    ```python
     def createTrackbar(trackbarName: str,
                   windowName: str,
                   value: int,
                   count: int,
                   onChange: Callable[[int], None]) -> None: ...
    ```

- `createButton`

    ```python
    def createButton(buttonName: str,
                     onChange: Callable[[tuple[int] | tuple[int, Any]], None],
                     userData: Any | None = ...,
                     buttonType: int = ...,
                     initialButtonState: int = ...) -> None: ...
    ```

- `setMouseCallback`

    ```python
    def setMouseCallback(
        windowName: str,
        onMouse: Callback[[int, int, int, int, Any | None], None],
        param: Any | None = ...
    ) -> None: ...
    ```
@VadimLevin VadimLevin added this to the 4.9.0 milestone Jul 26, 2023
@VadimLevin VadimLevin requested a review from asmorkalov July 26, 2023 13:39
@VadimLevin VadimLevin self-assigned this Jul 26, 2023
@asmorkalov
Copy link
Copy Markdown
Contributor

cc @slooi

@asmorkalov asmorkalov merged commit 91749a2 into opencv:4.x Jul 26, 2023
@asmorkalov asmorkalov mentioned this pull request Jul 27, 2023
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.

No type hints for cv2.createTrackbar function in 4.8.0.74

2 participants