Helper Functions that work on individual frames
Convert Image to Other Formats¶
_, x = cv2.VideoCapture('files/interstellar-waves-edit.mp4').read()
type(x)
x.shape
type(as_tensor(x))
as_tensor(x, torch.HalfTensor).dtype
as_tensor(x).shape
as_tensor(x).mean(), as_tensor(x, normalise=True).mean()
type(bgr2rgb(x))
imshow(bgr2rgb(x))
type(bgr2hsv(x))
(bgr2hsv(x)).shape
type(x)
[type(i) for i in lapply([x, x, x], as_tensor)]
Resize Image¶
resize(x).shape # scale_factor = 1. by default
resize(x, scale_factor=1.5).shape
resize(x, width=200, height=100, keep_aspect_ratio=False).shape