Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 7 Next »

The code for

 Imports and callbacks
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):
    imgs_buffer.put(image_message.image)


faces_buffer = queue.Queue()
def on_faces(message: BoundingBoxesMessage):
    faces_buffer.put(message.bboxes)

# code continues below

# Connect to the services
camera = DesktopCamera()
face_rec = DNNFaceRecognition()

# Feed the camera images into the face recognition component
face_rec.connect(camera)

# Send back the outputs to this program
camera.register_callback(on_image)
face_rec.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.

  • No labels