Python binding: add iteration support for Poses and Landmark Observations#2099
Draft
Python binding: add iteration support for Poses and Landmark Observations#2099
Conversation
…inding Agent-Logs-Url: https://github.com/alicevision/AliceVision/sessions/e413ff80-940d-4863-a912-d37196bd9677 Co-authored-by: fabiencastan <153585+fabiencastan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
fabiencastan
March 26, 2026 19:45
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the Python SWIG binding to allow iteration over
Poses(already aSharedPtrMap<CameraPose>) and over eachLandmark's observations.Description
Posesalready hadSPMAP_EXTENSIONSapplied, giving it__iter__,keys(),values(), anditems()— but this was untested.Landmark.getObservations()returnedstl::flat_map<IndexT, Observation>(boost::container::flat_map), which SWIG cannot wrap as an iterable Python object.Features list
Poseswithfor pose_id in sfm_data.getPoses(),.keys(),.values(),.items()Landmarkobservations vialandmark.getObservations(), returning a dict-likeObservationsobjectImplementation remarks
getObservations()returnsstl::flat_map(aboost::container::flat_mapalias), which has no SWIG support. Rather than wrapping boost containers, the existinggetMapObservations()C++ method (which converts tostd::map<IndexT, Observation>) is surfaced via a%extendreplacement inLandmark.i. The%template(Observations) std::map<IndexT, Observation>already present inSfMData.ithen provides the full dict-like Python interface via SWIG'sstd_map.i.Both features are covered by new/updated tests in
pyTests/sfmData/.