-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateDataset.py
37 lines (33 loc) · 921 Bytes
/
CreateDataset.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
import time
import cv2 as cv
import os
camera = cv.VideoCapture(0)
if not camera.isOpened():
print("The Camera is not Opened....Exiting")
exit()
Labels = ["None"]
for label in Labels:
if not os.path.exists(label):
os.mkdir(label)
for folder in Labels:
count = 0
print("Press 's' to start data collection for "+folder)
userinput = input()
if userinput != 's':
print("Wrong Input..........")
exit()
status, frame = camera.read()
cv.imshow("Video Window", frame)
time.sleep(3)
while count<1000:
status, frame = camera.read()
cv.imshow("Video Window",frame)
if not status:
print("Frame is not been captured..Exiting...")
break
cv.imwrite('./'+folder+"./"+str(count)+'.jpg',frame)
count=count+1
if cv.waitKey(1) == ord('q'):
break
camera.release()
cv.destroyAllWindows()