【发布时间】:2019-08-02 18:27:41
【问题描述】:
我有一组从视频中提取的边缘图像(使用cv2.Canny)。所以数组的大小是TxHxW。其中T是时间步长,后面的参数是高度和宽度。
目前我在 Jupyter Notebook 上显示输出的方式是使用以下代码:
from IPython.display import HTML
import imageio
imageio.mimwrite('test2.mp4', edges, fps=30)
HTML("""
<video width="480" height="360" controls>
<source src="{0}">
</video>
""".format('./test2.mp4'))
我觉得写入文件可能是不必要的,并且可能有更好的方法。如果有请告诉我。重点是在 Jupyter notebook 中显示。
如果您需要测试用例,请让edges = np.random.randn(100, 80, 80)。
解决方案 1:
感谢下面@Alleo 的评论。使用 Ipython 7.6+,您可以执行以下操作:
import imageio;
from IPython.display import Video;
imageio.mimwrite('test2.mp4', edges, fps=30);
Video('test2.mp4', width=480, height=360) #the width and height option as additional thing new in Ipython 7.6.1
这仍然需要您写入文件。
【问题讨论】:
-
我想你想用
import imageio; from IPython.display import Video; imageio.mimwrite('test2.mp4', fragment, fps=30); Video('test2.mp4') -
谢谢。这当然是一个更清洁的选择。