Face Detection on Desktop
Prerequisites
redis server is running
face detection service is running
Code (in separate terminals):
redis-server conf/redis/redis.conf
run-face-detection
Walkthrough
Import necessary libraries
import queue
import cv2
from sic_framework.core import utils_cv2
from sic_framework.core.message_python2 import (
BoundingBoxesMessage,
CompressedImageMessage,
)
from sic_framework.devices.common_desktop.desktop_camera import DesktopCameraConf
from sic_framework.devices.desktop import Desktop
from sic_framework.services.face_detection.face_detection import FaceDetection
Create buffers for image/face objects, define callback functions
Whenever a new image or face detection is received, on_image or on_faces will be called to place the data object into its respective buffer.
imgs_buffer = queue.Queue(maxsize=1)
faces_buffer = queue.Queue(maxsize=1)
def on_image(image_message: CompressedImageMessage):
imgs_buffer.put(image_message.image)
def on_faces(message: BoundingBoxesMessage):
faces_buffer.put(message.bboxes)
Set up the camera, register callback functions
Display face detection
Â
The full code can be found here