opencv / opencv/opencv-python

Typing of compare does not allow scalar for src1 or src2

Open
#1,008 0 comments 0 reactions 1 assignee View on GitHub

@VadimLevin is already working on this.

Since Aug 6, 2024.

Dominant language
Python
Stars
5.4k
Forks
1k
Avg merge
22h 17m
Merged PRs (30d)
3

Description

Expected behaviour

The following code should be shown as valid:
cv2.compare(some_array, 10, cv2.CMP_EQ)

Although the docs for compare show the type of src1 and src2 to be InputArray, the description of the parameters says "input array or a scalar; when it is an array, it must have a single channel" and passing an int does work.

Actual behaviour

The int (10) is shown as a error because the pyi only allows src1 and src2 to be UMat/MatLike.

Steps to reproduce
  • example code: above code shows this error
  • opencv-python version: 4.10.0.84
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.