-
Notifications
You must be signed in to change notification settings - Fork 1
Installing realsense opencv cuda
The instructions below are for openCV 4.7.0 (latest at time of writing)
-
Download the latest opencv source code release and opencv-contrib from the official git repos. Make sure both folders exist in the same parent directory.
https://github.com/opencv/opencv/releases
wget https://github.com/opencv/opencv/archive/refs/tags/4.7.0.zip
unzip 4.7.0.zip
rm 4.7.0.zip
https://github.com/opencv/opencv_contrib/tags
wget https://github.com/opencv/opencv_contrib/archive/refs/tags/4.7.0.zip
unzip 4.7.0.zip
rm 4.7.0.zip
-
In the same parent directory, make the build repo for opencv
mkdir opencv-4.7.0_build
and enter the build directory
cd opencv-4.7.0_build
-
Run CMake to configure the OpenCV build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D CUDA_ARCH_BIN=6.2 -D CUDA_ARCH_PTX="" -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D WITH_CUBLAS=ON -D WITH_LIBV4L=ON -D WITH_GSTREAMER=ON -D WITH_GSTREAMER_0_10=OFF -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.7.0/modules ../opencv-4.7.0
-
Build OpenCV
First, make sure the Jetson is configured to run at maximum speed.
sudo nvpmodel -m 3
jetson_clocks
Now start the build process. This step takes a very long time (1h+).
screen -dmS "build_opencv" make -j4
It is reccomended to use
screen
here, especially if operating over anssh
connection. This allows the build process to run in a separate shell where it cannot be accidentally stopped if the network is disconnected or the terminal window is closed. To learn more about usingscreen
, see the man page at https://linux.die.net/man/1/screen -
Install OpenCV
sudo make install
-
To confirm that the OpenCV install has CUDA support, run
jtop
and click on the INFO tab. You should seeOpenCV: 4.7.0 with CUDA: YES
The instructions below are for librealsense 2.53.1 (latest version supported on Ubuntu 18.04 at time of writing)
-
Download the librealsense source code release for Ubuntu 18.04 from the official git repo
https://github.com/IntelRealSense/librealsense/releases
wget https://github.com/IntelRealSense/librealsense/archive/refs/tags/v2.53.1.zip
unzip v2.53.1.zip
rm v2.53.1.zip
Enter the realsense directory
cd librealsense-2.53.1
-
Install the necessary build dependencies
sudo apt install git libssl-dev libusb-1.0-0-dev libudev-dev pkg-config libgtk-3-dev libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at -y
-
Build librealsense
mkdir build && cd build
cmake -DBUILD_EXAMPLES=true -DFORCE_LIBUVC=true -DBUILD_WITH_CUDA=true ../
Again,
screen
is used because the next step may take a while.screen -dmS "build_librealsense" make -j4
-
Install librealsense
sudo make install
The final step is to build and install the realsense-ros package with support of the newly built librealsense packages. This has been included in the Rover repo.
catkin_make clean
catkin_make
For more detailed build instructions (not necessary for this repo), see here https://github.com/IntelRealSense/realsense-ros/tree/ros1-legacy#step-2-install-intel-realsense-ros-from-sources