[3D_Vision_Tutorial/PCL_Tutorial] Ubuntu 20.04 + OpenCV + Ceres Solver install + PCL
- https://github.com/mint-lab/3dv_tutorial : 3dvision tutorial code
- https://github.com/CYLoung/pcl_tutorial : pcl tutorial code
- Dependency : OpenCV / Ceres Solver / PCL
๐ฑ OpenCV Install
$ pkg-config --modversion opencv # OpenCV ๊ฐ ์ด๋ฏธ ๊น๋ ค์๋์ง ํ์ธํ๊ธฐ
$ pkg-config --modversion opencv4 # version 4 ๋ถํฐ๋ ์ด๋ ๊ฒ ํ์ธํด์ผํ๋ค.
- Install ์ฐธ๊ณ https://webnautes.tistory.com/1186
๐ฑ OpenCV ์ํ๋ ํด๋์ build & install
$ pkg-config --modversion opencv # local์ ์ค์น ๋์ด์๋์ง ํ์ธ
# ์ค์น๊ฐ ๋์ด์์ผ๋ฉด ๊ทธ๋๋ก ์ฌ์ฉํ์
๋ ๋์ง๋ง ์ฌ๋ฌ๋ฒ์ ์ OpenCV๋ฅผ ์ฌ์ฉํ๊ณ ์ถ์ผ์๋ค๋ฉด ์ง์ฐ๊ธฐ
$ sudo apt-get install -y cmake # install cmake
# folder๋ ์ํ๋ ๊ฒฝ๋ก์
$ git clone https://github.com/opencv/opencv.git # clone opencv
ํด๋ ๊ตฌ์กฐ๋ ์๋์ ๊ฐ์ด ๊ตฌ์ฑํ๋ค. ๋๋ ๋ก์ปฌ์์ ์ฌ๋ฌ๊ฐ์ version์ ํฅํ์ ์ฌ์ฉํ๊ณ ์ถ์ด์ ๋ฐ๋ก ์ค์น ์์ญ์ ๋นผ๋์๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ๊ทธ๋ฅ /usr/local ~ ์ด๋๊ฐ ์ค์น๋จ
# ๋์ ํด๋ ๊ตฌ์กฐ
install_thirdparty
ใด-- OpenCV
|--- install # make install ๋์ค์ CMAKELIST ์์ ๊ฒฝ๋ก ์ฐ๊ฒฐ์ํฌ ๊ณณ (์ค์ ๋ก ๋น๋๊ฐ ๋๋ ์ฅ์๋ ์๋์ง๋ง, ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ฐ์ ธ๋ค ์ธ ์ ์์)
|--- build # build
ใด-- opencv
-DCMAKE_BUILD_TYPE์ build type : Debug mode , Release mode๋ฅผ ๋ช ์
INSTALL_PREFIX๊ฐ ๋์ค์ ์ด๋ค ๊ฒฝ๋ก์ install ํ์ผ์ ๋ฑ๋กํ๊ฒ ๋ค!๋ผ๊ณ ๋ช ์ํ๋ ๋ถ๋ถ์ด๋ค.
๋ง์ง๋ง์ผ๋ก ../opencv -> CMakeLists.txt ๊ฐ ์๋ ๊ฒฝ๋ก๋ฅผ ์๋ฏธํ๋ค.
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install ../opencv
์ด๋ ๊ฒ CMake ํ์ผ์ด ์์ฑ๋๋ฉด
$ make -j4
$ make install
# system์ ์ค์นํ๊ณ ์ถ์ผ๋ฉด PREFIX_INSTALL ๊ฒฝ๋ก๋ฅผ ์ ์ธํ๊ณ sudo make install
๋์ค์ CMakelist์์ ํด๋น ๊ฒฝ๋ก๋ฅผ ์ฐ๊ฒฐํด์ ์ฌ์ฉํ๋ฉด ๋จ
๐ซ Ceres-Solver install
# CMake
sudo apt-get install cmake
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev libgflags-dev
# Use ATLAS for BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# Eigen3
sudo apt-get install libeigen3-dev
# SuiteSparse (optional)
sudo apt-get install libsuitesparse-dev
wget http://ceres-solver.org/ceres-solver-2.1.0.tar.gz
tar zxf ceres-solver-2.1.0.tar.gz
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-2.1.0
make -j4
make test
# Optionally install Ceres, it can also be exported using CMake which
# allows Ceres to be used without requiring installation, see the documentation
# for the EXPORT_BUILD_DIR option for more information.
sudo make install
๐ช Ceres-solver test
- ํ ํด๋์ ์๋ ํ์ผ์ ์์ฑํ๊ณ
- CMake ์์ฑ๋ฒ ์ฌ์ฉ๋ฒ ์ฐธ๊ณ (https://edward0im.github.io/technology/2020/09/16/cmake/)
https://ceres-solver.googlesource.com/ceres-solver/+/master/examples/helloworld.cc
mkdir build
cd build
cmake ..
make
โ Ceres-solver install error 1
Total Test time (real) = 78.95 sec
The following tests FAILED:
2 - cuda_memcheck_dense_cholesky_test (Failed)
25 - cuda_dense_cholesky_test (SEGFAULT)
27 - cuda_kernels_test (Child aborted)
28 - cuda_sparse_matrix_test (Child aborted)
29 - cuda_vector_test (Child aborted)
31 - dense_cholesky_test (Child aborted)
104 - ba_denseschur_cuda_auto_test (Child aborted)
121 - ba_denseschur_cuda_auto_threads_test (Child aborted)
138 - ba_denseschur_cuda_user_test (Child aborted)
155 - ba_denseschur_cuda_user_threads_test (Child aborted)
Errors while running CTest
make: *** [Makefile:130: test] Error 8
์ ๊ทผ 1 ) USE_CUDA ํ์ฑ
https://github.com/ceres-solver/ceres-solver/blob/master/CMakeLists.txt -> USE_CUDA ์ค์ ์ด ํ์ํ๋ค
https://www.cv-learn.com/20230321-ccmake/#more
์ ๊ทผ 2 ) wget์ผ๋ก ๋ค์ด๋ฐ์์ ์ค์น (clone์ผ๋ก ํ ํ์ผ ๋ง๊ณ wget์ผ๋ก ๋ค์ด๋ฐ์์ ์ค์นํ๋ ๋๋ค,,ใ ,,)
โ Ceres-solver install error 2
-- Install configuration: "Release"
CMake Error at cmake_install.cmake:41 (file):
file cannot create directory: /usr/local/lib/cmake/Ceres. Maybe need
administrative privileges.
-> make install ์ sudo๋ฅผ ๋ถ์ด์ ๋ฐ๋ก cmake ๋ INSTALL_PREFIX ๊ฒฝ๋ก๋ฅผ ์ง์ ํ ๊ฒ์ด ์๋๋ผ๋ฉด
๐ซ PCL & Boost install
# Method 1 ) pkg install
sudo apt-get update && sudo apt-get install -y software-properties-common git
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl -y && sudo apt-get update
sudo apt-get install -y libpcl-all #ubnutu 14
sudo apt-get install -y libpcl-dev #ubuntu 16 (libpcl-dev 1.7.2)
sudo apt-get install -y libpcl-dev #ubuntu 18 (PCL 1.8)
# Method 2 ) Source install
# ํ์ ์ค์น
$ sudo apt-get update -qq
$ sudo apt-get install -y --no-install-recommends make cmake cmake-gui build-essential git libeigen3-dev libflann-dev libusb-1.0-0-dev libboost-all-dev &&
# ์ถ๊ฐ ์ค์น
sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends libflann1.8 libusb-dev libvtk6-qt-dev libpcap-dev libproj-dev linux-libc-dev libudev-dev mpi-default-dev openmpi-bin openmpi-common libvtk5.10-qt4 libvtk5.10 libvtk5-dev libqhull* libgtest-dev freeglut3-dev pkg-config libxmu-dev libxi-dev mono-complete qt-sdk openjdk-8-jdk openjdk-8-jre
# git build-essential linux-libc-dev cmake cmake-gui libusb-1.0-0-dev libusb-dev libudev-dev mpi-default-dev openmpi-bin openmpi-common libflann1.8 libflann-dev libeigen3-dev libboost-all-dev libvtk5.10-qt4 libvtk5.10 libvtk5-dev libqhull* libgtest-dev freeglut3-dev pkg-config libxmu-dev libxi-dev mono-complete qt-sdk openjdk-8-jdk openjdk-8-jre
$ sudo rm -rf /var/lib/apt/lists/*
cd install_thirdparty
wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.13.1.tar.gz
tar zvfx pcl-1.13.1.tar.gz
cd pcl-pcl-1.13.1
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install ../
# with enhanced compiler optimizations `cmake -DCMAKE_BUILD_TYPE=Release ..`
make -j4 # it depend on your cpu core
make -j4 install # PREFIX ์์น๋ฅผ ์ ์ธํ๊ณ ์์คํ
์ ์ค์นํ๋ฉด sudo๋ฅผ ์์ ์ถ๊ฐํด์ผํจ
๐ซ Clion setting
- ํ์ ๊ณ์ ์ค์ : https://www.jetbrains.com/community/education/#students
Free Educational Licenses - Community Support
Learn or teach how to code with best-of-industry tools from JetBrains. Free Educational Licenses for JetBrains' tools.
www.jetbrains.com
- ํ์ ๊ณ์ ์ค์ ๊ด๋ จ ์ฐธ๊ณ ๊ธ
๐ Reference
[1] OpenCV install
- https://docs.opencv.org/4.x/df/d65/tutorial_table_of_content_introduction.html
- ์ ํ์ด์ง ์ค
- OpenCV configuration options reference : build option
- Using OpenCV with gcc and CMake : compile ํ ๋ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ๋ฑ์ด ๋์์๋ค.
[2] with Ubuntu https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html
[3] Ceres Solver install http://ceres-solver.org/installation.html#linux
[4] Ceres Solver helloceres :https://github.com/LimHyungTae/helloceres