gpt4 book ai didi

python - 使用OpenCV时永远弹跳Python Rocket

转载 作者:行者123 更新时间:2023-12-02 17:09:31 25 4
gpt4 key购买 nike

我正在使用的Python版本是MacOS Sierra上的Python 2.7.13,并且我还将OpenCV 3与Python一起使用。

while True:
frame = read_stream()
# some manipulation on `frame`
cv2.imshow("Screen", frame)

在这里,我尝试显示来自套接字流的显示帧。第一次它运行良好,但是由于某种原因,下一次我尝试运行它时,扩展坞中的Python火箭飞船图标一直在向上和向下跳动,并且窗口无法打开。

enter image description here

从我正在打印的日志来看,框架正逐渐成形。

这可能是什么原因?我只是想不出原因。

最佳答案

从文档:

Note: This function should be followed by waitKey function which displays the image for specified milliseconds. Otherwise, it won’t display the image. For example, waitKey(0) will display the window infinitely until any keypress (it is suitable for image display). waitKey(25) will display a frame for 25 ms, after which display will be automatically closed. (If you put it in a loop to read videos, it will display the video frame-by-frame)



据推测,添加waitKey(20)将为您提供一个不错的50Hz流,但是您可以根据需要调整该值。

编辑:正如您第一次说的那样,我在这里可能走错了路。如果是这种情况,我将删除答案,然后我们将研究图像窗口“屏幕”的定义...

关于python - 使用OpenCV时永远弹跳Python Rocket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46361110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com