new_idx = range(int(video.fps * video.clip.duration))[::self.every]
elif self.hertz is not None:
interval = int(video.fps / self.hertz)
new_idx = range(int(video.fps * video.clip.duration))[::interval]
elif self.top_n is not None:
import cv2
diffs = []
for i, img in enumerate(video.frames):
if i == 0:
last = img
continue
diffs.append(sum(cv2.sumElems(cv2.absdiff(last.data, img.data))))
last = img
new_idx = sorted(range(len(diffs)),
key=lambda i: diffs[i],
reverse=True)[:self.top_n]
frame_index = sorted(list(set(video.frame_index).intersection(new_idx)))
return VideoFrameCollectionStim(filename=video.filename,
clip=video.clip,
frame_index=frame_index)
After Change
elif self.hertz is not None:
interval = video.fps / float(self.hertz)
new_idx = np.arange(0, video.n_frames, interval).astype(int)
new_idx = list(new_idx)
elif self.top_n is not None:
import cv2
diffs = []
for i, img in enumerate(video.frames):