'How can I fix Intellisense issues with Python's openCV on vsCode
I am somewhat new to Python and I am starting to explore openCV and numpy for object detection. It's all going well and I understand it well, however I am using vsCode and when I initialize the value:
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
the autocomplete/Intellisense does not render in the future. For example when I try:
ret, frame = cap.read()
on line 10 or
cap.release()
on line 27, it does register as being a correct function. The code all still works, so it's not the end of the world, just wondering if this issue can be fixed?
All code:
import cv2
import numpy as np
lowerBound = np.array([15, 150, 20])
upperBound = np.array([35, 255, 255])
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
while 1:
ret, frame = cap.read()
image = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
mask = cv2.inRange(image, lowerBound, upperBound)
cnts, heirarchy = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
if len(cnts) != 0:
for c in cnts:
if cv2.contourArea(c) > 500:
x, y, w, h = cv2.boundingRect(c)
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 3)
cv2.imshow("mask", mask)
cv2.imshow("cam", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
cap.release()
cv2.destroyAllWindows
break
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steven-MSFT |


