-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdataset_from_url.py
More file actions
41 lines (32 loc) · 814 Bytes
/
dataset_from_url.py
File metadata and controls
41 lines (32 loc) · 814 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
39
40
41
#imports
import time
import cv2
import os
import argparse
import training
# data
name = "dataset/" + input("Put a name: ")
os.makedirs(name)
# getting the url from terminal
ap = argparse.ArgumentParser()
ap.add_argument("-u", "--url", required = True)
args = vars(ap.parse_args())
# captured images to start the training
examples_amount = 180
# and then
time_start = time.time()
cap = cv2.VideoCapture(args["url"])
images_captured = 0
print ("Capture from url...\n")
while True:
ret,frame = cap.read()
cv2.imwrite(name + "/%d.jpg" % (images_captured + 1), frame)
images_captured = images_captured + 1
if (images_captured > examples_amount):
time_end = time.time()
cap.release()
print ("Done")
break
print("Starting training")
# training
training.Training()