I'm a new grad student who's spent the last 3 days trying to grab some frames from a .avi with zero success. I've tried pythons 2 and 3, openCV, simpleCV, simpleITK, scikit-image, and ffmpeg, and have run into different issues with each. Is it really that hard? There's next to no documentation around for all of them, for sure.
All of the above claim to have installed correctly (e.g. skimage, SimpleITK and SimpleCV can be imported fine, openCV responds fine to cv2.__version__, which is what they claim defines a healthy install).
import numpy as np
import cv2
cap = cv2.VideoCapture('vtest.avi')
while(cap.isOpened()):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
cap.isOpened() is always false, so no reading gets done.
class AVILoader:
video_file = 'myvideo.avi'
def __call__(self, frame):
return video_read(self.video_file, frame)
avi_load = AVILoader()
frames = range(0, 1000, 10) # 0, 10, 20, ...
ic = ImageCollection(frames, load_func=avi_load)
x = ic[5] # calls avi_load(frames[5]) or equivalently avi_load(50)
Of course, that's junk too because video_read just isn't a function. Google gets 8 results associating video_read with skimage.
It took a long time, crash my IDE a couple of times, and came up with no data at the end.
I'm frustrated. How do you get started?