Python3网络摄像头输出到全屏

时间:2019-09-16 18:12:37

标签: python-3.x

我是python3的新手,并且正在网上查找一些代码,我试图使网络摄像头屏幕接近全屏,但是我不知道该怎么做。这是我找到的当前代码。

import cv2
import face_recognition

cap = cv2.VideoCapture(0)

# Check if the webcam is opened correctly
if not cap.isOpened():
    raise IOError("Cannot open webcam")

while True:
    ret, frame = cap.read()
    frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
    rgb_frame = frame[:, :, ::-1]
    face_locations = face_recognition.face_locations(rgb_frame)

    for top, right, bottom, left in face_locations:
        cv2.rectangle(frame, (left, top), (right, bottom), (51, 255, 60), 2)
    cv2.imshow('Video', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

我认为我需要将其放入Canvis中。任何帮助都将不胜感激。

0 个答案:

没有答案