1 """Component that will help set the Dlib face detect processing."""
3 from __future__
import annotations
7 import face_recognition
10 PLATFORM_SCHEMA
as IMAGE_PROCESSING_PLATFORM_SCHEMA,
11 ImageProcessingFaceEntity,
18 PLATFORM_SCHEMA = IMAGE_PROCESSING_PLATFORM_SCHEMA
24 add_entities: AddEntitiesCallback,
25 discovery_info: DiscoveryInfoType |
None =
None,
27 """Set up the Dlib Face detection platform."""
30 for camera
in config[CONF_SOURCE]
35 """Dlib Face API entity for identify."""
38 """Initialize Dlib face entity."""
46 self.
_name_name = f
"Dlib Face {split_entity_id(camera_entity)[1]}"
50 """Return camera entity id from process pictures."""
55 """Return the name of the entity."""
56 return self.
_name_name
61 fak_file = io.BytesIO(image)
62 fak_file.name =
"snapshot.jpg"
65 image = face_recognition.load_image_file(fak_file)
66 face_locations = face_recognition.face_locations(image)
68 face_locations = [{ATTR_LOCATION: location}
for location
in face_locations]
70 self.
process_facesprocess_faces(face_locations, len(face_locations))
def __init__(self, camera_entity, name=None)
def process_image(self, image)
None process_faces(self, list[FaceInformation] faces, int total)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)