Skip to content

Commit 8cfc096

Browse files
authored
Merge pull request #681 from PratikshaGoyal/feature
Image Slideshow
2 parents 8736b04 + 9d93628 commit 8cfc096

File tree

14 files changed

+43
-0
lines changed

14 files changed

+43
-0
lines changed

Images to Video/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Image Slideshow
2+
Program requires a 2 arguments:
3+
1. Path to Foldder that contains input images
4+
2. Output video name
5+
```
6+
python img2vid.py -p {/pth/to/input/images} -o {output.mp4}
7+
```
8+

Images to Video/img2vid.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import cv2
2+
3+
from imutils import paths
4+
import argparse
5+
6+
ap = argparse.ArgumentParser()
7+
ap.add_argument("-p", "--path", required=True, help="path to input directory")
8+
ap.add_argument("-o", "--output_video", type=str, required=True, help="output video name")
9+
args = vars(ap.parse_args())
10+
11+
out = None
12+
(w, h) = (None, None)
13+
img_array = []
14+
15+
imagePaths = list(paths.list_images(args["path"]))
16+
17+
for filename in imagePaths:
18+
img = cv2.imread(filename)
19+
img = cv2.resize(img, (1400, 800))
20+
height, width, layers = img.shape
21+
if w is None or h is None:
22+
(w, h) = (width, height)
23+
img_array.append(img)
24+
25+
if out is None:
26+
out = cv2.VideoWriter(args["output_video"], cv2.VideoWriter_fourcc(*'DIVX'), 1, (w, h), True)
27+
28+
for i in range(len(img_array)):
29+
out.write(img_array[i])
30+
31+
out.release()

Images to Video/input_images/1.png

11.9 KB
Loading

Images to Video/input_images/10.png

9.92 KB
Loading

Images to Video/input_images/2.jpg

7.06 KB
Loading

Images to Video/input_images/3.jpg

8.65 KB
Loading

Images to Video/input_images/4.png

6.68 KB
Loading

Images to Video/input_images/5.jpg

8.89 KB
Loading

Images to Video/input_images/6.jpg

9.34 KB
Loading

Images to Video/input_images/7.jpg

8.45 KB
Loading

0 commit comments

Comments
 (0)