forked from tobybreckon/python-examples-cv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cycleimages.py
49 lines (31 loc) · 1.3 KB
/
cycleimages.py
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
42
43
44
45
46
47
48
49
#####################################################################
# Example : load and display a set of images from a directory
# basic illustrative python script
# For use with provided test / training datasets
# Author : Toby Breckon, [email protected]
# Copyright (c) 2015 / 2016 School of Engineering & Computing Science,
# Durham University, UK
# License : LGPL - http://www.gnu.org/licenses/lgpl.html
#####################################################################
import cv2
import os
directory_to_cycle = "path-to-directory-to-cycle" # edit this
#####################################################################
# display all images in directory (sorted by filename)
for filename in sorted(os.listdir(directory_to_cycle)):
# if it is a PNG file
if '.png' in filename:
print(os.path.join(directory_to_cycle, filename))
# read it and display in a window
img = cv2.imread(
os.path.join(
directory_to_cycle,
filename),
cv2.IMREAD_COLOR)
cv2.imshow('the image', img)
key = cv2.waitKey(200) # wait 200ms
if (key == ord('x')):
break
# close all windows
cv2.destroyAllWindows()
#####################################################################