-
-
Save tomoto/85d88a5b2b91fc581ee3675e18e379ca to your computer and use it in GitHub Desktop.
NCS2 experiment on Raspberry Pi
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
#!/usr/bin/perl | |
$| = 1; | |
my($data); | |
sub emit_if_complete { | |
my($d) = @_; | |
if ($d->{'g'} && $d->{'e'}) { | |
print qq/{"g":"$d->{'g'}","e":"$d->{'e'}"}\n/; | |
} | |
} | |
while (<>) { | |
if (/^\[0,1\]/) { | |
# reset | |
$data = {}; | |
} | |
if (!$data->{'g'} && /Predicted gender, age = ([FM]),(\d+)/) { | |
$data->{'g'} = $1; | |
&emit_if_complete($data) | |
} | |
if (!$data->{'e'} && /Predicted emotion = (\w+)/) { | |
$data->{'e'} = $1; | |
&emit_if_complete($data); | |
} | |
} |
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
device=MYRIAD | |
fpmode=FP16 | |
bin/interactive_face_detection_demo \ | |
-d ${device} -m intel_models/face-detection-retail-0004/${fpmode}/face-detection-retail-0004.xml \ | |
-d_ag ${device} -m_ag intel_models/age-gender-recognition-retail-0013/${fpmode}/age-gender-recognition-retail-0013.xml \ | |
-d_em ${device} -m_em intel_models/emotions-recognition-retail-0003/${fpmode}/emotions-recognition-retail-0003.xml \ | |
-d_hp ${device} -m_hp intel_models/head-pose-estimation-adas-0001/${fpmode}/head-pose-estimation-adas-0001.xml \ | |
$* |
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
./face.sh -r $* | tee >(./extract_emotion_and_gender.pl | sudo ./show_emotion_and_gender.py) |
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
./bin/object_detection_demo_ssd_async -d MYRIAD -m mobilenet-ssd/FP16/mobilenet-ssd.xml $* |
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
model=$1 | |
url_base=https://download.01.org/openvinotoolkit/2018_R4/open_model_zoo | |
out_base=intel_models | |
cmd="wget --no-check-certificate" | |
function get_files { | |
fpmode=$1 | |
p=$model/$fpmode | |
mkdir -p $out_base/$p | |
$cmd $url_base/$p/$model.bin -O $out_base/$p/$model.bin | |
$cmd $url_base/$p/$model.xml -O $out_base/$p/$model.xml | |
} | |
get_files FP16 | |
# get_files FP32 |
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
#!/usr/bin/env python | |
import unicornhat as unicorn | |
import time | |
import json | |
import sys | |
import os | |
unicorn.set_layout(unicorn.AUTO) | |
unicorn.rotation(270) | |
unicorn.brightness(0.4) | |
width,height=unicorn.get_shape() | |
faces = { | |
'neutral': [ | |
"00000000", | |
"01000010", | |
"01000010", | |
"00000000", | |
"00000000", | |
"01111110", | |
"00000000", | |
"00000000", | |
], | |
'happy': [ | |
"00000000", | |
"01000010", | |
"10100101", | |
"00000000", | |
"01000010", | |
"00100100", | |
"00011000", | |
"00000000", | |
], | |
'sad': [ | |
"00000000", | |
"01100110", | |
"10000001", | |
"00000000", | |
"00011000", | |
"00100100", | |
"01000010", | |
"00000000", | |
], | |
'surprise': [ | |
"01000010", | |
"10100101", | |
"01000010", | |
"00000000", | |
"00011000", | |
"00100100", | |
"00100100", | |
"00011000", | |
], | |
'anger': [ | |
"00000000", | |
"11000011", | |
"00100100", | |
"00000000", | |
"00011000", | |
"00100100", | |
"01000010", | |
"00000000", | |
], | |
}; | |
def show_matrix(matrix, r, g, b): | |
for y, row in enumerate(matrix): | |
for x, p in enumerate(row): | |
if p == '1': | |
unicorn.set_pixel(x, y, r, g, b) | |
else: | |
unicorn.set_pixel(x, y, 0, 0, 0) | |
unicorn.show() | |
def process(data): | |
f = faces[data['e']] | |
if data['g'] == 'F': | |
r, g, b = 255, 0, 200 | |
else : | |
r, g, b = 0, 200, 255 | |
show_matrix(f, r, g, b) | |
while True: | |
line = sys.stdin.readline() | |
data = json.loads(line) | |
process(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment