import imageio
import urllib.request
url = "https://i.stack.imgur.com/lui1A.gif"
fname = "tmp.gif"
## Read the gif from the web, save to the disk
imdata = urllib.request.urlopen(url).read()
imbytes = bytearray(imdata)
open(fname,"wb+").write(imdata)
## Read the gif from disk to `RGB`s using `imageio.miread`
gif = imageio.mimread(fname)
nums = len(gif)
print("Total {} frames in the gif!".format(nums))
# convert form RGB to BGR
imgs = [cv2.cvtColor(img, cv2.COLOR_RGB2BGR) for img in gif]
## Display the gif
i = 0
while True:
cv2.imshow("gif", imgs[i])
if cv2.waitKey(100)&0xFF == 27:
break
i = (i+1)%nums
cv2.destroyAllWindows()
Code Example |
---|
Cpp :: inverse lerp c++ |
Cpp :: sieve of eratosthenes c++ |
Cpp :: c++ max |
Cpp :: passing a 2d array cpp |
Cpp :: c++ cout int |
Cpp :: while loop in c++ |
Cpp :: c++ find in pair |
Cpp :: vector remove class |
Cpp :: constants in cpp |
Cpp :: modify value in map c++ |
Cpp :: stream in c++ |
Cpp :: sum function in c++ |
Cpp :: c++ filesystem remove file |
Cpp :: char * to string c++ |
Cpp :: how to find maximum value in c++ |
C :: reset style matplotlib |
C :: myFgets in c |
C :: wireless app debug android |
C :: how to map one value to another in C |
C :: sdl_renderfillrect |
C :: font awsome circle info icon |
C :: for loop c |
C :: scan numbers into array c |
C :: string if statements c |
C :: get last char string c |
C :: char array to int c |
C :: Access denied creating xampp-control.ini |
C :: make a function makefile |
C :: addition of two numbers in c |
C :: How to convert string to int without using library functions in c |