流保存的OpenCV图像为空

时间:2018-10-21 12:33:08

标签: python file opencv stream save

我想使用ISS的Nasa Stream作为我的桌面背景。

一个解决方案是使用vlc背景模式,但是在我的操作系统(Zorin OS / Ubuntu)上,它只是使一个新窗口的大小达到了屏幕大小,覆盖了所有的桌面快捷方式。那不是我想要的。

我的解决方案是,使用OpenCV的VideoCapture捕获逐帧的Stream,然后每次覆盖我当前的背景图片。

我现在的问题是,我只得到空的图像,图像只是一个空文件

这是我的Python代码:

import numpy as np
import cv2
import time

cap = cv2.VideoCapture("udp://@iphone-streaming.ustream.tv/uhls/17074538/streams/live/iphone/playlist.m3u8")
print("start")
i = 1
while(True):
    ret, frame = cap.read()
    cv2.imwrite("/home/philipp/Bilder/Image.jpg", frame)
    print("saved Image")
    time.sleep(1)
    i += 1

我希望任何人都知道为什么会这样。

预先感谢您的帮助

0 个答案:

没有答案