CV2 创建模糊视频
import numpy as np
import cv2
size = 80,80
duration = 2
fps = 25
out = cv2.VideoWriter('output.avi', cv2.VideoWriter_fourcc(*'X264'), fps, size)
for l in range(fps * duration):
data = np.zeros( (80,80,3), dtype=np.uint8 )
for k in range(80):
data[40][k]=[255,0,0]
out.write(data)
out.release()
当我想从像素数组(在示例中是一条线,但我需要创建更复杂的图像)创建视频时,结果非常模糊且难以阅读。
是否有特定的格式可以使用 cv2 创建平滑像素,或者我需要另一个视频库?
对于输入,它是一个 80*80 的数组,就像此代码中一样,但包含我的数据 转换为视频时我得到第二张图像
import numpy as np
import cv2
size = 80,80
duration = 2
fps = 25
out = cv2.VideoWriter('output.avi', cv2.VideoWriter_fourcc(*'X264'), fps, size)
for l in range(fps * duration):
data = np.zeros( (80,80,3), dtype=np.uint8 )
for k in range(80):
data[40][k]=[255,0,0]
out.write(data)
out.release()
When I want to create an video from an array of pixels (in the example a line, but I need to create more complex images) the result is very blurry and difficult to read.
Is there a specific format to create smooth pixels with cv2 or I need another video library?
For the input, it's an array 80*80 like in this code but with my data
And I get the second image when converting to video
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论