From b09fccceac6090d1406ccaf27ed3eb6d3fc1f189 Mon Sep 17 00:00:00 2001
From: FlorianJacta <98709993+FlorianJacta@users.noreply.github.com>
Date: Wed, 11 Oct 2023 17:21:49 +0200
Subject: [PATCH 1/4] Update to 3.0
---
src/main.py | 13 +++++++++++--
src/requirements.txt | 2 +-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/main.py b/src/main.py
index f66f2d4..fcf9b9c 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,4 +1,4 @@
-from taipy.gui import Gui
+from taipy.gui import Gui, notify
from webcam import Webcam
import cv2
@@ -29,6 +29,7 @@ def on_action_captured_image(state, id, action, payload):
print("Captured image")
choice = payload["args"][0]
if choice == 0:
+ notify(state, "i", "Adding image to database...")
# Add image to training data:
img = state.captured_image
file_name = str(uuid.uuid4()) + ".jpg"
@@ -39,6 +40,7 @@ def on_action_captured_image(state, id, action, payload):
label_file_path = Path(training_data_folder, "data.csv")
with label_file_path.open("a") as f:
f.write(f"{file_name},{label}\n")
+ notify(state, "s", "Image added to database")
state.captured_image = None
state.captured_label = ""
@@ -59,12 +61,14 @@ def process_image(state, frame):
# Capture image (actually we consider only the first detected face)
if state.capture_image and len(labeled_images) > 0:
+ notify(state, "i", "Capturing image...")
img = labeled_images[0][0]
label = labeled_images[0][2]
state.captured_image = cv2.imencode(".jpg", img)[1].tobytes()
state.captured_label = label
state.show_capture_dialog = True
state.capture_image = False
+
def handle_image(state, action, args, value):
@@ -83,6 +87,7 @@ def handle_image(state, action, args, value):
img = cv2.imread(temp_path, cv2.IMREAD_UNCHANGED)
except cv2.error as e:
logging.error(f"Failed to read image file: {e}")
+ notify(state, "e", f"Failed to read image file: {e}")
return
process_image(state, img)
# Finish. Tempfile is removed.
@@ -90,7 +95,9 @@ def handle_image(state, action, args, value):
def button_retrain_clicked(state):
print("Retraining...")
+ notify(state, "i", "Retraining...")
train_face_recognizer(training_data_folder)
+ notify(state, "s", "Retrained!")
webcam_md = """<|toggle|theme|>
@@ -105,6 +112,8 @@ def button_retrain_clicked(state):
- How to detect and recognize faces in the image in real time using [OpenCV](https://opencv.org/).
+
+Wait for your face to be detected. Then, capture your face, provide your name, and retrain the model.
Date: Wed, 25 Oct 2023 15:13:33 +0200
Subject: [PATCH 2/4] Update version
---
.gitignore | 3 ++-
src/requirements.txt | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index c9d2fa6..4f12d12 100644
--- a/.gitignore
+++ b/.gitignore
@@ -135,4 +135,5 @@ dmypy.json
.vscode
# Demo Images
-images/
\ No newline at end of file
+images/
+src.zip
diff --git a/src/requirements.txt b/src/requirements.txt
index 5a8078f..f9d1bcf 100644
--- a/src/requirements.txt
+++ b/src/requirements.txt
@@ -1,4 +1,4 @@
-taipy==3.0.0.dev3
+taipy==3.0.0.dev4
opencv-python-headless==4.7.0.72
opencv-contrib-python-headless==4.7.0.72
pillow
\ No newline at end of file
From 5771d50791bc30a6f51ea3372d8b003b90f84e83 Mon Sep 17 00:00:00 2001
From: FlorianJacta <98709993+FlorianJacta@users.noreply.github.com>
Date: Fri, 30 Aug 2024 16:59:13 +0200
Subject: [PATCH 3/4] Fix 3.0
---
src/main.py | 8 +++++---
src/requirements.txt | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/main.py b/src/main.py
index fcf9b9c..b91cae4 100644
--- a/src/main.py
+++ b/src/main.py
@@ -25,8 +25,9 @@
captured_label = ""
-def on_action_captured_image(state, id, action, payload):
+def on_action_captured_image(state, id, payload):
print("Captured image")
+
choice = payload["args"][0]
if choice == 0:
notify(state, "i", "Adding image to database...")
@@ -71,9 +72,10 @@ def process_image(state, frame):
-def handle_image(state, action, args, value):
+def handle_image(state, action, args):
print("Handling image...")
- payload = value["args"][0]
+
+ payload = args["args"][0]
bytes = payload["data"]
logging.debug(f"Received data: {len(bytes)}")
diff --git a/src/requirements.txt b/src/requirements.txt
index f9d1bcf..cc94a7d 100644
--- a/src/requirements.txt
+++ b/src/requirements.txt
@@ -1,4 +1,4 @@
-taipy==3.0.0.dev4
+taipy==3.0
opencv-python-headless==4.7.0.72
opencv-contrib-python-headless==4.7.0.72
pillow
\ No newline at end of file
From a5227a5405de2789ea09c3c3634ce1c82e37f338 Mon Sep 17 00:00:00 2001
From: Jean-Robin
Date: Fri, 30 Aug 2024 17:46:13 +0200
Subject: [PATCH 4/4] Apply suggestions from code review
---
src/main.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/main.py b/src/main.py
index 6274ac7..6c0d63a 100644
--- a/src/main.py
+++ b/src/main.py
@@ -17,7 +17,6 @@
def on_action_captured_image(state, id, payload):
print("Captured image")
-
choice = payload["args"][0]
if choice == 0:
notify(state, "i", "Adding image to database...")
@@ -59,12 +58,10 @@ def process_image(state, frame):
state.captured_label = label
state.show_capture_dialog = True
state.capture_image = False
-
def handle_image(state, action, args):
print("Handling image...")
-
payload = args["args"][0]
bytes = payload["data"]
logging.debug(f"Received data: {len(bytes)}")
@@ -147,4 +144,3 @@ def button_retrain_clicked(state):
gui = Gui(webcam_md)
gui.add_library(Webcam())
gui.run(title='Face Recognition')
-