OpenCV 找不到网络摄像头的 VideoCapture 或在 Windows 10 上显示

OpenCV does not find VideoCapture for webcam or show on Windows 10

读取数据时不显示网络摄像头捕获

我为 0 和 700 作为参数尝试了 video_capture= cv2.VideoCapture() 方法,因为有建议并且发生了这种情况:

=======

import cv2

# Create an object. 700 for my external camera
video_capture = cv2.VideoCapture(700)
video_capture.set(cv2.CAP_PROP_FRAME_WIDTH,640)
video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT,480)

faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')


while True:

    ret, frame = video_capture.read()

    #Check if the video is being read
    if ret == False:
        print("Connection Failed!")
    else:

        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        faces = faceCascade.detectMultiScale(
            gray,
            scaleFactor=1.1,
            minNeighbors=5,
            minSize=(30, 30),
            flags=cv2.CASCADE_SCALE_IMAGE
        )

        # Draw a rectangle around the faces
        for (x, y, w, h) in faces:
            cv2.rectangle(gray, (x, y), (x+w, y+h), (0, 255, 0), 2)

        # Display the resulting frame
        cv2.imshow('Video', gray)
        
        if cv2.waitKey(1)==ord('e'):
            break

video_capture.release()
cv2.destroyAllWindows()

卡巴斯基似乎阻止了我在终端 运行 代码上的实时网络摄像头捕获 pycharm 我已经启用,运行 使用 Python 控制台。现在一切正常。 Pycharm Console Config

如果您使用任何具有本地设备控制或集中设备控制的防病毒软件,就会出现此问题。请检查您的防病毒软件并禁用设备控制。