Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • 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 (WIP: find sourcethe 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 https://bitbucket.org/socialroboticshub/framework/src/master/sic_framework/tests/ demo_desktop_camera_facerecognition.py from GitHub.

Expand
titleImports and callbacks
Code Block
languagepy
import queue

import cv2

from sic_framework.core.message_python2 import BoundingBoxesMessage
from sic_framework.core.message_python2 import CompressedImageMessage
from sic_framework.core.utils_cv2 import draw_on_image
from sic_framework.devices.desktop.desktop_camera import DesktopCamera
from sic_framework.services.face_recognition_dnn.face_recognition_service import DNNFaceRecognition

imgs_buffer = queue.Queue()
def on_image(image_message: CompressedImageMessage):
    try:
        imgs_buffer.get_nowait()  # remove previous message if its still there
    except queue.Empty:
        pass
    imgs_buffer.put(image_message.image)


faces_buffer = queue.Queue()
def on_faces(message: BoundingBoxesMessage):
    try:
        faces_buffer.get_nowait()  # remove previous message if its still there
    except queue.Empty:
        pass
    faces_buffer.put(message.bboxes)

# code continues below

...