Commit beb36f0e authored by cb's avatar cb

Added Charset options for names to main

parent ecf25655
......@@ -22,23 +22,23 @@ lastnames = long_lastname.splitlines()
del lastnames[0]
lastnames = [items.split("\t")[0].title() for items in lastnames]
def rand_name(letters=True):
def rand_name(charset):
while True:
firstname = firstnames[random.randint(0, len(firstnames))]
lastname = lastnames[random.randint(0, len(lastnames))]
name = ' '.join([firstname, lastname])
# Loop till there is no non printable characters
if verify_name(name, letters):
if verify_name(name, charset):
return name
def verify_name(name, letters=True):
def verify_name(name, charset):
'''
Brute Version of cleaning names:
Two options:
* Only printable characters (but we'll have some punctuations and (1) (2)...)
* Only letters -> charset "abcdefghijklmnopqrstuvwxyz" + Uppercase
'''
if letters:
if charset =="letters":
# Only ascii
charset = string.ascii_letters + string.whitespace
else:
......
......@@ -35,7 +35,7 @@ averageSuspicious = 0
#We are not doing really face recognition
def doRecognizePerson(faceNames, fid):
time.sleep(2)
faceNames[ fid ] = randomnames.rand_name() #"Person " + str(fid)
faceNames[ fid ] = randomnames.rand_name(charset) #"Person " + str(fid)
def calculateAverageSuspicious(faceSuspicion):
......@@ -45,7 +45,7 @@ def calculateAverageSuspicious(faceSuspicion):
averageSuspicious = sum(faceSuspicion)/currentFaces
print(f"Average suspicion: {averageSuspicious}")
def detectAndTrackMultipleFaces(start_thread):
def detectAndTrackMultipleFaces(start_thread, charset):
#Open the first webcame device
capture = cv2.VideoCapture(0)
......@@ -236,7 +236,7 @@ def detectAndTrackMultipleFaces(start_thread):
else:
# Directly add name
faceNames[ currentFaceID ] = randomnames.rand_name() #"Person " + str(fid)
faceNames[ currentFaceID ] = randomnames.rand_name(charset) #"Person " + str(fid)
calculateAverageSuspicious(faceSuspicion)
......@@ -244,8 +244,6 @@ def detectAndTrackMultipleFaces(start_thread):
currentFaceID += 1
#Now loop over all the trackers we have and draw the rectangle
#around the detected faces. If we 'know' the name for this person
#(i.e. the recognition thread is finished), we print the name
......@@ -320,5 +318,8 @@ def detectAndTrackMultipleFaces(start_thread):
if __name__ == '__main__':
detectAndTrackMultipleFaces(
start_thread=False # False: Names are directly printed on screen, no new thread
# False: Names are directly printed on screen, no new thread
start_thread=False,
# Select only names with letters and whitespace. Any other value will select printable.
charset = "letters"
)
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