def main(): """Face detection camera inference example.""" parser = argparse.ArgumentParser() parser.add_argument('--num_frames', '-n', type=int, dest='num_frames', default=None, help='Sets the number of frames to run for, otherwise runs forever.') args = parser.parse_args() leds = Leds() leds.reset() leds.update(Leds.privacy_on()) noCustomerDelay = 0; with PiCamera(sensor_mode=4, resolution=(1640, 1232)) as camera: # with PiCamera(sensor_mode=4, resolution=(1640, 1232), framerate=30) as camera: # with PiCamera() as camera: camera.start_preview() with CameraInference(face_detection.model()) as inference: for result in inference.run(): if len(face_detection.get_faces(result)) >= 1: noCustomerDelay = 0 leds.update(Leds.rgb_on(GREEN)) # stream = io.BytesIO() # camera.capture(stream, format='jpeg') # stream.seek(0) camera.capture('faces.jpg') faces = GetFaceId('faces.jpg') print(faces) if(len(faces) > 0): result = GetUserId(faces[0]) print(result) highestScore = 0 userId = "" for face in result: for candidate in face['candidates']: if(highestScore < candidate['confidence']): userId = candidate['personId'] InfoVendingMachine("10", userId) print(userId) # break else: if noCustomerDelay >= 30: leds.update(Leds.rgb_on(WHITE)) InfoVendingMachine("10", '') noCustomerDelay = 0; else: noCustomerDelay += 1; camera.stop_preview() leds.reset()
print('RGB: Solid CYAN for 1 second') leds.update(Leds.rgb_on(CYAN)) time.sleep(1) print('RGB: Solid WHITE for 1 second') leds.update(Leds.rgb_on(WHITE)) time.sleep(1) print('RGB: Off for 1 second') leds.update(Leds.rgb_off()) time.sleep(1) for _ in range(3): print('Privacy: On (brightness=default)') leds.update(Leds.privacy_on()) time.sleep(1) print('Privacy: Off') leds.update(Leds.privacy_off()) time.sleep(1) for _ in range(3): print('Privacy: On (brightness=5)') leds.update(Leds.privacy_on(5)) time.sleep(1) print('Privacy: Off') leds.update(Leds.privacy_off()) time.sleep(1) print('Set blink pattern: period=500ms (2Hz)') leds.pattern = Pattern.blink(500)