okankop / vidaug

Effective Video Augmentation Techniques for Training Convolutional Neural Networks
MIT License
387 stars 78 forks source link

Not working for .mp4 format? #9

Closed ramnamaqsood776 closed 5 years ago

ramnamaqsood776 commented 5 years ago

Hello Can you please guide me that why this code is not running for .mp4 format? Thank you

okankop commented 5 years ago

You need to give image frames in numpy or PIL fotmat. So you need to extract frames form video of format .mp4 first.

PHDPeter commented 4 years ago

import cv2 def load_video(video_path):

'video' should be either a list of images from type of numpy array or PIL images

cap = cv2.VideoCapture(video_path)
ret, frame = cap.read()
frame_list=[]
while ret == True:
    ret, frame = cap.read()
    frame_list.append(frame)

#cap.release()
print(len(frame_list))
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)  # float
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)  # float

cap.release()
return frame_list, width,height