Struct FaceEnrollmentAutomatic
pub struct FaceEnrollmentAutomatic(/* private fields */);
Expand description
Automatic face enrollment functionality.
Implementations§
§impl FaceEnrollmentAutomatic
impl FaceEnrollmentAutomatic
pub fn get_face_ids(&self) -> Vec<FaceID>
pub fn get_face_ids(&self) -> Vec<FaceID>
Return the face IDs of all automatically enrolled faces.
This list of face IDs is not related to the faces currently in view. The
face IDs returned by this function are all faces that have ever been
enrolled into the face library. To retrieve information about the faces
currently in view, use FaceIdentification::get_face_id
.
pub fn max_face_library_size(&self) -> usize
pub fn max_face_library_size(&self) -> usize
Returns the maximum size of the face library.
When the library is full and new faces are detected, they will overwrite
older faces, except for faces that are tagged as important using
tag_face_id
. When all faces are tagged as important, new faces will not
be added to the library beyond this maximum size.
pub fn tag_face_id(
&mut self,
face_id: &FaceID,
tag: FaceIDTag,
) -> Result<(), Error>
pub fn tag_face_id( &mut self, face_id: &FaceID, tag: FaceIDTag, ) -> Result<(), Error>
Tag a face ID as ‘important’ to prevent it from being overwritten.
When the face library is full and a new face is encountered, the algorithm will overwrite the oldest face in the library that is not tagged as important. A typical use-case of this is to tag a face as important when the user has named them in a front-end application.
When all entries in the face library are tagged as important and a new face is encountered, then no new faces will be enrolled.
By default, an automatically enrolled face is not tagged as important.
However, library entries created by restore_enrollment_data
are
automatically tagged as important.
§Errors
Error::InvalidFaceID
pub fn remove_face_id(&mut self, face_id: FaceID) -> Result<(), Error>
pub fn remove_face_id(&mut self, face_id: FaceID) -> Result<(), Error>
Remove a face ID from the face library for any
VideoIntelligence::process_frame
calls that follow.
§Errors
Error::InvalidFaceID
pub fn remove_all_face_ids(&mut self)
pub fn remove_all_face_ids(&mut self)
Remove all face IDs from the face library.
pub fn get_enrollment_data(
&self,
face_id: &FaceID,
snapshot_options: SnapshotOptions,
) -> Result<EnrollmentData, Error>
pub fn get_enrollment_data( &self, face_id: &FaceID, snapshot_options: SnapshotOptions, ) -> Result<EnrollmentData, Error>
Get the face enrollment data for a face ID, for persistent storage.
This can for example be used to store the face library when a device shuts down and restore it later when it reboots.
This enrollment data can change during any
VideoIntelligence::process_frame
call.
§Errors
Error::InvalidFaceID
pub fn restore_enrollment_data(
&mut self,
face_id: &FaceID,
enrollment_data: EnrollmentData,
) -> Result<(), Error>
pub fn restore_enrollment_data( &mut self, face_id: &FaceID, enrollment_data: EnrollmentData, ) -> Result<(), Error>
Restore the face enrollment data for a face ID, from persistent storage.
When the specified face_id
does not yet exist then it will be created.
When the specified face_id
already exists, the internal enrollment data
will be overwritten with new enrollment data. If the new enrollment data
is corrupt, this will result in removal of the existing face enrollment
data.
If a new face_id
was created, this function will automatically tag it as
‘important’, see also tag_face_id
.
If the enrollment data does not include a face snapshot, then a face
snapshot for this face ID will not be available.
If the enrollment data includes a face snapshot, then
configure_face_snapshots
must have been called first, with enabled
set
to true
and the same height
and width
as the stored data.
§Errors
Error::InvalidFaceID
Error::FaceLibraryFull
Error::StateCorrupt
pub fn merge_face_ids(
&mut self,
face_id_dst: &FaceID,
face_id_src: FaceID,
) -> Result<(), Error>
pub fn merge_face_ids( &mut self, face_id_dst: &FaceID, face_id_src: FaceID, ) -> Result<(), Error>
Merge two entries of the face library.
If a single person is enrolled twice in the face library, this function
can be used to merge their enrollments back to a single one.
After calling this function face_id_src
is no longer valid and
face_id_dst
will be updated with the additional information from
face_id_src
.
§Errors
Error::InvalidFaceID
pub fn get_face_enrollment_track_ids(
&self,
face_id: &FaceID,
) -> Result<Vec<TrackID>, Error>
pub fn get_face_enrollment_track_ids( &self, face_id: &FaceID, ) -> Result<Vec<TrackID>, Error>
Return the track IDs for an automatically enrolled face.
The caller must provide a buffer of size at least max_tracks_per_face_id
integers.
A face enrollment (face ID) can be made up of multiple person tracks, each of which is identified with a track ID. When a person is re-identified and their new face information is considered relevant for the algorithm, the new person track will be added to the existing face enrollment, or replace a previous one.
This list of track IDs can therefore change after processing any video frame.
§Errors
Error::InvalidFaceID
pub fn max_tracks_per_face_id(&self) -> usize
pub fn max_tracks_per_face_id(&self) -> usize
Returns the maximum number of tracks that a single face ID in the library consists of.
See get_face_enrollment_track_ids
for more information.
When a face ID already has the maximum number of tracks stored, then a new person track will only update this face ID if it is of better quality than the existing tracks.
pub fn remove_face_enrollment_track(
&mut self,
face_id: &FaceID,
track_id: TrackID,
) -> Result<(), Error>
pub fn remove_face_enrollment_track( &mut self, face_id: &FaceID, track_id: TrackID, ) -> Result<(), Error>
Remove a track that is part of a face enrollment.
This can be used if the Plumerai library made a mistake with automatic enrollment, and a user wants to manually correct the face library. By inspecting the face snapshots of each track ID, the user can decide to remove a wrong track.
If this was the only track of face_id
then this face ID is removed
entirely.
§Errors
Error::InvalidFaceID
Error::InvalidTrackID
pub fn reassign_face_enrollment_track(
&mut self,
face_id_src: FaceID,
track_id_src: TrackID,
face_id_dst: &FaceID,
) -> Result<(), Error>
pub fn reassign_face_enrollment_track( &mut self, face_id_src: FaceID, track_id_src: TrackID, face_id_dst: &FaceID, ) -> Result<(), Error>
Reassign a face track from face ID face_id_src
to a new or existing face
id face_id_dst
.
This can be used if the Plumerai library made a mistake with automatic enrollment, and a user wants to manually correct the face library. By inspecting the face snapshots of each track ID, the user can decide to reassign a track to the correct face ID.
If face_id_dst
does not exist, it will be created. If the face library
is full, this will overwrite the oldest library entry, unless all of them
are tagged as important in which case this function returns
Error::FaceLibraryFull
.
Note the following special behavior:
If face_id_src
has only one track and it is reassigned, then
face_id_src
is automatically removed entirely.
It is possible that one or more existing tracks of face_id_dst
are
overwritten depending on whether the algorithm think it will improve the
overall quality of the face enrollment.
The algorithm may determine that the original tracks of face_id_dst
provide a better enrollment without the newly reassigned track.
In such cases, face_id_dst
remains unchanged, but the track is still
removed from face_id_src
.
§Errors
Error::InvalidFaceID
Error::InvalidTrackID
Error::FaceLibraryFull
pub fn configure_face_snapshots(
&mut self,
settings: FaceSnapshotSettings,
) -> Result<(), Error>
pub fn configure_face_snapshots( &mut self, settings: FaceSnapshotSettings, ) -> Result<(), Error>
Configure the face snapshots for automatic enrollment.
By default, face snapshots are disabled.
§Errors
Error::InvalidSnapshotResolution
pub fn get_face_snapshot(
&self,
face_id: &FaceID,
track_id: &TrackID,
) -> Result<FaceSnapshot, Error>
pub fn get_face_snapshot( &self, face_id: &FaceID, track_id: &TrackID, ) -> Result<FaceSnapshot, Error>
Return a snapshot of an automatically enrolled face.
A face enrollment can be made up of multiple person tracks.
Every snapshot originates from a single person track.
Use get_face_enrollment_track_ids
to get a list of track IDs to use in
this function.
After every processed frame the list of snapshots can change. New images might be used by the algorithm if they are of higher quality.
§Errors
Error::InvalidFaceID
Error::InvalidTrackID
Error::FaceSnapshotsDisabled