Skip to content

[surface_matching] Add binary save/load for PPF3DDetector#4096

Open
v5a wants to merge 2 commits intoopencv:4.xfrom
v5a:feature/ppf-saveload
Open

[surface_matching] Add binary save/load for PPF3DDetector#4096
v5a wants to merge 2 commits intoopencv:4.xfrom
v5a:feature/ppf-saveload

Conversation

@v5a
Copy link
Copy Markdown

@v5a v5a commented Mar 24, 2026

Summary

This PR implements saveModel and loadModel methods for PPF3DDetector to enable saving trained models to disk and reloading them later. This addresses the long‑standing missing functionality reported in #3353.

Changes

  • Added saveModel(): writes all internal state (sampled point cloud, PPF matrix, hash nodes, hash table) to a custom binary file.
  • Added loadModel(): reads back the binary file and reconstructs the detector state exactly.
  • A custom binary format is used instead of FileStorage because XML/YAML serialization is too slow for the large datasets typically processed by this module.

Testing

  • Trained a model with the example model parasaurolophus_6700.ply.
  • Saved the model to trained_model.bin and loaded it into a new detector instance.
  • Matched both detectors against the scene rs1_normals.ply.
  • Both detectors found exactly the same 20 poses; the Frobenius norm of the first pose difference is 0.0, confirming perfect consistency.

Related Issue

Closes #3353

@v5a
Copy link
Copy Markdown
Author

v5a commented Mar 26, 2026

Hi @asmorkalov,
The two failing checks (CUDA and FastCV) appear to be unrelated to the changes in this PR. Could you please take a look? All other platforms passed successfully. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cv::ppf_match_3d::PPF3DDetector::write and read function doesn´t work

2 participants