-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture.py
More file actions
38 lines (32 loc) · 796 Bytes
/
Copy pathcapture.py
File metadata and controls
38 lines (32 loc) · 796 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
38
# -*- coding: utf-8 -*-
"""
Created on Mon May 18 23:28:21 2020
@author: piyus
"""
import cv2
import os
name=input("enter name")
# define the name of the directory to be created
path = "dataset/"+name
try:
os.mkdir(path)
except OSError:
print ("Creation of the directory %s failed" % path)
else:
print ("Successfully created the directory %s " % path)
cam = cv2.VideoCapture(0)
path = "dataset/"+name+"/"
img_counter = 7
while img_counter!=0:
ret, frame = cam.read()
if not ret:
print("failed to grab frame")
break
# SPACE pressed
img_name = "opencv_frame_{}.png".format(img_counter)
des=path+img_name
cv2.imwrite(des, frame)
print("{} written!".format(img_name))
img_counter =img_counter- 1
cam.release()
cv2.destroyAllWindows()