mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update example scripts
This commit is contained in:
parent
b320334efd
commit
9a0d65b527
@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
|
|||||||
sensor.skip_frames(time=2000) # Let the camera adjust.
|
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).
|
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
|
||||||
net = tf.load('person_detection')
|
labels, net = tf.load_builtin_model('person_detection')
|
||||||
labels = ['person', 'no_person']
|
|
||||||
|
|
||||||
clock = time.clock()
|
clock = time.clock()
|
||||||
while(True):
|
while(True):
|
||||||
|
|||||||
@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
|
|||||||
sensor.skip_frames(time=2000) # Let the camera adjust.
|
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).
|
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
|
||||||
net = tf.load('person_detection')
|
labels, net = tf.load_builtin_model('person_detection')
|
||||||
labels = ['person', 'no_person']
|
|
||||||
|
|
||||||
clock = time.clock()
|
clock = time.clock()
|
||||||
while(True):
|
while(True):
|
||||||
|
|||||||
@ -115,11 +115,13 @@ def face_detection(data):
|
|||||||
# When called returns if there's a "person" or "no_person" within view.
|
# When called returns if there's a "person" or "no_person" within view.
|
||||||
#
|
#
|
||||||
# data is unused
|
# data is unused
|
||||||
|
labels, net = tf.load_builtin_model('person_detection')
|
||||||
def person_detection(data):
|
def person_detection(data):
|
||||||
|
global net
|
||||||
sensor.set_pixformat(sensor.GRAYSCALE)
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
||||||
sensor.set_framesize(sensor.QVGA)
|
sensor.set_framesize(sensor.QVGA)
|
||||||
scores = tf.classify("person_detection", sensor.snapshot())[0].output()
|
scores = net.classify(sensor.snapshot())[0].output()
|
||||||
return ['person', 'no_person'][scores.index(max(scores))].encode()
|
return labels[scores.index(max(scores))].encode()
|
||||||
|
|
||||||
# When called returns the payload string for the largest qrcode
|
# When called returns the payload string for the largest qrcode
|
||||||
# within the OpenMV Cam's field-of-view.
|
# within the OpenMV Cam's field-of-view.
|
||||||
|
|||||||
@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
|
|||||||
sensor.skip_frames(time=2000) # Let the camera adjust.
|
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).
|
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
|
||||||
net = tf.load('person_detection')
|
labels, net = tf.load_builtin_model('person_detection')
|
||||||
labels = ['person', 'no_person']
|
|
||||||
|
|
||||||
clock = time.clock()
|
clock = time.clock()
|
||||||
while(True):
|
while(True):
|
||||||
|
|||||||
@ -15,8 +15,7 @@ sensor.set_windowing((240, 240)) # Set 240x240 window.
|
|||||||
sensor.skip_frames(time=2000) # Let the camera adjust.
|
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).
|
# Load the built-in person detection network (the network is in your OpenMV Cam's firmware).
|
||||||
net = tf.load('person_detection')
|
labels, net = tf.load_builtin_model('person_detection')
|
||||||
labels = ['person', 'no_person']
|
|
||||||
|
|
||||||
clock = time.clock()
|
clock = time.clock()
|
||||||
while(True):
|
while(True):
|
||||||
|
|||||||
@ -115,11 +115,13 @@ def face_detection(data):
|
|||||||
# When called returns if there's a "person" or "no_person" within view.
|
# When called returns if there's a "person" or "no_person" within view.
|
||||||
#
|
#
|
||||||
# data is unused
|
# data is unused
|
||||||
|
labels, net = tf.load_builtin_model('person_detection')
|
||||||
def person_detection(data):
|
def person_detection(data):
|
||||||
|
global net
|
||||||
sensor.set_pixformat(sensor.RGB565)
|
sensor.set_pixformat(sensor.RGB565)
|
||||||
sensor.set_framesize(sensor.QVGA)
|
sensor.set_framesize(sensor.QVGA)
|
||||||
scores = tf.classify("person_detection", sensor.snapshot())[0].output()
|
scores = net.classify(sensor.snapshot())[0].output()
|
||||||
return ['person', 'no_person'][scores.index(max(scores))].encode()
|
return labels[scores.index(max(scores))].encode()
|
||||||
|
|
||||||
# When called returns the payload string for the largest qrcode
|
# When called returns the payload string for the largest qrcode
|
||||||
# within the OpenMV Cam's field-of-view.
|
# within the OpenMV Cam's field-of-view.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user