Closed nischi closed 11 months ago
This is script I put together to do tihs, not as good as being option in module but still makes it easier.
from picamera import PiCamera
from time import sleep
import os
import cv2
camera = PiCamera()
camera.start_preview()
camera.rotation = 180
camera.resolution = (640, 480)
# Parent Directory path
parent_dir = "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN"
dataset_dir = os.path.join(parent_dir, 'dataset')
tools_dir = os.path.join(parent_dir, 'tools')
# get name for file
name = input("Enter user name : ")
directory = name.capitalize()
# Path
path = os.path.join(dataset_dir, directory)
# Create the directory
if not os.path.exists(path):
os.makedirs(path)
print("Directory '% s' created" % directory)
# Get ready...
for i in range(5):
print('Ready in {}....'.format(5-i))
sleep(1)
for i in range(10):
print('Smile for pic {} ....'.format(i+1))
imgpath = os.path.join(path,'image%0.04d.jpg' % (i))
camera.capture(imgpath)
img = cv2.imread(imgpath,0)
cv2.imshow('Your Pic',img)
sleep(2)
cv2.destroyAllWindows()
camera.stop_preview()
print("Done taking 10 photos!")
print("Now call call following to run training on images:")
print("python3 %s/encode.py -i %s -e %s/encodings.pickle -d hog" % (tools_dir, dataset_dir, tools_dir))
Should be fixed with new version 2.0
Like @patrickmoineau does in his fork, implementing a way to create his dataset with the camera. But in a separate file and do not touch the encoding.py.
https://github.com/patrickmoineau/MMM-Face-Reco-DNN/commit/7ea8595b1950089358e1881ac5830006e2bdbeca