Skip to content

Commit bcf9474

Browse files
Update experiments
1 parent 9b49e4e commit bcf9474

File tree

484 files changed

+1596
-1211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

484 files changed

+1596
-1211
lines changed

gen2-age-gender/main.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from depthai_sdk import OakCamera, TwoStagePacket, AspectRatioResizeMode, Visualizer, TextPosition, BboxStyle
2+
import numpy as np
3+
import cv2
4+
5+
with OakCamera() as oak:
6+
color = oak.create_camera('color')
7+
8+
det = oak.create_nn('face-detection-retail-0004', color)
9+
# AspectRatioResizeMode has to be CROP for 2-stage pipelines at the moment
10+
det.config_nn(aspectRatioResizeMode=AspectRatioResizeMode.CROP)
11+
12+
age_gender = oak.create_nn('age-gender-recognition-retail-0013', input=det)
13+
# age_gender.config_multistage_nn(show_cropped_frames=True) # For debugging
14+
15+
def cb(packet: TwoStagePacket, visualizer: Visualizer):
16+
for det, rec in zip(packet.detections, packet.nnData):
17+
age = int(float(np.squeeze(np.array(rec.getLayerFp16('age_conv3')))) * 100)
18+
gender = np.squeeze(np.array(rec.getLayerFp16('prob')))
19+
gender_str = "woman" if gender[0] > gender[1] else "man"
20+
21+
visualizer.add_text(f'{gender_str}\nage: {age}',
22+
bbox=(*det.top_left, *det.bottom_right),
23+
position=TextPosition.BOTTOM_RIGHT)
24+
25+
frame = visualizer.draw(packet.frame)
26+
cv2.imshow('Age-gender estimation', frame)
27+
28+
29+
# Visualize detections on the frame. Don't show the frame but send the packet
30+
# to the callback function (where it will be displayed)
31+
oak.visualize(age_gender, callback=cb).detections(fill_transparency=0.1)
32+
oak.visualize(det.out.passthrough)
33+
oak.visualize(age_gender.out.twostage_crops, scale=3.0)
34+
35+
36+
# oak.show_graph() # Show pipeline graph, no need for now
37+
oak.start(blocking=True) # This call will block until the app is stopped (by pressing 'Q' button)

gen2-age-gender/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
depthai-sdk==1.9.1
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)