Python 中的视频数据集

问题描述 投票:0回答:1

我正在尝试使用带注释的视频数据集,我尝试举一个简单的例子来说明我应该如何开始。我知道要使用视频数据集,我们首先需要从视频中提取图像,然后进行图像处理。然而,我仍然很难理解这些步骤。我发现了这个链接,它很棒,但是数据非常大,无法在我的计算机上下载。 https://www.analyticsvidhya.com/blog/2019/09/step-by-step-deep-learning-tutorial-video-classification-python/

有什么建议可以让我通过示例来加深理解并了解如何处理这些数据集?

python video dataset
1个回答
0
投票

这是一种快速创建合成视频数据集的方法:

import numpy as np
import skvideo.io as sk

# creating sample video data (Here object is moving towards left)
num_vids = 5
num_imgs = 50
img_size = 50
min_object_size = 1
max_object_size = 5

for i_vid in range(num_vids):
    imgs = np.zeros((num_imgs, img_size, img_size))  # set background to 0
    vid_name = "vid" + str(i_vid) + ".mp4"
    w, h = np.random.randint(min_object_size, max_object_size, size=2)
    x = np.random.randint(0, img_size - w)
    y = np.random.randint(0, img_size - h)
    i_img = 0
    while x > 0:
        imgs[i_img, y : y + h, x : x + w] = 255  # set rectangle as foreground
        x = x - 1
        i_img = i_img + 1
    sk.vwrite(vid_name, imgs.astype(np.uint8))

from IPython.display import Video
Video("vid3.mp4")  # the script & video generated should be in same folder

同样,您可以创建物体向其他方向移动的视频。

© www.soinside.com 2019 - 2024. All rights reserved.