geohot / twitchslam

A toy implementation of monocular SLAM written while livestreaming
MIT License
959 stars 211 forks source link

how to import the lib #10

Open masterchop opened 4 years ago

masterchop commented 4 years ago

How to import the .so libraries?

masterchop commented 4 years ago

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'

ucalyptus commented 4 years ago

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 ?

worthless443 commented 4 years ago

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

zanussbaum commented 3 years ago

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.

kir486680 commented 3 years ago

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.

chbGSmCm commented 3 years ago

should be the same fix as in https://github.com/geohot/twitchslam/issues/11

exellentcoin26 commented 3 years ago

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!