-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
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.pyPylint 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