26 lines
590 B
Python
26 lines
590 B
Python
vpath = '/srv/ftp/railing/2021/09/04/Railing_00_20210904070617.mp4'
|
|
stack_path = os.path.splitext(vpath)[0]
|
|
import cv2
|
|
import numpy
|
|
import torch
|
|
cap = cv2.VideoCapture(vpath)
|
|
frame_num = 0
|
|
step_frame = 5
|
|
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
|
|
# %%
|
|
images = list()
|
|
stack_num = 0
|
|
for frame_num in range(0, total_frames, step_frame):
|
|
img = cap.read()[1].copy()
|
|
|
|
images.append(img)
|
|
if len(images) == 16:
|
|
|
|
stack_num +=1
|
|
break
|
|
# %%
|
|
imgs = np.moveaxis(np.stack(images), 3, 1)
|
|
bt = torch.FloatTensor(imgs)
|
|
tensor_path = f'{stack_path}.{stack_num:03}.pt'
|