Do face recognition on a nao’s camera stream
...
WARNING: this pseudeocode for the next version, use only as a reference of how to set up a structure to the image above
...
title | Setters |
---|
...
language | py |
---|
...
Before going through this tutorial, you should have the following set up:
Start the Redis server:
Make sure the dependencies for the face recognition service are installed in your virtual environment:
Code Block pip install social-interaction-cloud[face-recognition]
Use the following command to start the face recognition service, and pass the model files (the cascade classifier file used in this example can be found here: haarcascade_frontalface_default.xml, and the resnet50 model file can be found here resnet50_ft_weight.pt):
Code Block run-face-recognition --model resnet50_ft_weight.pt --cascadefile haarcascade_frontalface_default.xml
Create a new file with the code below or use demo_desktop_camera_facerecognition.py from GitHub.
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Code Block | ||
---|---|---|
| ||
nao# Connect to the services camera = Nao(ip="192.168.0.1"DesktopCamera() face_recognitionrec = FaceRecognitionDNNFaceRecognition(ip='localhost') nao.top_) # Feed the camera images into the face recognition component face_rec.connect(camera) # Send back the outputs to this program camera.register_callback(seton_image_variable) face_recognitionrec.connect(nao.top_camera) face_recognition.register_callback(set_bbox_variable) while True: image.draw(bbox) display(image)register_callback(on_faces) while True: img = imgs_buffer.get() faces = faces_buffer.get() for face in faces: draw_on_image(face, img) cv2.imshow('', img) cv2.waitKey(1) |
Here is the schematic overview of how this program works. The camera streams its output to the face recognition service, and both stream the output to the program on your laptop.
...