繁体   English   中英

OpenCV Python视频没有响应

[英]OpenCV Python video doesnt respond

我编写了以下代码,以过滤来自摄像机的视频馈送,从而仅显示光线或反射中的亮点。 当我运行它时,窗口打开,但是它没有响应,什么也没显示。

import cv2
import numpy as np
import keyboard

#Starts capturing video in a VideoCapture object called cap
cap = cv2.VideoCapture(0)

#While the q button is  not pressed, the while loop runs
while not keyboard.is_pressed('q'):
    #ret is a placeholder (not used)
    ret, frame = cap.read()

    #Sets the range of acepted colors in HSV
    whiteRange = np.array([[0, 0, 200], [255, 40, 255]])

    #Blurs the image to remove noise and smooth the details
    gaussianBlur = cv2.GaussianBlur(frame, (5,5), 0)
    #Converts from BGR to HSV to filter colors in the next step
    hsvFrame = cv2.cvtColor(gaussianBlur, cv2.COLOR_BGR2HSV)
    #Filters for white only and turns other colors black
    whiteFilter = cv2.inRange(hsvFrame, whiteRange[0], whiteRange[1])

    #Display the final image
    cv2.imshow('Tape-Detection', whiteFilter)

#Ends the capture and destroys the windows
cap.release()
cv2.destroyAllWindows()

任何建议也都很好,我是OpenCV Python的新手。

没有cv2.imshow()不能使用cv2.waitKey() 等待期间的备用循环用于更新显示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM