Main Function
This while loop represents the core functionality of the program.
This loop repeats forever, as quickly as the hardware allows, until the user quits the program.
In the Python script this block of code is found at the bottom - after the custom functions are defined.
while True:
# Read a frame of video
ret, frame = videoCapture.read()
# Process the faces in the frame and
return an array row for each face found in frame
liveArray = ProcessFrame(
frame, lastFrameArray, databaseArray, liveDataStructure,
databaseRecheckTrigger)
# For each row in liveArray that
leaves ProcessFrame without a successful ID, create a new database row
liveArray, databaseArray, databaseStructure,
frameCountTrigger)
# Add .jpgs to image database on
timed intervals, per face
TakeScreenshots(
frame, liveArray, databaseArray, screenShotInterval,
frameCountTrigger)
# Use the x/y cords and name of the
found face to display the results on frame (building GUI)
PaintBoxes(frame, liveArray)
# Paint FPS data on frame
difference = (datetime.now() - newTime)
fps = 'FPS: {:0.2f}'.format(1 /
difference.microseconds * 1000000)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(frame, fps, (0, 30), font, 1, (0, 0, 255), 2)
# Store data in RAM to compare
against next frame's data
lastFrameArray = liveArray
# processThisFrame = not
processThisFrame
# Display the resulting image
cv2.imshow('Video', frame)
# Listen for user click, if click
happens in an UnkwownX box, return which box was clicked on and a True flag
liveArrayRow, userClickedOnUnknown = ClickID(mouseClick, liveArray)
# If ClickID returned True
if
userClickedOnUnknown == True:
# This line pauses the while loop
until user inputs text
newNameInput = input('Tag this person: ')
# Updates record in liveArray,
databaseArray, and record's /Screenshot/ folder
PromoteUnknown(newNameInput, liveArrayRow, liveArray,
databaseArray)
# Reset user click to impossible
coordinates
mouseClick = [-1,
-1]
# Reset while loop to run
indefinitely
userClickedOnUnknown = False
# Hit 'q' on the keyboard to
quit!
if
cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release handle to the webcam
videoCapture.release()
cv2.destroyAllWindows()
# Print and save the databaseArray in its final state before
program exit
SaveArray(databaseArray)