to be tested
This commit is contained in:
parent
20270cc73a
commit
9f75eda8a5
@ -20,6 +20,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="main.py" />
|
||||
<Compile Include="Trainer.py" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
</Project>
|
@ -3,15 +3,17 @@ from io import BytesIO
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
def train(label, path):
|
||||
def addPerson(label, ImagesPath, newFileName, oldFileName):
|
||||
try:
|
||||
#faceFilePath = '/faces/hesham-saeed2'
|
||||
faceFile = '/faces/'+ oldFileName
|
||||
face_recognizer = cv2.createLBPHFaceRecognizer()
|
||||
face_recognizer.load('/faces/hesham-saeed2')
|
||||
face_recognizer.load(faceFile)
|
||||
except:
|
||||
print('[ Error ] Problem in init/loading LBPHfacerecognizer')
|
||||
images = []
|
||||
labels = []
|
||||
image_names = os.listdir(path)
|
||||
image_names = os.listdir(ImagesPath)
|
||||
for image_name in image_names:
|
||||
if image_name.startswith('.'):
|
||||
continue;
|
||||
@ -24,5 +26,6 @@ def train(label, path):
|
||||
images.append(gray[y:y+h, x:x+w])
|
||||
labels.append(label)
|
||||
face_recognizer.train(images, np.array(labels))
|
||||
face_recognizer.save('/faces/'+newFileName)
|
||||
|
||||
|
28
main.py
28
main.py
@ -12,11 +12,8 @@ try:
|
||||
except Exception as ex:
|
||||
print('[ Error ] some depandincies are missing\n'+ str(ex.args))
|
||||
|
||||
|
||||
def init():
|
||||
go = True
|
||||
#OpenShifter()
|
||||
#if Sensors():
|
||||
print('Initilizing Camera and cascade components..')
|
||||
try:
|
||||
camera = PiCamera()
|
||||
@ -116,24 +113,21 @@ def recognize(image):
|
||||
else:
|
||||
return 'Unknown'
|
||||
|
||||
def Sensors():
|
||||
|
||||
while 1:
|
||||
try:
|
||||
line = ser.readline()
|
||||
print(line)
|
||||
if 'A' in line:
|
||||
return True
|
||||
else:
|
||||
print('Sensors not OK..')
|
||||
|
||||
except:
|
||||
print('[ Error ] Can not connect with arduino. Retrying..')
|
||||
|
||||
def OpenShifter():
|
||||
try:
|
||||
ser = serial.Serial('/dev/ttyUSB1',9600)
|
||||
ser.open()
|
||||
ser.write('O')
|
||||
ser.close()
|
||||
except Exception as ex:
|
||||
print('[ Error ] Can not connect to Arduino at /dev/ttyUSB1 .. \n Trying /dev/ttyUSB0')
|
||||
try:
|
||||
ser = serial.Serial('/dev/ttyUSB0',9600)
|
||||
ser.open()
|
||||
ser.write('O')
|
||||
ser.close()
|
||||
except Exception as ex:
|
||||
print('[ Error ] Can not connect to Arduino at /dev/ttyUSB0')
|
||||
|
||||
|
||||
init()
|
||||
|
Loading…
Reference in New Issue
Block a user