图像窗口未在OpenCV中的按键上关闭

时间:2015-03-13 17:24:32

标签: python opencv video-capture

我在Python中的OpenCV中有以下代码:

import numpy as np
import cv2

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

video_capture = cv2.VideoCapture(0)

while True:
    # Capture frame-by-frame
    ret, frame = video_capture.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)
    for (x,y,w,h) in faces:
        cv2.rectangle(frame,(x,y),(x+w,y+h),(0, 255, 0), 2)

    cv2.imshow('Video',frame)
    k = cv2.waitKey(10) & 0xFF
    if k==27:
        break


# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()

按下“ESC”按钮时,它没有关闭。我看到了这个文档页面 - http://docs.opencv.org/trunk/doc/py_tutorials/py_gui/py_image_display/py_image_display.html

问题是什么?

0 个答案:

没有答案