Update example scripts

This commit is contained in:
Kwabena W. Agyeman 2022-02-07 20:47:27 -08:00
parent b320334efd
commit 9a0d65b527
6 changed files with 12 additions and 12 deletions

View File

@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
net = tf.load('person_detection')
labels = ['person', 'no_person']
labels, net = tf.load_builtin_model('person_detection')
clock = time.clock()
while(True):

View File

@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
net = tf.load('person_detection')
labels = ['person', 'no_person']
labels, net = tf.load_builtin_model('person_detection')
clock = time.clock()
while(True):

View File

@ -115,11 +115,13 @@ def face_detection(data):
# When called returns if there's a "person" or "no_person" within view.
#
# data is unused
labels, net = tf.load_builtin_model('person_detection')
def person_detection(data):
global net
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
scores = tf.classify("person_detection", sensor.snapshot())[0].output()
return ['person', 'no_person'][scores.index(max(scores))].encode()
scores = net.classify(sensor.snapshot())[0].output()
return labels[scores.index(max(scores))].encode()
# When called returns the payload string for the largest qrcode
# within the OpenMV Cam's field-of-view.

View File

@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
net = tf.load('person_detection')
labels = ['person', 'no_person']
labels, net = tf.load_builtin_model('person_detection')
clock = time.clock()
while(True):

View File

@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
sensor.skip_frames(time=2000) # Let the camera adjust.
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
net = tf.load('person_detection')
labels = ['person', 'no_person']
labels, net = tf.load_builtin_model('person_detection')
clock = time.clock()
while(True):

View File

@ -115,11 +115,13 @@ def face_detection(data):
# When called returns if there's a "person" or "no_person" within view.
#
# data is unused
labels, net = tf.load_builtin_model('person_detection')
def person_detection(data):
global net
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
scores = tf.classify("person_detection", sensor.snapshot())[0].output()
return ['person', 'no_person'][scores.index(max(scores))].encode()
scores = net.classify(sensor.snapshot())[0].output()
return labels[scores.index(max(scores))].encode()
# When called returns the payload string for the largest qrcode
# within the OpenMV Cam's field-of-view.