This project contains code examples created in Visual Studio Code for Computer Vision using C++ & OpenCV & Point Cloud Library (PCL). These examples are created for the Computer Vision Subject of Robotics Software Engineering Degree at URJC.
Probably OpenCV is installed, but it's a good practice to install it as follows.
Open an Ubuntu terminal and follow the next steps:
- Install dependencies:
sudo apt install build-essential cmake git pkg-config libgtk-3-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
gfortran openexr libatlas-base-dev python3-dev python3-numpy \
libtbb2 libtbb-dev libdc1394-22-dev
- Clone OpenCV and Contrib repositories:
mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
- Create temporary build directory:
cd ~/opencv_build/opencv
mkdir build
cd build
- Setup OpenCV:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..\
-D OPENCV_ENABLE_NONFREE=ON
- Compilation process:
make -j8
- Installation process:
sudo make install
- Import OpenCV package:
pkg-config opencv4 --cflags --libs
- Add in ~/.bashrc:
echo 'export LD_LIBRARY_PATH=$LS_LIBRARY_PATH:/usr/local/lib/' >> ~/.bashrc
- Load the libraries into the current shell:
source ~/.bashrc
The best way to be updated, is to install PCL compiling from source: https://pcl.readthedocs.io/projects/tutorials/en/latest/compiling_pcl_posix.html
It fixs some problems when you try to use Ubuntu 22.04, VTK 9.1 and PCL 1.12.1
- Clone PCL repository:
mkdir ~/pcl_build && cd ~/pcl_build
git clone --recursive https://github.com/PointCloudLibrary/pcl.git
- Create temporary build directory:
cd ~/pcl_build/pcl
mkdir build
cd build
- Run the CMake build system using the default options:
cmake ..
- Compilation process:
make -j2
- Installation process:
sudo make -j2 install
This is a project made by José Miguel Guerrero, Associate Professor at Universidad Rey Juan Carlos. Copyright © 2021.
Shield:
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.