Skip to content

Commit bbd3963

Browse files
committed
update code
1 parent ab994f2 commit bbd3963

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

imageSlideShow.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,40 @@
22

33
import cv2
44
import numpy as np
5+
from math import ceil
56
import os
67

78
# Getting images from image base
8-
dst = "/home/siddharth/Desktop/PROGRAMS/Work/Opencv exercise/ 0. Image Base/"
9+
dst = "./images/"
910
images = os.listdir(dst)
1011
length = len(images)
1112

12-
#print(images)
13-
14-
result = cv2.imread(dst + images[0])
13+
result = np.zeros((360,360,3), np.uint8)
1514
i = 1
1615
count = 0
16+
a = 1.0 # alpha
17+
b = 0.0 # beta
18+
img = cv2.imread(dst + images[i])
19+
img = cv2.resize(img, (360, 360))
1720

1821
# Slide Show Loop
1922
while(True):
20-
a = 1.0
21-
b = 0.0
22-
img = cv2.imread(dst + images[i])
23-
23+
24+
if(ceil(a)==0):
25+
a = 1.0
26+
b = 0.0
27+
i = (i+1)%length # Getting new image from directory
28+
img = cv2.imread(dst + images[i])
29+
img = cv2.resize(img, (360, 360))
30+
31+
a -= 0.01
32+
b += 0.01
33+
2434
# Image Transition from one to another
25-
while(int(b)!=1):
26-
result = cv2.addWeighted(result, a, img, b, 0)
27-
cv2.imshow("slideShow", result)
28-
a -= 0.0001
29-
b += 0.0001
30-
31-
i = (i+1)%length # Getting new image from directory
32-
33-
if cv2.waitKey(1) & 0xff == ord('q'):
35+
result = cv2.addWeighted(result, a, img, b, 0)
36+
cv2.imshow("Slide Show", result)
37+
key = cv2.waitKey(1) & 0xff
38+
if key==ord('q'):
3439
break
3540

36-
cv2.destroyAllWindows()
41+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)