Code: Select all
import sensor, image, time, os, nn
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565
sensor.set_framesize(sensor.QQVGA) # Set frame size to QVGA (320x240)
sensor.set_windowing((32, 64)) # Set 128x128 window.
sensor.skip_frames(time=1000)
net = nn.load('/person.network')
clock = time.clock() # Create a clock object to track the FPS.
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
out = net.forward(img, softmax=True)
if out.index(max(out)) == 0:
print("person detected")