We implement KinectFusion using C++ and CUDA (specifically CUDA 11) to meet the real-time computing requirements. Essential libraries such as OpenCV for image processing and Eigen for efficient matrix and vector operations will also be utilized.
Regarding the dataset, we will use the TUM RGB-D Dataset, to validate our reconstruction implementation.
- C++17
- CUDA 11
- OpenCV 4
- Eigen 3
Please refer to the NVIDIA website.
This is a guide to installing OpenCV 4 with CUDA support. Here it is assumed that you have already installed CUDA 11 and downloaded the OpenCV source code to ~/Libs/opencv/4.8.0
and the OpenCV contrib source code to ~/Libs/opencv/contrib-4.8.0
. Please refer to the official OpenCV installation guide.
# change the directory to the directory where you downloaded the OpenCV source code
cd ~/Libs/opencv/4.8.0
mkdir build && cd build
# change the install directory to your preferred directory and set the path to the OpenCV contrib source code
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=~/Libs/opencv/4.8.0/install \
-D OPENCV_EXTRA_MODULES_PATH=~/Libs/opencv/contrib-4.8.0/modules \
-D WITH_CUDA=ON \
-D BUILD_DOCS=ON \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
..
make -j16
make install
# make sure you are in the *root directory* of this project
cd KinectFusion
mkdir Data && cd Data
wget https://vision.in.tum.de/rgbd/dataset/freiburg1/rgbd_dataset_freiburg1_xyz.tgz
tar -xvzf rgbd_dataset_freiburg1_xyz.tgz
# make sure you are in the *KinectFusion_GPU_CUDA* directory under the root directory of this project
cd KinectFusion_GPU_CUDA
# create a new cmake configuration file (or you can use any text editor to create this file)
touch config.cmake
echo "set(OpenCV_DIR /path/to/your/opencv)" >> config.cmake # set the path to your OpenCV 4
echo "set(Eigen3_DIR /path/to/your/eigen)" >> config.cmake # set the path to your Eigen 3
# set your GPU Compute Capability, refer to https://developer.nvidia.com/cuda-gpus
# for example, if you have a GTX 1080, the compute capability is 6.1. You can set it as follows:
echo "set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-O3;-std=c++11 -gencode arch=compute_61,code=sm_61 --expt-relaxed-constexpr)" >> config.cmake
For example, you can set the path to your OpenCV as follows:
# config.cmake
SET(OpenCV_DIR "~/Libs/opencv/4.8.0/install/lib/cmake/opencv4")
# make sure you are in the *KinectFusion_GPU_CUDA* directory under the root directory of this project
cd KinectFusion_GPU_CUDA
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j16
cd KinectFusion_GPU_CUDA/build
./KinectFusion_CUDA
The reconstructed 3D model and output videos will be stored in the output
directory.