嗨,我刚刚开始使用 holoviews,我正在尝试使用 holoviews、opencv 准备一个小型流视频应用程序。我在龙卷风和异步编程方面的经验非常有限。
from holoviews.streams import Pipe, Buffer
from tornado.ioloop import IOLoop
from tornado import gen
import cv2
@gen.coroutine
def f():
pipe = Pipe(data=[])
#print(pipe)
vd = cv2.VideoCapture("TestVideo.mp4")
width = int(vd.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(vd.get(cv2.CAP_PROP_FRAME_HEIGHT))
frames = int(vd.get(cv2.CAP_PROP_FRAME_COUNT))
print("Hello")
for i in range(frames):
ret, frame = vd.read()
#print(i)
try:
rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
gen.sleep(10000000000)
pipe.send(rgb[:])
#print(str(i)+'x')
except:
#print(str(i)+'Error')
print("Error at Frame:"+str(i))
pass
vd.release()
cv2.destroyAllWindows()
IOLoop.current().add_callback(f)
hv.DynamicMap(hv.RGB, streams=[pipe])
我没有得到运行/流式更新。我只得到最后一帧的单个图像。有人可以帮我找出我的错误吗