ANSFR: name the real cause when enrollment cannot compute embeddings

Enrolling a face while the recognizer engine is down used to store the
user row and silently drop the embedding: InsertUser is a pure DB write,
Feature() returns empty when uninitialized, and InsertFace's size check
misreported that as "Invalid embedding generated" — blaming the face.
The result surfaces hours later as every match returning Unknown/2.0
with nothing in the log saying why (seen on the A400: 45 users, zero
embeddings).

- ANSFRBase gains a public IsInitialized() accessor (flag existed but
  was protected).
- InsertFace / InsertMultipleFaces gate on it before computing the
  embedding and log the true cause: recognizer not initialized, face
  NOT enrolled, fix engine errors then re-enroll.
- The residual invalid-embedding message now reports actual vs expected
  size and the remaining causes (unusable crop / recognizer reloading).
- Reload() warns when the database has users but zero embeddings — the
  one line that identifies stale half-enrolled databases at startup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-21 11:36:22 +10:00
co-authored by Claude Opus 4.8
parent 799f755d5a
commit fda0f6f86f
2 changed files with 47 additions and 3 deletions
+5
View File
@@ -754,6 +754,11 @@ namespace ANSCENTER
virtual void AddEmbedding(const std::string& className, const std::vector<float>& embedding) =0;
virtual bool Destroy()=0;
virtual void SetMaxSlotsPerGpu(int n) {} // override in TRT-based subclasses
// True once Initialize() fully succeeded (license + model + engine).
// Callers that compute embeddings (enrollment) must check this first:
// Feature() returns an empty vector when uninitialized, which is
// indistinguishable from a bad face crop at the call site.
bool IsInitialized() const { return _isInitialized; }
~ANSFRBase();
// Utility functions