'Video datasets in Python

I am a new to deep learning algorithms and Machine learning as well as working with data. I am currently trying to work with annotated video dataset, I tried to have a simple example on How I should get started. I am aware that to work with video dataset, we will first need to extract the images from videos and then do the image processing. However, as I am new it is still difficult for me to understand the steps. I came accross this link, it is great but the data is really large and it cannot be downloaded on my computer. https://www.analyticsvidhya.com/blog/2019/09/step-by-step-deep-learning-tutorial-video-classification-python/

Any suggestions to a walk through examples I can use to build my understanding and Know how to deal with these datasets



Solution 1:[1]

Here is a way to create synthetic video dataset quickly:

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

Similarly you can create videos where, object(s) move(s) in other directions.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SKG