Skip to content

Commit 3f1a8fd

Browse files
Image Slideshow
1 parent 9b9f59c commit 3f1a8fd

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 os
5+
import argparse
6+
7+
ap = argparse.ArgumentParser()
8+
ap.add_argument("-p", "--path", required=True, help="path to input directory")
9+
ap.add_argument("-o", "--output_video", type=str, required=True, help="output video name")
10+
args = vars(ap.parse_args())
11+
12+
out = None
13+
(w,h) = (None,None)
14+
img_array = []
15+
16+
imagePaths = list(paths.list_images(args["path"]))
17+
18+
for filename in imagePaths:
19+
img = cv2.imread(filename)
20+
img = cv2.resize(img,(1400,800))
21+
height, width, layers = img.shape
22+
if w is None or h is None:
23+
(w,h) = (width,height)
24+
img_array.append(img)
25+
26+
if out is None:
27+
out = cv2.VideoWriter(args["output_video"],cv2.VideoWriter_fourcc(*'DIVX'), 1, (w,h),True)
28+
29+
for i in range(len(img_array)):
30+
out.write(img_array[i])
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)