Horje
opencv read gif c++ Code Example
opencv read gif c++
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()




Cpp

Related
int a=0;     int b=30; Code Example int a=0; int b=30; Code Example
Code debut C++ Code Example Code debut C++ Code Example
zsh: segmentation fault ./provided_files.exe erosion X \. Code Example zsh: segmentation fault ./provided_files.exe erosion X \. Code Example
how to store array of string with spaces in c++ stl Code Example how to store array of string with spaces in c++ stl Code Example
print float number with only four places after the decimal point in c++ Code Example print float number with only four places after the decimal point in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11