Merge #2
18
Trainer.py
18
Trainer.py
@ -3,8 +3,24 @@ from io import BytesIO
|
|||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
|
import takePhotos;
|
||||||
|
|
||||||
def addPerson(label, ImagesPath, newFileName, oldFileName):
|
picCount = 0
|
||||||
|
|
||||||
|
def start():
|
||||||
|
print('Starting training..')
|
||||||
|
label = int(input('Label (Integer): '))
|
||||||
|
picCount = int(input('Number of Photos: '))
|
||||||
|
clearTrainFolder()
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
try:
|
||||||
#faceFilePath = '/faces/hesham-saeed2'
|
#faceFilePath = '/faces/hesham-saeed2'
|
||||||
faceFile = 'faces/'+ oldFileName
|
faceFile = 'faces/'+ oldFileName
|
||||||
|
@ -5,9 +5,8 @@ from picamera import PiCamera
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
def capture(path):
|
def capture(count):
|
||||||
try:
|
try:
|
||||||
choice = input('Number of photos: ')
|
|
||||||
print('Initializing camera')
|
print('Initializing camera')
|
||||||
camera = PiCamera()
|
camera = PiCamera()
|
||||||
camera.resolution = (640, 480)
|
camera.resolution = (640, 480)
|
||||||
@ -15,7 +14,7 @@ def capture(path):
|
|||||||
sleep(2)
|
sleep(2)
|
||||||
except:
|
except:
|
||||||
print('[ Error ] Can not initialize PiCamera')
|
print('[ Error ] Can not initialize PiCamera')
|
||||||
for i in range(1, choice):
|
for i in range(1, count):
|
||||||
camera.capture(path+str(i)+'.jpg')
|
camera.capture(path+str(i)+'.jpg')
|
||||||
photo = cv2.imread(path+str(i)+'.jpg',1)
|
photo = cv2.imread(path+str(i)+'.jpg',1)
|
||||||
cv2.imshow('Photo',photo)
|
cv2.imshow('Photo',photo)
|
||||||
@ -24,5 +23,4 @@ def capture(path):
|
|||||||
sleep(1)
|
sleep(1)
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
print('Done!')
|
print('Done!')
|
||||||
capture('train/')
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user