-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollectImages.py
More file actions
38 lines (28 loc) · 905 Bytes
/
collectImages.py
File metadata and controls
38 lines (28 loc) · 905 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
# Import opencv
import cv2
# Import uuid
import uuid
# Import Operating System
import os
# Import time
import time
IMAGES_PATH = 'Tensorflow/workspace/images/collectedimages'
labels = ['hello', 'thanks', 'love', 'iloveyou', 'yes', 'no', 'vjit']
number_imgs = 15
for label in labels:
!mkdir {'Tensorflow\workspace\images\collectedimages\\'+label}
cap = cv2.VideoCapture(0)
print('Collecting images for {}'.format(label))
time.sleep(5)
for imgnum in range(number_imgs):
print('Collecting image {}'.format(imgnum))
ret, frame = cap.read()
# print(ret, frame)
imgname = os.path.join(IMAGES_PATH,label,label+'.'+'{}.jpg'.format(str(uuid.uuid1())))
# print(imgname)
# cv2.imwrite(imgname, frame)
cv2.imshow('frame', frame)
time.sleep(2)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()