Skip to content

Commit

Permalink
Merge pull request #4 from Avaiga/feature/doc#986-document-best-pract…
Browse files Browse the repository at this point in the history
…ice-on-main-script

Feature/doc#986 - Document best practice on main script
  • Loading branch information
trgiangdo authored Jul 29, 2024
2 parents 6c2721a + 19a1d29 commit 359d623
Showing 1 changed file with 13 additions and 14 deletions.
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)

0 comments on commit 359d623

Please sign in to comment.