Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV Members are not recognized #10027

Open
LambdaScorpii opened this issue Oct 16, 2024 · 1 comment
Open

OpenCV Members are not recognized #10027

LambdaScorpii opened this issue Oct 16, 2024 · 1 comment
Labels
Lib specific 💅 This affect the code from a particular library Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@LambdaScorpii
Copy link

LambdaScorpii commented Oct 16, 2024

Bug description

when working with cv2 and saving files, PyLint does complain it cannot find the cv2 members, hence, flooding the Problems tab with messages, which are in fact no problem at all. Below is a MWE to reproduce some of the messages.

"""Minimum Working Example showing the issue that PyLint does not recognize cv2 Members"""

import cv2

cap = cv2.VideoCapture("test.mp4")
background_substractor = cv2.createBackgroundSubtractorMOG2()

ret, frame = cap.read()
foreground_mask = background_substractor.apply(frame)
contours, hierarchy = cv2.findContours(
    foreground_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
)

cv2.destroyAllWindows()
cap.release()

Configuration

No response

Command used

VSCode PyLint Extension

pylint --reports=n --output-format=json --clear-cache-post-run=y --from-stdin opencv_mwe_pylint_err.py

Pylint output

[
{
"type": "error",
"module": "object_tracker.opencv_mwe_pylint_err",
"obj": "",
"line": 5,
"column": 6,
"endLine": 5,
"endColumn": 22,
"path": "poc\object_tracker\opencv_mwe_pylint_err.py",
"symbol": "no-member",
"message": "Module 'cv2' has no 'VideoCapture' member",
"message-id": "E1101"
},
{
"type": "error",
"module": "object_tracker.opencv_mwe_pylint_err",
"obj": "",
"line": 6,
"column": 25,
"endLine": 6,
"endColumn": 59,
"path": "poc\object_tracker\opencv_mwe_pylint_err.py",
"symbol": "no-member",
"message": "Module 'cv2' has no 'createBackgroundSubtractorMOG2' member",
"message-id": "E1101"
},
{
"type": "error",
"module": "object_tracker.opencv_mwe_pylint_err",
"obj": "",
"line": 11,
"column": 22,
"endLine": 11,
"endColumn": 38,
"path": "poc\object_tracker\opencv_mwe_pylint_err.py",
"symbol": "no-member",
"message": "Module 'cv2' has no 'findContours' member",
"message-id": "E1101"
},
{
"type": "error",
"module": "object_tracker.opencv_mwe_pylint_err",
"obj": "",
"line": 12,
"column": 21,
"endLine": 12,
"endColumn": 38,
"path": "poc\object_tracker\opencv_mwe_pylint_err.py",
"symbol": "no-member",
"message": "Module 'cv2' has no 'RETR_EXTERNAL' member",
"message-id": "E1101"
},
{
"type": "error",
"module": "object_tracker.opencv_mwe_pylint_err",
"obj": "",
"line": 12,
"column": 40,
"endLine": 12,
"endColumn": 63,
"path": "poc\object_tracker\opencv_mwe_pylint_err.py",
"symbol": "no-member",
"message": "Module 'cv2' has no 'CHAIN_APPROX_SIMPLE' member",
"message-id": "E1101"
},
{
"type": "error",
"module": "object_tracker.opencv_mwe_pylint_err",
"obj": "",
"line": 15,
"column": 0,
"endLine": 15,
"endColumn": 21,
"path": "poc\object_tracker\opencv_mwe_pylint_err.py",
"symbol": "no-member",
"message": "Module 'cv2' has no 'destroyAllWindows' member",
"message-id": "E1101"
}
]

Expected behavior

PyLint should recognize all members in the cv2 module.

Pylint version

pylint 3.2.7
astroid 3.2.4
Python 3.12.7

OS / Environment

Windows 11
Ubuntu 24.04
Raspberry Pi OS with desktop
Release date: July 4th 2024
System: 32-bit
Kernel version: 6.6
Debian version: 12 (bookworm)

Additional dependencies

opencv-python==4.10.0.84

@LambdaScorpii LambdaScorpii added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 16, 2024
@LambdaScorpii
Copy link
Author

Edit

Tested it without being an extension, by directly installing the latest version. Seems to cause the same issue, though:

pylint --version

pylint 3.3.1
astroid 3.3.5
Python 3.12.7 (tags/v3.12.7:0b05ead, Oct 1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)]

pylint opencv_mwe_pylint_err.py

************* Module object_tracker.opencv_mwe_pylint_err
opencv_mwe_pylint_err.py:5:6: E1101: Module 'cv2' has no 'VideoCapture' member (no-member)
opencv_mwe_pylint_err.py:6:25: E1101: Module 'cv2' has no 'createBackgroundSubtractorMOG2' member (no-member)
opencv_mwe_pylint_err.py:10:22: E1101: Module 'cv2' has no 'findContours' member (no-member)
opencv_mwe_pylint_err.py:11:21: E1101: Module 'cv2' has no 'RETR_EXTERNAL' member (no-member)
opencv_mwe_pylint_err.py:11:40: E1101: Module 'cv2' has no 'CHAIN_APPROX_SIMPLE' member (no-member)
opencv_mwe_pylint_err.py:14:0: E1101: Module 'cv2' has no 'destroyAllWindows' member (no-member)


Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

"""Minimum Working Example showing the issue that PyLint does not recognize cv2 Members"""

import cv2

cap = cv2.VideoCapture("test.mp4")
background_substractor = cv2.createBackgroundSubtractorMOG2()

ret, frame = cap.read()
foreground_mask = background_substractor.apply(frame)
contours, hierarchy = cv2.findContours(
    foreground_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
)

cv2.destroyAllWindows()
cap.release()

@Pierre-Sassoulas Pierre-Sassoulas added the Lib specific 💅 This affect the code from a particular library label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lib specific 💅 This affect the code from a particular library Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

2 participants