Skip to content
Snippets Groups Projects
Commit a6098179 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Merge branch 'face-detection' into 'master'

Face recognition

See merge request !146
parents 96f115f7 4347e303
No related branches found
No related tags found
1 merge request!146Face recognition
......@@ -5,6 +5,7 @@ import typing as ty
import numpy as np
from armarx_core import ice_manager
from armarx.parser import ArmarXArgumentParser as ArgumentParser
from armarx_memory.client import MemoryNameSystem
......@@ -30,12 +31,13 @@ def main():
persons: ty.List[Person] = FaceDetection.query_human_profiles(mns=mns, logger=logger)
if persons:
logger.debug(f"Found {len(persons)} persons with images: {persons}")
logger.info(f"Found {len(persons)} persons with images.")
logger.debug(f"Images: {persons}")
else:
logger.error("No persons with images found. Aborting.")
return
logger.debug("Starting image processor")
logger.info("Starting image processor")
image_processor = FaceDetection(
args.input_provider,
persons=persons,
......@@ -45,6 +47,8 @@ def main():
image_processor.on_connect()
image_processor.update_calibration()
ice_manager.wait_for_shutdown()
if __name__ == "__main__":
main()
......@@ -43,5 +43,5 @@ class FaceRecognition(AronDataclass):
"position3D": self.position_3d.astype(np.float32).reshape(3, 1),
"position2D": self.position_2d.astype(np.int32),
"extents2D": self.extents_2d.astype(np.int32),
"profileID": self.profile_id.to_aron() if self.profile_id else mem.MemoryID().to_aron(),
"profileID": self.profile_id.to_aron() if self.profile_id else None,
})
......@@ -10,13 +10,16 @@ import cv2
import numpy as np
import face_recognition
from armarx_core import cmake_helper
from armarx_core import slice_loader
from armarx import arviz as viz
from armarx_memory import client as mem
from armarx.pose_helper import convert_position_to_global
from armarx import FramedPositionBase
slice_loader.load_armarx_slice("VisionX", "core/ImageProcessorInterface.ice")
slice_loader.load_armarx_slice("VisionX", "components/Calibration.ice")
from armarx_vision.image_processor import ImageProcessor
from visionx import StereoCalibrationInterfacePrx
......@@ -80,11 +83,15 @@ class FaceDetection(ImageProcessor):
abs_path = face_image_path.get_system_path()
if os.path.isfile(abs_path):
name = profile.names.spoken[0] or id.entity_name
if logger is not None:
logger.info("Loading person '%s'.", name)
logger.debug("Creating face encoding for person '%s'.", name)
image = face_recognition.load_image_file(abs_path)
encoding = face_recognition.face_encodings(image)[0]
encodings_of_faces = face_recognition.face_encodings(image)
if len(encodings_of_faces) > 0:
if logger:
logger.info(f"Loaded image of person '{name}' from '{abs_path}.")
encoding = encodings_of_faces[0]
else:
if logger:
logger.info(f"Found no faces in image '{abs_path}' ...")
face_encodings.append(encoding)
......@@ -193,7 +200,7 @@ class FaceDetection(ImageProcessor):
position_3d=position_3d,
position_2d=position_2d,
extents_2d=extents_2d,
profile_id=person.profile_id
profile_id=person.profile_id,
)
face_recognitions.append(recognition)
......
......@@ -10,12 +10,11 @@ python = "^3.6.9"
# armarx-dev = "^0.16.2"
# armarx-dev = { path="../../../python3-armarx/", develop=true } # "^0.16.2"
ipython = "5.5"
zeroc-ice = "^3.7"
numpy = "1.19.5"
numpy = "*"
face-recognition = "^1.3.0"
opencv-python = "4.3.0.36"
peewee = "^3.14.4"
transforms3d = "^0.3.1"
transforms3d = "*"
pyzbar = "^0.1.8"
cbor2 = "^5.4.2"
base45 = "^0.4.3"
......
......@@ -29,8 +29,8 @@
<Time />
</ObjectChild>
<ObjectChild key='profileID'>
<armarx::armem::arondto::MemoryID />
<ObjectChild key='profileID' >
<armarx::armem::arondto::MemoryID optional="true"/>
</ObjectChild>
</Object>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment