-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimageSlideShow.py
More file actions
executable file
·41 lines (32 loc) · 839 Bytes
/
imageSlideShow.py
File metadata and controls
executable file
·41 lines (32 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Image Slide Show using addWeighted
import cv2
import numpy as np
from math import ceil
import os
# Getting images from image base
dst = "./images/"
images = os.listdir(dst)
length = len(images)
result = np.zeros((360,360,3), np.uint8)
i = 1
a = 1.0 # alpha
b = 0.0 # beta
img = cv2.imread(dst + images[i])
img = cv2.resize(img, (360, 360))
# Slide Show Loop
while(True):
if(ceil(a)==0):
a = 1.0
b = 0.0
i = (i+1)%length # Getting new image from directory
img = cv2.imread(dst + images[i])
img = cv2.resize(img, (360, 360))
a -= 0.01
b += 0.01
# Image Transition from one to another
result = cv2.addWeighted(result, a, img, b, 0)
cv2.imshow("Slide Show", result)
key = cv2.waitKey(1) & 0xff
if key==ord('q'):
break
cv2.destroyAllWindows()