Home > Mobile >  Can anyone help me fix intellisense issues with python's openCV on vsCode
Can anyone help me fix intellisense issues with python's openCV on vsCode

Time:04-08

I am somewhat new to python and I am starting to explore openCV and numpy for object detection. Its 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 and everything, so its not the end of the world, just wondering if anyone could help me fix this issue?

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

This is my first time posting a question on here, so if I need to include some more information, please let me know. Thanks

CodePudding user response:

Python Language Server does not support enter image description here

enter image description here

  • Related