Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions opensfm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class OpenSfMConfig:
flann_tree: int = 8
# Smaller -> Faster (but might lose good matches)
flann_checks: int = 20
# Seed for the RNG that FLANN's index construction draws from.
# Fixed by default so matching is reproducible; see build_flann_index.
flann_random_seed: int = 42

##################################
# Params for BoW matching
Expand Down
7 changes: 7 additions & 0 deletions opensfm/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,11 @@ def build_flann_index(descriptors: NDArray, config: Dict[str, Any]) -> cv2.flann
)

# pyrefly: ignore [not-callable]
# Pin OpenCV's RNG so the index is a pure function of (descriptors,
# seed). FLANN's index construction draws from cv::theRNG(), which is
# thread-local and advances between builds, so without this two workers
# build different indexes from identical descriptors and matching is
# not reproducible.
cv2.setRNGSeed(config["flann_random_seed"])

return context.flann_Index(descriptors, flann_params)