geohot/twitchslam

how to import the lib

masterchop opened this issue · 7 comments

How to import the .so libraries?

i compile pingolin but the same thing happen:
Traceback (most recent call last):
File "fakeslam.py", line 13, in
from slam import SLAM
File "/home/chop/Scripts/SLAM/twitchslam/slam.py", line 10, in
from display import Display2D, Display3D
File "/home/chop/Scripts/SLAM/twitchslam/display.py", line 26, in
import pangolin
ImportError: No module named 'pangolin'

How to import the .so libraries?

You will find them on build websites.

i compile pingolin but the same thing happen:
Traceback (most recent call last):
File "fakeslam.py", line 13, in
from slam import SLAM
File "/home/chop/Scripts/SLAM/twitchslam/slam.py", line 10, in
from display import Display2D, Display3D
File "/home/chop/Scripts/SLAM/twitchslam/display.py", line 26, in
import pangolin
ImportError: No module named 'pangolin'

!pip install --upgrade pangolin worked ?

from frame import Frame, match_frames

I guess you have to manually build and install the package pangolin

Try doing

git clone https://github.com/uoip/pangolin.git
cd pangolin
mkdir build
cd build
cmake ..
make -j8
cd ..
python setup.py install

Make sure you have the dependencies installed beforehand which are PyOpenGL and Numpy

This is how I got it to work for python3.8 on OSX Catalina. From my understanding, the Pangolin that's included is for Python 3.6.

sudo python -mpip install numpy pyopengl Pillow pybind11
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
git submodule init && git submodule update
mkdir build
cd build
cmake .. -DPYTHON_LIBRARIES=/usr/local/bin/python3 -DBUILD_SHARED_LIBS=OFF
cmake --build .

Then copy this back into the lib/macosx folder.
You also need to change all the imports of pangolin to pypangolin

i.e.
import pypangolin as pangolin to work with existing code.

This is how I got it to work for python3.8 on OSX Catalina. From my understanding, the Pangolin that's included is for Python 3.6.

sudo python -mpip install numpy pyopengl Pillow pybind11
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
git submodule init && git submodule update
mkdir build
cd build
cmake .. -DPYTHON_LIBRARIES=/usr/local/bin/python3 -DBUILD_SHARED_LIBS=OFF
cmake --build .

Then copy this back into the lib/macosx folder.
You also need to change all the imports of pangolin to pypangolin

i.e.
import pypangolin as pangolin to work with existing code.

But if I import pangolin this way, DrawCameras() does not work because it is not implemented in the original repo.

should be the same fix as in #11

When you do sys.path.append, you cannot do relative paths. it must be the full path of the folder linux or macos. This is how I did it.

#! /usr/bin/env python3.6

import os
import sys
path = os.path.dirname(os.path.abspath(__file__))
sys.path.append(path + "/lib/linux")
import pangolin
import g2o

I struggled with this for days!