pub struct FaceRepo<'a> { /* private fields */ }Implementations§
Source§impl<'a> FaceRepo<'a>
impl<'a> FaceRepo<'a>
pub fn refresh_all_galleries(&self) -> SqliteResult<()>
Sourcepub fn face_thumbnail_candidates(
&self,
cluster_ids: &[i64],
max_per_cluster: usize,
) -> SqliteResult<HashMap<i64, Vec<i64>>>
pub fn face_thumbnail_candidates( &self, cluster_ids: &[i64], max_per_cluster: usize, ) -> SqliteResult<HashMap<i64, Vec<i64>>>
Return fallback face thumbnail candidates for the supplied clusters.
The rows are ordered by cluster, then by face confidence descending. Callers can check the corresponding crop files outside the shared DB mutex and then persist any representative replacement in one batch.
pub fn update_representative_faces( &self, updates: &[(i64, i64)], ) -> SqliteResult<()>
Sourcepub fn normalize_cluster_stats(&self) -> SqliteResult<()>
pub fn normalize_cluster_stats(&self) -> SqliteResult<()>
Recompute all cluster stats and prune empty clusters.
Sourcepub fn populate_face_thumbnails(
&self,
clusters: &mut [FaceClusterRecord],
drive_path: &Path,
) -> SqliteResult<()>
pub fn populate_face_thumbnails( &self, clusters: &mut [FaceClusterRecord], drive_path: &Path, ) -> SqliteResult<()>
Populate face thumbnail paths on cluster records.
Call this after get_all_clusters() with the drive root path. The
path written into each cluster is relative to drive_root (e.g.
.photovault/faces/42.jpg) so it round-trips through the same
frontend thumbUrl() helper as photos.thumbnail_path.
Source§impl<'a> FaceRepo<'a>
impl<'a> FaceRepo<'a>
Sourcepub fn get_recent_faces(&self, limit: usize) -> SqliteResult<Vec<FaceDetail>>
pub fn get_recent_faces(&self, limit: usize) -> SqliteResult<Vec<FaceDetail>>
A live preview is a newest-first snapshot, not the oldest review page.
Sourcepub fn count_pending_face_processing(&self) -> SqliteResult<i64>
pub fn count_pending_face_processing(&self) -> SqliteResult<i64>
Count of photos that haven’t yet had face detection run. Drives the “Resume face detection” banner on the People page.
Sourcepub fn get_unclustered_faces_with_photo_embeddings(
&self,
) -> SqliteResult<Vec<(i64, i64, FaceEmbedding)>>
pub fn get_unclustered_faces_with_photo_embeddings( &self, ) -> SqliteResult<Vec<(i64, i64, FaceEmbedding)>>
Get unclustered faces with photo_id and embeddings.
Sourcepub fn get_unclustered_embeddings_after(
&self,
after_id: i64,
) -> SqliteResult<Vec<(i64, i64, FaceEmbedding)>>
pub fn get_unclustered_embeddings_after( &self, after_id: i64, ) -> SqliteResult<Vec<(i64, i64, FaceEmbedding)>>
Streaming assignment considers only newly committed faces.
Sourcepub fn get_all_clusters(&self) -> SqliteResult<Vec<FaceClusterRecord>>
pub fn get_all_clusters(&self) -> SqliteResult<Vec<FaceClusterRecord>>
Get all clusters, ordered by photo count descending
pub fn get_gallery_embeddings(&self) -> SqliteResult<Vec<GalleryEmbedding>>
pub fn get_cluster_photo_ids(&self) -> SqliteResult<Vec<(i64, i64)>>
Sourcepub fn get_face_boxes_for_photos(
&self,
photo_ids: &[i64],
) -> SqliteResult<Vec<(i64, f32, f32, f32, f32)>>
pub fn get_face_boxes_for_photos( &self, photo_ids: &[i64], ) -> SqliteResult<Vec<(i64, f32, f32, f32, f32)>>
Normalised face boxes (photo_id, x, y, width, height) for the given
photos, in display orientation. Used to keep faces in frame when a
photo is cropped into a collage cell.
Sourcepub fn faces_in_photo(&self, photo_id: i64) -> SqliteResult<Vec<PhotoFace>>
pub fn faces_in_photo(&self, photo_id: i64) -> SqliteResult<Vec<PhotoFace>>
The faces in one photo, left to right, with who each one is. Faces set aside as “not a face” are left out.
Sourcepub fn get_people_for_photo(
&self,
photo_id: i64,
) -> SqliteResult<Vec<(i64, String)>>
pub fn get_people_for_photo( &self, photo_id: i64, ) -> SqliteResult<Vec<(i64, String)>>
Get person names for a photo (faces detected in this photo with cluster names) Get (cluster_id, display_name) pairs for all people detected in a photo.
Sourcepub fn get_photos_for_cluster(&self, cluster_id: i64) -> SqliteResult<Vec<i64>>
pub fn get_photos_for_cluster(&self, cluster_id: i64) -> SqliteResult<Vec<i64>>
Get all photo IDs that contain faces from a given cluster
Sourcepub fn get_contextual_cluster_candidates(
&self,
photo_id: i64,
folder_prefix_like: Option<&str>,
target_ts: i64,
window_secs: i64,
) -> SqliteResult<Vec<(i64, i64, i64, String)>>
pub fn get_contextual_cluster_candidates( &self, photo_id: i64, folder_prefix_like: Option<&str>, target_ts: i64, window_secs: i64, ) -> SqliteResult<Vec<(i64, i64, i64, String)>>
Find contextual candidate identities from nearby photos in the same folder.
Sourcepub fn get_unprocessed_photos_with_context(
&self,
) -> SqliteResult<Vec<(i64, String, i32, Option<i64>, String)>>
pub fn get_unprocessed_photos_with_context( &self, ) -> SqliteResult<Vec<(i64, String, i32, Option<i64>, String)>>
Get unprocessed photos with optional timestamp for contextual identity linking.
Sourcepub fn get_photo_brightness(&self, photo_id: i64) -> SqliteResult<Option<f32>>
pub fn get_photo_brightness(&self, photo_id: i64) -> SqliteResult<Option<f32>>
Read the cached photos.brightness value for a photo. Returns
None if the photo doesn’t exist OR brightness was never
computed (NULL in the column). Caller is expected to fall back
to on-disk recomputation in that case.
Sourcepub fn get_photo_other_clusters(
&self,
photo_id: i64,
exclude_face_id: i64,
) -> SqliteResult<Vec<i64>>
pub fn get_photo_other_clusters( &self, photo_id: i64, exclude_face_id: i64, ) -> SqliteResult<Vec<i64>>
Cluster IDs of the already-assigned faces in the given photo (other than the face we’re resolving). Used as the “context” in co-occurrence.
Sourcepub fn cooccurrence_count(
&self,
cluster_a: i64,
cluster_b: i64,
) -> SqliteResult<i64>
pub fn cooccurrence_count( &self, cluster_a: i64, cluster_b: i64, ) -> SqliteResult<i64>
How many photos contain both cluster_a and cluster_b.
Used as the co-occurrence strength between two clusters. High values mean the two people appear together frequently and should bias retrieval toward whichever matches the rest of the photo’s cast.
Sourcepub fn temporal_neighbor_clusters(
&self,
photo_id: i64,
window_secs: i64,
) -> SqliteResult<Vec<(i64, i64)>>
pub fn temporal_neighbor_clusters( &self, photo_id: i64, window_secs: i64, ) -> SqliteResult<Vec<(i64, i64)>>
Clusters assigned to faces within a time window around date_taken,
excluding the photo itself. Returns (cluster_id, delta_seconds).
Used for temporal-chain propagation: if nearby-in-time photos contain high-confidence assignments for cluster X, an ambiguous face in our photo should be biased toward X.
Sourcepub fn get_faces_by_cluster(
&self,
cluster_id: i64,
status: FaceStatus,
cursor: Option<i64>,
limit: usize,
) -> SqliteResult<Vec<FaceDetail>>
pub fn get_faces_by_cluster( &self, cluster_id: i64, status: FaceStatus, cursor: Option<i64>, limit: usize, ) -> SqliteResult<Vec<FaceDetail>>
Get faces for a cluster filtered by status.
Sourcepub fn get_unclustered_faces(
&self,
cursor: Option<i64>,
limit: usize,
) -> SqliteResult<Vec<FaceDetail>>
pub fn get_unclustered_faces( &self, cursor: Option<i64>, limit: usize, ) -> SqliteResult<Vec<FaceDetail>>
Recently detected faces that are not assigned to a person yet. Used only as a live, in-progress surface while the face pipeline is still clustering. The final People grid remains cluster-based.
Sourcepub fn count_unconfirmed_global(&self) -> SqliteResult<(i64, i64)>
pub fn count_unconfirmed_global(&self) -> SqliteResult<(i64, i64)>
Count unconfirmed faces across all clusters, leaving out ones the user skipped in review. Returns (total_unconfirmed, clusters_with_unconfirmed).
Sourcepub fn next_unconfirmed_face_batch_excluding(
&self,
limit: usize,
excluded_face_ids: &[i64],
) -> SqliteResult<Vec<FaceDetail>>
pub fn next_unconfirmed_face_batch_excluding( &self, limit: usize, excluded_face_ids: &[i64], ) -> SqliteResult<Vec<FaceDetail>>
Return the next review batch, leaving out faces the user skipped.
A skip isn’t a confirm or reject decision; it just takes the face
out of review (see skip_review_face). excluded_face_ids are
this session’s skips still in flight.
Sourcepub fn get_negatives_for_face(&self, face_id: i64) -> SqliteResult<Vec<i64>>
pub fn get_negatives_for_face(&self, face_id: i64) -> SqliteResult<Vec<i64>>
Get negatives for a face (clusters it should NOT be in).
Source§impl<'a> FaceRepo<'a>
impl<'a> FaceRepo<'a>
pub fn face_state(&self, face_id: i64) -> SqliteResult<Option<FaceState>>
pub fn snapshot_face(&self, face_id: i64) -> SqliteResult<FaceSnapshot>
Sourcepub fn restore_face(&self, snapshot: &FaceSnapshot) -> SqliteResult<()>
pub fn restore_face(&self, snapshot: &FaceSnapshot) -> SqliteResult<()>
Put a face back as it was in snapshot. The caller checks first that
nothing else has changed the face since the decision.
Source§impl<'a> FaceRepo<'a>
impl<'a> FaceRepo<'a>
Sourcepub fn name_cluster(&self, cluster_id: i64, name: &str) -> SqliteResult<()>
pub fn name_cluster(&self, cluster_id: i64, name: &str) -> SqliteResult<()>
Name a cluster (set the person’s name)
Sourcepub fn delete_cluster(&self, cluster_id: i64) -> SqliteResult<()>
pub fn delete_cluster(&self, cluster_id: i64) -> SqliteResult<()>
Delete a face cluster — “this isn’t a real person” gesture.
Its faces are set aside (user_confirmed = -1), so the next
clustering pass doesn’t quietly rebuild the same person.
Inferred-identity links and gallery embeddings rooted at the
cluster cascade away (FK ON DELETE CASCADE in the schema).
Sourcepub fn ignore_face(&self, face_id: i64) -> SqliteResult<()>
pub fn ignore_face(&self, face_id: i64) -> SqliteResult<()>
“Not a face”: set a detection aside for good. It leaves its person
and clustering never picks it up again (user_confirmed = -1).
Sourcepub fn delete_face(&self, face_id: i64) -> SqliteResult<()>
pub fn delete_face(&self, face_id: i64) -> SqliteResult<()>
Delete a face and everything recorded about it (a hand-added face being taken back). Its person’s count and gallery follow.
Sourcepub fn skip_review_face(&self, face_id: i64) -> SqliteResult<()>
pub fn skip_review_face(&self, face_id: i64) -> SqliteResult<()>
Take a face out of review without deciding about it (“not sure”). It keeps its person; review just stops asking.
Sourcepub fn assign_face_to_cluster(
&self,
face_id: i64,
cluster_id: i64,
) -> SqliteResult<()>
pub fn assign_face_to_cluster( &self, face_id: i64, cluster_id: i64, ) -> SqliteResult<()>
Assign an existing face to an existing cluster and update cluster metadata.
Sourcepub fn create_cluster(&self, face_ids: &[i64]) -> SqliteResult<i64>
pub fn create_cluster(&self, face_ids: &[i64]) -> SqliteResult<i64>
Create a new face cluster from a set of face IDs
Sourcepub fn merge_clusters(
&self,
source_id: i64,
target_id: i64,
) -> SqliteResult<Option<MergeReceipt>>
pub fn merge_clusters( &self, source_id: i64, target_id: i64, ) -> SqliteResult<Option<MergeReceipt>>
Merge source cluster into target cluster
Moves all faces from source to target, updates counts, deletes source. Refuses if a cannot-merge constraint exists between the two clusters.
Sourcepub fn unmerge_clusters(&self, receipt: &MergeReceipt) -> SqliteResult<()>
pub fn unmerge_clusters(&self, receipt: &MergeReceipt) -> SqliteResult<()>
Undo a merge: bring the source person back with their faces and remember the two are different people, so clustering never merges them again. Inferred photo links are rebuilt by the next face pass.
Sourcepub fn get_cannot_merge_map(&self) -> SqliteResult<HashMap<i64, HashSet<i64>>>
pub fn get_cannot_merge_map(&self) -> SqliteResult<HashMap<i64, HashSet<i64>>>
Load all cannot-merge pairs (returns them in both directions for easy lookup).
Sourcepub fn confirm_face(&self, face_id: i64) -> SqliteResult<()>
pub fn confirm_face(&self, face_id: i64) -> SqliteResult<()>
Confirm a face: set user_confirmed=1. Add to gallery if not already.
Sourcepub fn reject_face_to_unknown(
&self,
face_id: i64,
prev_cluster_id: i64,
) -> SqliteResult<()>
pub fn reject_face_to_unknown( &self, face_id: i64, prev_cluster_id: i64, ) -> SqliteResult<()>
Reject face to unknown: set cluster_id=NULL, user_confirmed=0. Write negative.
Sourcepub fn reassign_face(
&self,
face_id: i64,
new_cluster_id: i64,
old_cluster_id: i64,
) -> SqliteResult<()>
pub fn reassign_face( &self, face_id: i64, new_cluster_id: i64, old_cluster_id: i64, ) -> SqliteResult<()>
Reassign a face to a different cluster. Marks user_confirmed=1, writes negative against the old cluster_id so it won’t come back.
Sourcepub fn confirm_face_to_cluster(
&self,
face_id: i64,
cluster_id: i64,
) -> SqliteResult<()>
pub fn confirm_face_to_cluster( &self, face_id: i64, cluster_id: i64, ) -> SqliteResult<()>
Confirm a currently-unassigned face into a cluster (used by K-similar flow).
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for FaceRepo<'a>
impl<'a> !Send for FaceRepo<'a>
impl<'a> !Sync for FaceRepo<'a>
impl<'a> !UnwindSafe for FaceRepo<'a>
impl<'a> Freeze for FaceRepo<'a>
impl<'a> Unpin for FaceRepo<'a>
impl<'a> UnsafeUnpin for FaceRepo<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more