CV2 创建模糊视频

发布于 2025-01-17 03:33:37 字数 685 浏览 0 评论 0原文

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 的数组,就像此代码中一样,但包含我的数据 转换为视频时我得到第二张图像

Imput

输出(与 .avi 或 .mp4 相同)

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

Imput

Output (same with .avi or .mp4)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文