I'm trying to take an image from a video and crop out a random 64 x 64 x 3 chunk of it (64 width, 64 height, 3 for the color channels).
Here's what I have so far:
def process_video(video_name):
# load video using cv2
video_cap = cv2.VideoCapture(video_name)
if video_cap.isOpened():
ret, frame = video_cap.read()
else:
ret = False
# while there's another frame
i = 0
while ret:
ret, frame = video_cap.read()
if i % 10 == 0:
# save several images from frame to local directory
i += 1
video_cap.release()
I want to take a small portion of the frame (64 x 64 x 3) and save it as a .jpg file, so I'm having trouble with the last commented part. Any suggestions for how to go about this?
Thanks!