Video Cooking #3 - Read frames from gif

Reading and creating gif files is much easier using PIL than OpenCV.

Read frame from gif file



import argparse
from PIL import Image, ImageSequence

parser = argparse.ArgumentParser(description='gif run')
parser.add_argument('--file', type=str, required=True, help='gif file name')
args = parser.parse_args()

im = Image.open(args.file)

index = 1
for frame in ImageSequence.Iterator(im):
    frame.save("frame%d.png" % index)
    index += 1



댓글

이 블로그의 인기 게시물

Image Processing #7 - OpenCV Text

Playing YouTube videos using OpenCV

OpenCV Installation - Rasbian Buster, Jessie, DietPi Buster