Formatting
This commit is contained in:
parent
a82b98154f
commit
fb84cf1bb5
@ -7,10 +7,10 @@ import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
|
||||
picCount = 0
|
||||
new = False
|
||||
|
||||
|
||||
def start():
|
||||
print('Starting training..')
|
||||
label = int(input('Label (Integer): '))
|
||||
@ -32,12 +32,14 @@ def start():
|
||||
addPerson(label, newFileName, oldFileName)
|
||||
addName(name)
|
||||
|
||||
|
||||
def clearTrainFolder():
|
||||
print('clearing train folder')
|
||||
filelist = [f for f in os.listdir('train/') if f.endswith(".jpg")]
|
||||
for f in filelist:
|
||||
os.remove(os.path.join('train/', f))
|
||||
|
||||
|
||||
def addPerson(label, newFileName, oldFileName):
|
||||
try:
|
||||
# faceFilePath = '/faces/hesham-saeed2'
|
||||
@ -76,6 +78,7 @@ def addPerson(label, newFileName, oldFileName):
|
||||
face_recognizer.save('faces/' + newFileName)
|
||||
print('Updated and saved file in faces/' + newFileName)
|
||||
|
||||
|
||||
def capture(count):
|
||||
try:
|
||||
print('Initializing camera')
|
||||
@ -97,6 +100,7 @@ def capture(count):
|
||||
cv2.destroyAllWindows()
|
||||
print('Done!')
|
||||
|
||||
|
||||
def promptNew():
|
||||
filemode = raw_input('Make new File? (y/n): ')
|
||||
if filemode == 'y':
|
||||
@ -107,8 +111,8 @@ def promptNew():
|
||||
print('incorrect input')
|
||||
promptNew()
|
||||
|
||||
def addName(newName):
|
||||
|
||||
def addName(newName):
|
||||
with open("faces/names.json", "r") as read_file:
|
||||
exist = False
|
||||
namesJson = json.load(read_file)
|
||||
@ -125,4 +129,5 @@ def addName(newName):
|
||||
with open("faces/names.json", "w") as write_file:
|
||||
json.dump(names, write_file)
|
||||
|
||||
|
||||
start()
|
||||
|
Loading…
Reference in New Issue
Block a user