This repository was archived by the owner on Dec 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from LimaoC/mitch-notebook-scripts
- Loading branch information
Showing
4 changed files
with
129 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pprint import pprint | ||
import cv2 | ||
from deepface import DeepFace | ||
|
||
|
||
ENTER_ASCII = 13 | ||
|
||
|
||
def take_photo(photo_name): | ||
capture = cv2.VideoCapture(0) | ||
while True: | ||
success, frame = capture.read() | ||
if not success: | ||
continue | ||
|
||
cv2.imshow(f"Camera Preview for {photo_name}: Press enter to take photo", frame) | ||
|
||
if cv2.waitKey(1) & 0xFF == ENTER_ASCII: | ||
cv2.imwrite(photo_name, frame) | ||
|
||
break | ||
|
||
capture.release() | ||
cv2.destroyAllWindows() | ||
|
||
|
||
# Take two photos. Press enter to confirm photo. | ||
print("Please take two photos") | ||
take_photo("photo1.png") | ||
take_photo("photo2.png") | ||
|
||
|
||
# Verify that photos are of same person. | ||
print("Deepface output") | ||
pprint(DeepFace.verify("photo1.png", "photo2.png", model_name="GhostFaceNet")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import time | ||
from pprint import pprint | ||
from datetime import datetime | ||
from data.routines import ( | ||
init_database, | ||
get_schema_info, | ||
create_user, | ||
save_posture, | ||
get_users, | ||
get_postures, | ||
get_user_postures, | ||
Posture, | ||
) | ||
|
||
print("Initialising database") | ||
init_database() | ||
|
||
print("Schema info") | ||
pprint(get_schema_info()) | ||
|
||
print("Creating user") | ||
create_user() | ||
|
||
print("Getting 10 users") | ||
pprint(get_users(num=10)) | ||
|
||
print("Adding posture for user 1") | ||
time1 = datetime.now() | ||
time.sleep(1) | ||
time2 = datetime.now() | ||
posture = Posture(None, 1, 0.8, 1.0, time1, time2) | ||
save_posture(posture) | ||
|
||
print("Getting 10 postures") | ||
pprint(get_postures(num=10)) | ||
|
||
print("Getting postures for user 1") | ||
pprint(get_user_postures(1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import cv2 | ||
from models.pose_detection.routines import ( | ||
DebugPostureTracker, | ||
create_debug_posture_tracker, | ||
) | ||
|
||
|
||
def run_posture_tracking_loop(posture_tracker: DebugPostureTracker): | ||
while True: | ||
# Other control flow code | ||
# ... | ||
|
||
posture_tracker.track_posture() | ||
|
||
# ... | ||
# Other control flow code | ||
|
||
# Quit when q is pressed | ||
if cv2.waitKey(1) & 0xFF == ord("q"): | ||
break | ||
|
||
|
||
with create_debug_posture_tracker() as posture_tracker: | ||
run_posture_tracking_loop(posture_tracker) |