jskinn / ORB_SLAM2-PythonBindings

A python wrapper for ORB_SLAM2
BSD 2-Clause "Simplified" License
162 stars 40 forks source link

ImportError #10

Open ChenHoy opened 5 years ago

ChenHoy commented 5 years ago

Hello, I am trying to use the bindinsg with Python3.7 and boost 1.71.

Both is found during the building process and no warnings or errors are raised. However, when I import orbslam2, I get the following ImportError: "ImportError: path/to/venv/lib/python3.7/site-packages/orbslam2.so: undefined symbol: _ZN5pbcvt26matToNDArrayBoostConverter7convertERKN2cv3MatE"

The paths to boost has been adjusted in CMakeLists.txt (Boost 1.71 REQUIRED COMPONENTS python37). Everything else was just adjusted to Python 3.7.

Hopefully, someone has an idea why this occurs. This error is similar to Issue #1, but I have explicitly set the paths correctly and the dependencies are apparently found correctly when building.

Thanks in advance for any help!

danbo2 commented 5 years ago

Hi @ChenHoy,

Can you help me work the issue out ? I meet the issue after building orbslam2. Capture

Thanks

jskinn commented 5 years ago

Failure to import like that indicates that python cannot find one of the referenced .so files when importing, even if your compiler could find them when it linked it. Probably one of the boost .so files. Did you move orbslam2.so after you created it? You can inspect where orbslam2.so expects to find all it's dependencies by running ldd orbslam2.so. IIRC, these are usually relative paths, so moving the file may break them. You can add the built orbslam.so to your virtualenv without moving it by using a symlink or a .pth file (see https://docs.python.org/3.7/library/site.html)

danbo2 commented 5 years ago

@jskinn Hi, I have compiled successfully in virtual environment, and used a symlink to add the built orbslam2.so to the virtualenv and checked dependencies are well. However, I am not luck to import it successfully. Can you help me solve the issue ? SLAM Link Thanks

jskinn commented 4 years ago

A couple of issues:

Braz3n commented 4 years ago

This issue can also be caused if you're trying to build the project with OpenCV4 instead of OpenCV2 or 3.

Unfortunately the ORB_SLAM2 repository isn't compatible with OpenCV4 either. You can use this fork of the original repo to build under OpenCV4, however.

As far as this project is concerned, only a couple changes are needed to work with the aforementioned fork: