Skip to content

Commit

Permalink
Improvements and fixes under macOs
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifreda committed Dec 5, 2024
1 parent 020dd24 commit f742395
Show file tree
Hide file tree
Showing 46 changed files with 942 additions and 176 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config.pyc
thirdparty/g2opy
thirdparty/pangolin
thirdparty/opencv-python
thirdparty/opencv
thirdparty/open3d
thirdparty/contextdesc/pretrained
matches.txt
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@ You can use the pySLAM framework as a baseline to play with [local features](#su

**Enjoy it!**

<center>
<img src="images/STEREO.png" alt="Visual Odometry" width="600" border="0" />
<img src="images/feature-matching.png" alt="Feature Matching" width="600" border="0" />
<img src="images/RGBD2.png" alt="SLAM" width="600" border="0" />
<img src="images/main-rerun-vo-and-matching.png" alt="Feature matching and Visual Odometry" width="600" border="0" />
</center>
<img src="images/STEREO.png" alt="Visual Odometry" height="160" border="0" /> <img src="images/feature-matching.png" alt="Feature Matching" height="160" border="0" /> <img src="images/RGBD2.png" alt="SLAM" height="160" border="0" /> <img src="images/main-rerun-vo-and-matching.png" alt="Feature matching and Visual Odometry" height="160" border="0" />

---
## Install
Expand Down Expand Up @@ -172,7 +167,7 @@ Loop closing is enabled by default. You can disable it by setting `kUseLoopClosi

Some **example files** are available in the subfolder `test/loopclosing`. In particular, as for loop closure, you may want to take a look at [test/loopclosing/test_loop_detector.py](./test/loopclosing/test_loop_detector.py).

**Generate the array descriptors to train a vocabulary (DBoW, VLAD)**
**How to generate the array descriptors to train a vocabulary (DBoW, VLAD)**
Generate the array of descriptors to train the vocabulary by using the script `test/loopclosing/test_gen_des_array_from_imgs.py`. Select your desired descriptor type by using the tracker configuration.

**DBOW vocabulary generation**
Expand Down Expand Up @@ -228,7 +223,11 @@ Some quick information about the non-trivial GUI buttons of `main_slam.py`:

### Monitor the logs for tracking, local mapping, and loop closing simultaneously

The logs generated by the modules `local_mapping.py`, `loop_closing.py`, `loop_detecting_process.py`, and `global_bundle_adjustments.py` are collected in the files `local_mapping.log`, `loop_closing.log`, `loop_detecting.log`, and `gba.log`, respectively stored in the folder `logs`. For fun/debugging, you can monitor their parallel flows by running the command `tail -f logs/<log file name>` in separate shells. Otherwise, just run the script `./scripts/launch_tmux_slam.sh` from the repo root folder: Use `CTRL+A` and then `CTRL+Q` to exit.
The logs generated by the modules `local_mapping.py`, `loop_closing.py`, `loop_detecting_process.py`, and `global_bundle_adjustments.py` are collected in the files `local_mapping.log`, `loop_closing.log`, `loop_detecting.log`, and `gba.log`, respectively stored in the folder `logs`. For fun/debugging, you can monitor their parallel flows by running the command:
`$ tail -f logs/<log file name>`
in separate shells. Otherwise, just run the script:
`$ ./scripts/launch_tmux_slam.sh`
from the repo root folder. Use `CTRL+A` and then `CTRL+Q` to exit from `tmux`.

---
## Supported local features
Expand Down Expand Up @@ -321,6 +320,8 @@ See the file `feature_matcher.py` for further details.
* Hyperdimensional Computing: [HDC](https://www.tu-chemnitz.de/etit/proaut/hdc_desc). [[paper](https://openaccess.thecvf.com/content/CVPR2021/html/Neubert_Hyperdimensional_Computing_as_a_Framework_for_Systematic_Aggregation_of_Image_CVPR_2021_paper.html)]


**NOTE**: *iBoW* and *OBIndex2* incrementally build a binary image index and do not need a prebuilt vocabulary. In the implemented classes, when needed, the input non-binary local descriptors are transparently transformed into binary descriptors.

#### Global descriptors

Also referred to as *holistic descriptors*:
Expand Down Expand Up @@ -482,7 +483,7 @@ Many improvements and additional features are currently under development:
- [x] map saving/loading
- [x] modern DL matching algorithms
- [ ] object detection and semantic segmentation
- [ ] 3D dense reconstruction
- [x] 3D dense reconstruction
- [x] unified install procedure (single branch) for all OSs
- [x] trajectory saving
- [ ] depth estimation integration
Expand Down
3 changes: 3 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ if [ -d "thirdparty/open3d" ]; then
rm -Rf thirdparty/open3d
fi

if [ -d "thirdparty/opencv" ]; then
rm -Rf thirdparty/opencv
fi

cd thirdparty/pydbow3
./clean.sh
Expand Down
6 changes: 0 additions & 6 deletions cpp/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -fPIC -DNDEBUG")
find_package(Eigen3 REQUIRED)

find_package(OpenCV ${OPENCV_VERSION} QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
endif()
endif()
message(STATUS "found OpenCV version: ${OpenCV_VERSION}")
message(STATUS "opencv include: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "opencv lib dirs: ${OpenCV_INSTALL_PATH}")
Expand Down
21 changes: 17 additions & 4 deletions cpp/utils/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash


SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # get script dir (this should be the main folder directory of PLVS)
SCRIPT_DIR=$(readlink -f $SCRIPT_DIR) # this reads the actual path if a symbolic directory is used


function make_dir(){
if [ ! -d $1 ]; then
mkdir $1
Expand All @@ -8,15 +13,23 @@ fi

# ====================================================
# check if we have external options
EXTERNAL_OPTION=$1
if [[ -n "$EXTERNAL_OPTION" ]]; then
echo "external option: $EXTERNAL_OPTION"
EXTERNAL_OPTIONS=$@
if [[ -n "$EXTERNAL_OPTIONS" ]]; then
echo "external option: $EXTERNAL_OPTIONS"
fi

OpenCV_DIR="$SCRIPT_DIR/../../thirdparty/opencv/install/lib/cmake/opencv4"
if [[ -d "$OpenCV_DIR" ]]; then
EXTERNAL_OPTIONS="$EXTERNAL_OPTIONS -DOpenCV_DIR=$OpenCV_DIR"
fi

echo "EXTERNAL_OPTIONS: $EXTERNAL_OPTIONS"

# ====================================================

make_dir build
cd build
cmake .. $EXTERNAL_OPTION
cmake .. $EXTERNAL_OPTIONS
make -j 4

cd ..
19 changes: 19 additions & 0 deletions global_bundle_adjustment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@

"""
* This file is part of PYSLAM
*
* Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com>
*
* PYSLAM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PYSLAM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PYSLAM. If not, see <http://www.gnu.org/licenses/>.
"""

import os
import time
import math
Expand Down
6 changes: 4 additions & 2 deletions install_all_mac_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ brew update
brew install wget
brew install doxygen
brew install eigen
brew install opencv
#brew install opencv
brew install glew
brew install pkg-config
brew install suite-sparse
Expand All @@ -36,7 +36,9 @@ brew install libomp # need to add -L/opt/homebrew/opt/libomp/lib -I/opt/homebr
brew install boost # for serialization
brew install tmux
brew install flann
#brew install open3d
brew install catch2
brew install numpy
#brew install open3d # built from source for different issues

# create a pyslam environment within pyenv and activate it
./pyenv-mac-create.sh # NOTE: the use of ./ seems crucial for the correct identification of the python libs for C++ projects
Expand Down
21 changes: 16 additions & 5 deletions install_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,30 @@

#set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # get script dir (this should be the main folder directory of PLVS)
SCRIPT_DIR=$(readlink -f $SCRIPT_DIR) # this reads the actual path if a symbolic directory is used

# ====================================================
# check if we have external options
EXTERNAL_OPTION=$1
if [[ -n "$EXTERNAL_OPTION" ]]; then
echo "external option: $EXTERNAL_OPTION"
EXTERNAL_OPTIONS=$@
if [[ -n "$EXTERNAL_OPTIONS" ]]; then
echo "external option: $EXTERNAL_OPTIONS"
fi

# check if we want to add a python interpreter check
if [[ -n "$WITH_PYTHON_INTERP_CHECK" ]]; then
echo "WITH_PYTHON_INTERP_CHECK: $WITH_PYTHON_INTERP_CHECK "
EXTERNAL_OPTION="$EXTERNAL_OPTION -DWITH_PYTHON_INTERP_CHECK=$WITH_PYTHON_INTERP_CHECK"
EXTERNAL_OPTIONS="$EXTERNAL_OPTIONS -DWITH_PYTHON_INTERP_CHECK=$WITH_PYTHON_INTERP_CHECK"
fi


OpenCV_DIR="$SCRIPT_DIR/thirdparty/opencv/install/lib/cmake/opencv4"
if [[ -d "$OpenCV_DIR" ]]; then
EXTERNAL_OPTIONS="$EXTERNAL_OPTIONS -DOpenCV_DIR=$OpenCV_DIR"
fi

echo "EXTERNAL_OPTIONS: $EXTERNAL_OPTIONS"

# ====================================================
# check if want to use conda or venv
if [ -z $USING_CONDA_PYSLAM ]; then
Expand All @@ -49,7 +60,7 @@ cd cpp

# build utils
cd utils
. build.sh $EXTERNAL_OPTION # use . in order to inherit python env configuration
. build.sh $EXTERNAL_OPTIONS # use . in order to inherit python env configuration
cd ..

cd ..
Expand Down
5 changes: 2 additions & 3 deletions install_open3d_python.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Author: Luigi Freda

#set -e

Expand All @@ -12,9 +13,7 @@
# on open3d dynamic library loading


print_blue '================================================'
print_blue "Installing open3d-python from source"
print_blue '================================================'

STARTING_DIR=`pwd` # this should be the main folder directory of the repo

Expand All @@ -23,7 +22,7 @@ pip uninstall -y open3d

cd thirdparty
if [ ! -d open3d ]; then
git clone --recursive https://github.com/isl-org/Open3D.git open3d
git clone https://github.com/isl-org/Open3D.git open3d
cd open3d

# This commit 0f06a149c4fb9406fd3e432a5cb0c024f38e2f0e didn't work. It corresponds to open3d 0.18.0 -> https://github.com/isl-org/Open3D/commits/v0.18.0
Expand Down
Loading

0 comments on commit f742395

Please sign in to comment.