scripts/examples: Simplify blazeface and palm examples.

This commit is contained in:
Kwabena W. Agyeman 2025-11-02 12:31:01 -08:00
parent 75e16b5738
commit 3527c4d423
4 changed files with 52 additions and 66 deletions

View File

@ -26,11 +26,7 @@ while True:
img = csi0.snapshot() img = csi0.snapshot()
# faces is a list of ((x, y, w, h), score, keypoints) tuples # faces is a list of ((x, y, w, h), score, keypoints) tuples
faces = model.predict([img]) for r, score, keypoints in model.predict([img]):
# Draw bounding boxes around the detected faces and keypoints.
if faces:
for r, score, keypoints in faces[0]:
ml.utils.draw_predictions(img, [r], ("face",), ((0, 0, 255),), format=None) ml.utils.draw_predictions(img, [r], ("face",), ((0, 0, 255),), format=None)
# keypoints is a ndarray of shape (6, 2) # keypoints is a ndarray of shape (6, 2)

View File

@ -31,11 +31,7 @@ while True:
img = csi0.snapshot() img = csi0.snapshot()
# palms is a list of ((x, y, w, h), score, keypoints) tuples # palms is a list of ((x, y, w, h), score, keypoints) tuples
palms = model.predict([img]) for r, score, keypoints in model.predict([img]):
# Draw bounding boxes around the detected palms and keypoints.
if palms:
for r, score, keypoints in palms[0]:
ml.utils.draw_predictions(img, [r], ("palm",), ((0, 0, 255),), format=None) ml.utils.draw_predictions(img, [r], ("palm",), ((0, 0, 255),), format=None)
# keypoints is a ndarray of shape (7, 2) # keypoints is a ndarray of shape (7, 2)

View File

@ -39,10 +39,7 @@ while True:
img = csi0.snapshot() img = csi0.snapshot()
# palms is a list of ((x, y, w, h), score, keypoints) tuples # palms is a list of ((x, y, w, h), score, keypoints) tuples
palms = palm_detection.predict([img]) for r, score, keypoints in palm_detection.predict([img]):
if palms:
for r, score, keypoints in palms[0]:
# rect is (x, y, w, h) - enlarge by 3x for hand landmarks model # rect is (x, y, w, h) - enlarge by 3x for hand landmarks model
wider_rect = (r[0] - r[2], r[1] - r[3], r[2] * 3, r[3] * 3) wider_rect = (r[0] - r[2], r[1] - r[3], r[2] * 3, r[3] * 3)
# Operate on just the ROI of the detected palm # Operate on just the ROI of the detected palm

View File

@ -43,10 +43,7 @@ while True:
if n is None: if n is None:
# palms is a list of ((x, y, w, h), score, keypoints) tuples # palms is a list of ((x, y, w, h), score, keypoints) tuples
palms = palm_detection.predict([img]) for r, score, keypoints in palm_detection.predict([img]):
if palms:
for r, score, keypoints in palms[0]:
# rect is (x, y, w, h) - enlarge by 3x for hand landmarks model # rect is (x, y, w, h) - enlarge by 3x for hand landmarks model
wider_rect = (r[0] - r[2], r[1] - r[3], r[2] * 3, r[3] * 3) wider_rect = (r[0] - r[2], r[1] - r[3], r[2] * 3, r[3] * 3)
# Operate on just the ROI of the detected palm # Operate on just the ROI of the detected palm