Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/doc#986 - Document best practice on main script #4

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,10 @@
from pathlib import Path
from demo.faces import detect_faces, recognize_face, train_face_recognizer


logging.basicConfig(level=logging.DEBUG)

training_data_folder = Path("images")

show_capture_dialog = False
capture_image = False
show_add_captured_images_dialog = False

labeled_faces = [] # Contains rect with label (for UI component)

captured_image = None
captured_label = ""


def on_action_captured_image(state, id, action, payload):
print("Captured image")
Expand Down Expand Up @@ -93,7 +83,17 @@ def button_retrain_clicked(state):
train_face_recognizer(training_data_folder)


webcam_md = """<|toggle|theme|>
if __name__ == "__main__":
show_capture_dialog = False
capture_image = False
show_add_captured_images_dialog = False

labeled_faces = [] # Contains rect with label (for UI component)

captured_image = None
captured_label = ""

webcam_md = """<|toggle|theme|>

<container|container|part|

Expand Down Expand Up @@ -125,9 +125,8 @@ def button_retrain_clicked(state):

<|{captured_label}|input|>
|>
"""
"""

if __name__ == "__main__":
# Create dir where the pictures will be stored
if not training_data_folder.exists():
training_data_folder.mkdir()
Expand All @@ -136,4 +135,4 @@ def button_retrain_clicked(state):

gui = Gui(webcam_md)
gui.add_library(Webcam())
gui.run(port=9090)
gui.run(port=9090)