https://bugs.kde.org/show_bug.cgi?id=518355
Bug ID: 518355
Summary: Allow user-defined
faces_recognition_kdtree_checks_limit to prevent ANN
truncation in large datasets.
Classification: Applications
Product: digikam
Version First 9.1.0
Reported In:
Platform: unspecified
OS: Unspecified
Status: REPORTED
Severity: normal
Priority: NOR
Component: Faces-Recognition
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
The current Face Recognition engine in digiKam utilizes OpenCV’s FLANN library
for 128D vector matching. In large-scale databases, the multidimensional
KD-Tree becomes highly dense. Because FLANN is an Approximate Nearest Neighbor
(ANN) algorithm, its precision is strictly governed by the checks parameter in
cv::flann::SearchParams.
In the current implementation, this value appears to be hardcoded to a low
default. In high-dimensional space (\mathbb{R}^{128}), this limit causes the
search to terminate prematurely, returning "good enough" matches from
early-visited branches rather than discovering the true nearest neighbor
located in deeper or distal branches.
My Analysis of the 128D Vector Space:
I have performed a programmatic analysis of a large digiKam database using the
raw vectors from the FaceMatrices table. By calculating the Intra-Cluster
Distance (average distance of a face from its identity centroid) and the
Distance to the Nearest Neighbor Identity, the data reveals a critical overlap:
Observed Behavior: Multiple distinct identities have centroids where the
"Distance to Neighboring Identity" is smaller than the internal "Intra-Cluster
Radius."
The Mathematical Failure: A standard FLANN search with a low checks limit is
mathematically incapable of distinguishing between these neighbors. It exits
the search before exploring the boundary hyperplanes of the dense manifold,
leading to persistent false positives regardless of how many times the user
"retrains" or rebuilds the tree.
Proposed Implementation:
Expose a new configuration parameter, faces_recognition_kdtree_checks_limit, in
the digikamrc or Advanced Settings.
Suggested Range: 32 (default/fast) to 2^14 (exhaustive/accurate).
Proposed Default: 128.
Technical Reference & Location:
The parameter should be passed to the cv::flann::SearchParams object within the
recognition engine calls.
Target File:
core/libs/facesengine/recognition/opencv-face/recognitiondatabase.cpp
(specifically where the KNN or Radius search is initialized).
GitHub Reference: digiKam Source: recognitiondatabase.cpp
Impact:
Implementing this is a low-effort, high-impact fix. It requires no changes to
the database schema or the underlying facial recognition models. It simply
provides power users with the "knob" required to trade a negligible amount of
CPU time for the search depth necessary to resolve identities in a dense,
high-dimensional archive.
--
You are receiving this mail because:
You are watching all bug changes.