heatrateestimation/frame_extraction.py

35 lines
598 B
Python

# frame extraction
#
# Task:
# -frame extration from mp4 video
#
# Inputs:
# -mp4 file
# -fps
# -
# -
#
# Output:
# -png of video
#
# Author: Thomas Périn
# Date: 17/02/2023
#
# Note: check video name when extracting a new one
############
import cv2
#Select video by name
vidcap = cv2.VideoCapture('face_video.mp4')
success,image = vidcap.read()
#Counter to number the images
count = 0
#Extraction loop for all images
while success:
cv2.imwrite("img%d.png" % count, image) # save frame as JPEG file
success,image = vidcap.read()
print('Read a new frame: ', success)
count += 1