alicevision / AliceVision

Photogrammetric Computer Vision Framework
http://alicevision.org
Other
2.89k stars 807 forks source link

Add initial Python binding with SWIG #1647

Closed cbentejac closed 5 months ago

cbentejac commented 5 months ago

Description

This PR adds an initial Python binding of selected AliceVision modules using SWIG.

To that effect, SWIG is added as an optional dependency to the project and some modifications are done to the code in order to get the modules to bind properly (see the Implementation remarks section).

This first version of this binding revolves around the sfmData and sfmDataIO modules, which allow to load, save and modify SfMData files. Some related modules have been partially binded to allow the access to some relevant classes, structures or functions.

The binding does not cover yet 100% of the sfmData module, as it contains many dependencies that are not easily binded (in particular dependencies to Eigen). The binding is expected to be extended gradually.

Additionally, unit tests in Python are added. They currently aim more at validating the binding itself than the actual functions, for which unit tests with Boost already exist. These tests are added to the CI run for Linux.

The build of the Python binding on Windows is out of the scope of this PR and will be solved in a future and dedicated pull request.

The Python API of AliceVision can be used as follows:

import aliceVision as av

data = av.sfmData.SfMData()
path = "/path/to/sfmdata/file.sfm"
av.sfmDataIO.load(data, path, av.sfmDataIO.ALL)
views = data.getViews()

Features list

Implementation remarks