Commit 1a2a9d07 authored by klorydryk's avatar klorydryk

add random names generation, based on real last/first names

parent 11df0e1f
This diff is collapsed.
This diff is collapsed.
import random
# English names
fo = open("words", "r")
long_txt = fo.read()
words = long_txt.splitlines()
# French firstnames https://www.data.gouv.fr/fr/datasets/liste-de-prenoms/
fo_firstname = open("Prenoms.csv", "r", encoding='Windows 1252')
long_firstname = fo_firstname.read()
firstnames = long_firstname.splitlines()
del firstnames[0]
firstnames = [items.split(";")[0].title() for items in firstnames]
# print(firstnames)
# French lastnames https://www.insee.fr/fr/statistiques/3536630
fo_lastname = open("noms2008nat_txt.txt", "r")
long_lastname = fo_lastname.read()
lastnames = long_lastname.splitlines()
del lastnames[0]
lastnames = [items.split("\t")[0].title() for items in lastnames]
def rand_name():
firstname = firstnames[random.randint(0, len(firstnames))]
lastname = lastnames[random.randint(0, len(lastnames))]
name = ' '.join([firstname, lastname])
return name
......@@ -12,6 +12,8 @@ import threading
import time
import random
import randomnames
#Initialize a face cascade using the frontal face haar cascade provided with
#the OpenCV library
#Make sure that you copy this file from the opencv project to the root of this
......@@ -33,7 +35,7 @@ averageSuspicious = 0
#We are not doing really face recognition
def doRecognizePerson(faceNames, fid):
time.sleep(2)
faceNames[ fid ] = "Person " + str(fid)
faceNames[ fid ] = randomnames.rand_name() #"Person " + str(fid)
def calculateAverageSuspicious(faceSuspicion):
......@@ -263,12 +265,12 @@ def detectAndTrackMultipleFaces():
cv2.putText(resultImage, faceNames[fid] ,
(int(t_x + t_w/2), int(t_y)),
cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 255, 255), 2)
0.5, (255, 255, 255), 1, cv2.LINE_AA)
else:
cv2.putText(resultImage, "Detecting..." ,
(int(t_x + t_w/2), int(t_y)),
cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 255, 255), 2)
0.5, (255, 255, 255), 1, cv2.LINE_AA)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment