1. 将 ceres_python_bindings 工程 clone到 ceres-solver下
    Clone the repository at https://github.com/Edwinem/ceres_python_bindings into your ceres-solver folder.
  2. 修改 ceres的 CMakeLists.txt,添加编译 PyCeres的选项

    +set(CMAKE_CXX_STANDARD 14)
    +include(ceres_python_bindings/AddToCeres.cmake)
  3. 添加 函数
    ceres-solver/ceres_python_bindings/python_bindings/custom_cpp_cost_functions.cpp 文件内添加自定义的优化函数
  4. 系统环境配置

    # PyCeres
    export PYTHONPATH=$PYTHONPATH:/home/frank/ceres-solver/build/lib
    export PYTHONPATH=$PYTHONPATH:/home/frank/geometry/build
    export PYTHONPATH=$PYTHONPATH:/home/frank/pyceres_factors/build
  5. 生成函数提示
    cd ceres-solver/build/lib

    pybind11-stubgen PyCeres --ignore-all-errors

    此时会出现一个 stubs文件夹,里面有PyCeres.pyi的代码提示文件
    将该文件拷贝到与 PyCeres.cpython-38-x86_64-linux-gnu.so 同一级目录即可


frank
1 声望0 粉丝