Compare commits
1 Commits
master
...
fix-import
Author | SHA1 | Date | |
---|---|---|---|
e17b2bf461 |
5
main.py
5
main.py
@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from PIL import Image
|
|
||||||
import os
|
|
||||||
import serial
|
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
@ -11,6 +9,7 @@ try:
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from picamera import PiCamera
|
from picamera import PiCamera
|
||||||
from picamera.array import PiRGBArray
|
from picamera.array import PiRGBArray
|
||||||
|
import serial
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -7,10 +7,10 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
picCount = 0
|
picCount = 0
|
||||||
new = False
|
new = False
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
print('Starting training..')
|
print('Starting training..')
|
||||||
label = int(input('Label (Integer): '))
|
label = int(input('Label (Integer): '))
|
||||||
@ -32,14 +32,12 @@ def start():
|
|||||||
addPerson(label, newFileName, oldFileName)
|
addPerson(label, newFileName, oldFileName)
|
||||||
addName(name)
|
addName(name)
|
||||||
|
|
||||||
|
|
||||||
def clearTrainFolder():
|
def clearTrainFolder():
|
||||||
print('clearing train folder')
|
print('clearing train folder')
|
||||||
filelist = [ f for f in os.listdir('train/') if f.endswith(".jpg") ]
|
filelist = [ f for f in os.listdir('train/') if f.endswith(".jpg") ]
|
||||||
for f in filelist:
|
for f in filelist:
|
||||||
os.remove(os.path.join('train/', f))
|
os.remove(os.path.join('train/', f))
|
||||||
|
|
||||||
|
|
||||||
def addPerson(label, newFileName, oldFileName):
|
def addPerson(label, newFileName, oldFileName):
|
||||||
try:
|
try:
|
||||||
#faceFilePath = '/faces/hesham-saeed2'
|
#faceFilePath = '/faces/hesham-saeed2'
|
||||||
@ -78,7 +76,6 @@ def addPerson(label, newFileName, oldFileName):
|
|||||||
face_recognizer.save('faces/'+newFileName)
|
face_recognizer.save('faces/'+newFileName)
|
||||||
print('Updated and saved file in faces/'+newFileName)
|
print('Updated and saved file in faces/'+newFileName)
|
||||||
|
|
||||||
|
|
||||||
def capture(count):
|
def capture(count):
|
||||||
try:
|
try:
|
||||||
print('Initializing camera')
|
print('Initializing camera')
|
||||||
@ -100,7 +97,6 @@ def capture(count):
|
|||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
print('Done!')
|
print('Done!')
|
||||||
|
|
||||||
|
|
||||||
def promptNew():
|
def promptNew():
|
||||||
filemode = raw_input('Make new File? (y/n): ')
|
filemode = raw_input('Make new File? (y/n): ')
|
||||||
if filemode == 'y':
|
if filemode == 'y':
|
||||||
@ -111,8 +107,8 @@ def promptNew():
|
|||||||
print('incorrect input')
|
print('incorrect input')
|
||||||
promptNew()
|
promptNew()
|
||||||
|
|
||||||
|
|
||||||
def addName(newName):
|
def addName(newName):
|
||||||
|
|
||||||
with open("faces/names.json", "r") as read_file:
|
with open("faces/names.json", "r") as read_file:
|
||||||
exist = False
|
exist = False
|
||||||
namesJson = json.load(read_file)
|
namesJson = json.load(read_file)
|
||||||
@ -129,5 +125,4 @@ def addName(newName):
|
|||||||
with open("faces/names.json","w") as write_file:
|
with open("faces/names.json","w") as write_file:
|
||||||
json.dump(names,write_file)
|
json.dump(names,write_file)
|
||||||
|
|
||||||
|
|
||||||
start()
|
start()
|
||||||
|
Loading…
Reference in New Issue
Block a user