Versions Compared

Key

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

The code for

Expand
titleSetters Imports 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 = Nonesic_framework.devices.desktop.desktop_camera import DesktopCamera
from sic_framework.services.face_recognition_dnn.face_recognition_service import DNNFaceRecognition

imgs_buffer = queue.Queue()
def seton_image_variable(img(image_message: CompressedImageMessage):
   image = img

bbox = None
def set_bbox_variable(box imgs_buffer.put(image_message.image)


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

# code continues in code box below

Code Block
languagepy
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.

...