### Start Docker Container and Compile Packages Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md Start a Docker container and compile machine-dependent packages inside it. This is typically done after building the image. ```bash cd docker && bash run_container.sh # Inside docker container, compile the packages which are machine dependent bash build.sh ``` -------------------------------- ### Setup Environment and Imports Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/visualize_dump_results.ipynb Loads necessary libraries and sets up the environment for LoFTR visualization. This includes setting the current directory and importing plotting utilities. ```python %load_ext autoreload %autoreload 2 %matplotlib inline import os os.chdir("..") import numpy as np import matplotlib.pyplot as plt import cv2 from pathlib import Path from src.utils.plotting import make_matching_figure, error_colormap ``` -------------------------------- ### Install LoFTR Matcher Only Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Install only the LoFTR matcher package using pip if full PyTorch Lightning features are not required. ```shell pip install torch einops yacs kornia ``` -------------------------------- ### Setup Testing Symlinks Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Create symbolic links for the testing subsets of ScanNet and MegaDepth datasets. Ensure the paths point to your downloaded dataset locations. ```shell ln -s /path/to/scannet-1500-testset/* /path/to/LoFTR/data/scannet/test ln -s /path/to/megadepth-1500-testset/* /path/to/LoFTR/data/megadepth/test ``` -------------------------------- ### Install LoFTR with PyTorch Lightning Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Use this command to create a Conda environment with full PyTorch Lightning trainer features for LoFTR. ```shell conda env create -f environment.yaml conda activate loftr ``` -------------------------------- ### Glob G2O Libraries Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Finds all library files starting with 'libg2o' within the specified G2O third-party directory. ```cmake file(GLOB G2O_LIBS ${PROJECT_SOURCE_DIR}/src/Thirdparty/g2o/lib/libg2o*) ``` -------------------------------- ### Configure RPATH Settings Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Configures Runtime Search Path (RPATH) settings to ensure libraries can be found at runtime, especially when the build directory is used for installation. ```cmake set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) ``` -------------------------------- ### Run LoFTR Webcam Demo Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Execute the LoFTR demo script using a webcam as input. This script requires the 'utils.py' file, which will be downloaded if not present. ```shell #!/bin/bash set -e # set -x if [ ! -f utils.py ]; then echo "Downloading utils.py from the SuperGlue repo." echo "We cannot provide this file directly due to its strict licence." wget https://raw.githubusercontent.com/magicleap/SuperGluePretrainedNetwork/master/models/utils.py fi # Use webcam 0 as input source. input=0 # or use a pre-recorded video given the path. # input=/home/sunjiaming/Downloads/scannet_test/$scene_name.mp4 # Toggle indoor/outdoor model here. model_ckpt=../weights/indoor_ds.ckpt # model_ckpt=../weights/outdoor_ds.ckpt # Optionally assign the GPU ID. # export CUDA_VISIBLE_DEVICES=0 echo "Running LoFTR demo.." eval "$(conda shell.bash hook)" conda activate loftr python demo_loftr.py --weight $model_ckpt --input $input # To save the input video and output match visualizations. # python demo_loftr.py --weight $model_ckpt --input $input --save_video --save_input # Running on remote GPU servers with no GUI. # Save images first. # python demo_loftr.py --weight $model_ckpt --input $input --no_display --output_dir="./demo_images/" # Then convert them to a video. # ffmpeg -framerate 15 -pattern_type glob -i '*.png' -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4 ``` -------------------------------- ### Inspect default configuration parameters Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/demo_single_pair.ipynb Displays the default configuration parameters for the 'coarse' matching stage of the LoFTR model. ```python default_cfg['coarse'] ``` -------------------------------- ### Initialize and Run LoFTR Inference Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Initialize the LoFTR matcher, load pre-trained weights, and perform inference on a batch of images. Ensure the batch contains 'image0' and 'image1'. ```python from src.loftr import LoFTR, default_cfg # Initialize LoFTR matcher = LoFTR(config=default_cfg) matcher.load_state_dict(torch.load("weights/indoor_ds.ckpt")['state_dict']) matcher = matcher.eval().cuda() # Inference with torch.no_grad(): matcher(batch) # batch = {'image0': img0, 'image1': img1} mkpts0 = batch['mkpts0_f'].cpu().numpy() mkpts1 = batch['mkpts1_f'].cpu().numpy() ``` -------------------------------- ### Initialize LoFTR matcher for outdoor dataset Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/demo_single_pair.ipynb Initializes the LoFTR matcher with the default configuration, specifically for outdoor scenes using the 'outdoor_ds.ckpt' weights. ```python from src.loftr import LoFTR, default_cfg # The default config uses dual-softmax. # The outdoor and indoor models share the same config. # You can change the default values like thr and coarse_match_type. matcher = LoFTR(config=default_cfg) matcher.load_state_dict(torch.load("weights/outdoor_ds.ckpt")['state_dict']) matcher = matcher.eval().cuda() ``` -------------------------------- ### Build Docker Image Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md Build the Docker image for the BundleSDF project. This command should be run once and may take some time. ```bash cd docker docker build --network host -t nvcr.io/nvidian/bundlesdf . ``` -------------------------------- ### Training LoFTR on ScanNet (Dual-Softmax) Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/docs/TRAINING.md Execute the training script for the dual-softmax matcher on the ScanNet dataset. This script is configured for 4 GPUs and may not reproduce paper results. ```shell scripts/reproduce_train/indoor_ds.sh ``` -------------------------------- ### Initialize LoFTR matcher with default config Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/demo_single_pair.ipynb Initializes the LoFTR matcher using the default dual-softmax configuration. Ensure 'temp_bug_fix' is set correctly based on the checkpoint used. ```python from src.loftr import LoFTR, default_cfg # The default config uses dual-softmax. # The outdoor and indoor models share the same config. # You can change the default values like thr and coarse_match_type. _default_cfg = deepcopy(default_cfg) _default_cfg['coarse']['temp_bug_fix'] = True # set to False when using the old ckpt matcher = LoFTR(config=_default_cfg) matcher.load_state_dict(torch.load("weights/indoor_ds_new.ckpt")['state_dict']) matcher = matcher.eval().cuda() ``` -------------------------------- ### Download SuperGlue Utility for LoFTR-OT Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Download the SuperGlue utility script required for LoFTR-OT functionality. This is necessary due to licensing restrictions of the original code. ```shell cd src/loftr/utils wget https://raw.githubusercontent.com/magicleap/SuperGluePretrainedNetwork/master/models/superglue.py ``` -------------------------------- ### Handle ZeroMQ Library Finding Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Provides a fallback mechanism to find the ZeroMQ library if it's not found by find_package, and fails the build if it remains unfound. ```cmake if(NOT ZeroMQ_FOUND) find_library(ZMQ_LIB zmq) if(NOT ZMQ_LIB) message(FATAL_ERROR "ZeroMQ library not found") endif() endif() ``` -------------------------------- ### Training LoFTR on MegaDepth (Dual-Softmax) Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/docs/TRAINING.md Execute the training script for the dual-softmax matcher on the MegaDepth dataset with smaller image sizes. This script uses 4 GPUs and may not reproduce paper results. ```shell scripts/reproduce_train/outdoor_ds.sh ``` -------------------------------- ### Run BundleSDF on HO3D Dataset Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md Execute this command to run BundleSDF on the HO3D dataset for pose and reconstruction results. Specify the video directories and an output directory. ```python python run_ho3d.py --video_dirs /mnt/9a72c439-d0a7-45e8-8d20-d7a235d02763/DATASET/HO3D_v3/evaluation/SM1 --out_dir /home/bowen/debug/ho3d_ours ``` -------------------------------- ### Load and preprocess images for outdoor scene Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/demo_single_pair.ipynb Loads and resizes images for an outdoor scene, ensuring dimensions are divisible by 8, and prepares them as PyTorch tensors for LoFTR inference. ```python # Load example images img0_pth = "assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg" img1_pth = "assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg" img0_raw = cv2.imread(img0_pth, cv2.IMREAD_GRAYSCALE) img1_raw = cv2.imread(img1_pth, cv2.IMREAD_GRAYSCALE) img0_raw = cv2.resize(img0_raw, (img0_raw.shape[1]//8*8, img0_raw.shape[0]//8*8)) # input size shuold be divisible by 8 img1_raw = cv2.resize(img1_raw, (img1_raw.shape[1]//8*8, img1_raw.shape[0]//8*8)) img0 = torch.from_numpy(img0_raw)[None][None].cuda() / 255. img1 = torch.from_numpy(img1_raw)[None][None].cuda() / 255. batch = {'image0': img0, 'image1': img1} # Inference with LoFTR and get prediction with torch.no_grad(): matcher(batch) mkpts0 = batch['mkpts0_f'].cpu().numpy() mkpts1 = batch['mkpts1_f'].cpu().numpy() mconf = batch['mconf'].cpu().numpy() ``` -------------------------------- ### Building Dataset Symlinks for ScanNet Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/docs/TRAINING.md Create symbolic links for ScanNet training and testing datasets, as well as their indices, within the LoFTR project's data directory. ```shell # scannet # -- # train and test dataset ln -s /path/to/scannet_train/* /path/to/LoFTR/data/scannet/train ln -s /path/to/scannet_test/* /path/to/LoFTR/data/scannet/test # -- # dataset indices ln -s /path/to/scannet_indices/* /path/to/LoFTR/data/scannet/index ``` -------------------------------- ### Visualize Oriented Bounding Box Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md Run this command to visualize the oriented bounding box for pose estimation. Results are saved in the specified output folder. ```python python run_custom.py --mode draw_pose --out_folder /home/bowen/debug/bundlesdf_2022-11-18-15-10-24_milk ``` -------------------------------- ### Load and preprocess images for inference Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/demo_single_pair.ipynb Loads two grayscale images, resizes them to a common dimension, converts them to PyTorch tensors, and normalizes pixel values. This prepares the images for LoFTR inference. ```python # Load example images img0_pth = "assets/scannet_sample_images/scene0711_00_frame-001680.jpg" img1_pth = "assets/scannet_sample_images/scene0711_00_frame-001995.jpg" img0_raw = cv2.imread(img0_pth, cv2.IMREAD_GRAYSCALE) img1_raw = cv2.imread(img1_pth, cv2.IMREAD_GRAYSCALE) img0_raw = cv2.resize(img0_raw, (640, 480)) img1_raw = cv2.resize(img1_raw, (640, 480)) img0 = torch.from_numpy(img0_raw)[None][None].cuda() / 255. img1 = torch.from_numpy(img1_raw)[None][None].cuda() / 255. batch = {'image0': img0, 'image1': img1} # Inference with LoFTR and get prediction with torch.no_grad(): matcher(batch) mkpts0 = batch['mkpts0_f'].cpu().numpy() mkpts1 = batch['mkpts1_f'].cpu().numpy() mconf = batch['mconf'].cpu().numpy() ``` -------------------------------- ### Set Output Directories Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Configures the output directories for libraries and runtime executables to be the binary directory. ```cmake set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) ``` -------------------------------- ### Define Include Directories Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Lists all necessary directories to be included for header files, covering project sources, third-party libraries, and external dependencies. ```cmake include_directories( src ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${CSPARSE_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/cuda/ ${PROJECT_SOURCE_DIR}/src/cuda/Solver/ ${PROJECT_SOURCE_DIR}/src/Thirdparty ${PROJECT_SOURCE_DIR}/src/Thirdparty/g2o ) ``` -------------------------------- ### Run Global Refinement Post-processing Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md Perform global refinement post-processing on the results of the tracking and reconstruction step to further refine the mesh. Update the video directory path as needed. ```python # 2) Run global refinement post-processing to refine the mesh python run_custom.py --mode global_refine --video_dir /home/bowen/debug/2022-11-18-15-10-24_milk --out_folder /home/bowen/debug/bundlesdf_2022-11-18-15-10-24_milk # Change the path to your video_directory ``` -------------------------------- ### Run Joint Tracking and Reconstruction on Custom Data Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md Execute the main script for joint tracking and reconstruction on custom RGBD video data. Ensure the video directory and output folder are correctly specified. ```python # 1) Run joint tracking and reconstruction. python run_custom.py --mode run_video --video_dir /home/bowen/debug/2022-11-18-15-10-24_milk --out_folder /home/bowen/debug/bundlesdf_2022-11-18-15-10-24_milk --use_segmenter 1 --use_gui 1 --debug_level 2 ``` -------------------------------- ### Benchmark HO3D Dataset Results Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md Use this command to benchmark the output results from the HO3D dataset processing. Ensure the video directories and output directory are correctly specified. ```python python benchmark_ho3d.py --video_dirs /mnt/9a72c439-d0a7-45e8-8d20-d7a235d02763/DATASET/HO3D_v3/evaluation/SM1 --out_dir /home/bowen/debug/ho3d_ours ``` -------------------------------- ### Reproduce Testing Results Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Commands to activate the conda environment and reproduce testing results using shell scripts or Python scripts with specified configurations and checkpoints. ```shell conda activate loftr # with shell script bash ./scripts/reproduce_test/indoor_ds.sh # or python test.py configs/data/scannet_test_1500.py configs/loftr/loftr_ds.py --ckpt_path weights/indoor_ds.ckpt --profiler_name inference --gpus=1 --accelerator="ddp" ``` -------------------------------- ### Configure Main Library Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Defines the main shared library for the project, setting its source files and properties like output directory and position-independent code. ```cmake add_library(${PROJECT_NAME} SHARED ${MY_SRC}) set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} POSITION_INDEPENDENT_CODE ON ) ``` -------------------------------- ### Visualize LoFTR matches Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/demo_single_pair.ipynb Draws the detected keypoints and their matches on the original images using a colormap based on confidence scores. Displays the number of matches found. ```python # Draw color = cm.jet(mconf) text = [ 'LoFTR', 'Matches: {}'.format(len(mkpts0)), ] fig = make_matching_figure(img0_raw, img1_raw, mkpts0, mkpts1, color, text=text) ``` -------------------------------- ### Building Dataset Symlinks for MegaDepth Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/docs/TRAINING.md Create symbolic links for MegaDepth training and testing datasets, including both original and D2-Net processed data, along with their indices. ```shell # megadepth # -- # train and test dataset (train and test share the same dataset) ln -sv /path/to/megadepth/phoenix /path/to/megadepth_d2net/Undistorted_SfM /path/to/LoFTR/data/megadepth/train ln -sv /path/to/megadepth/phoenix /path/to/megadepth_d2net/Undistorted_SfM /path/to/LoFTR/data/megadepth/test # -- # dataset indices ln -s /path/to/megadepth_indices/* /path/to/LoFTR/data/megadepth/index ``` -------------------------------- ### Enable CUDA Support and Check Language Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Enables CUDA language support for the project and performs a check to ensure CUDA is available. ```cmake enable_language(CUDA) include(CheckLanguage) check_language(CUDA) ``` -------------------------------- ### Find Required Packages Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Finds and configures essential external libraries and packages required by the project, specifying minimum versions where necessary. ```cmake find_package(Boost 1.65.0 REQUIRED COMPONENTS system program_options serialization) find_package(PCL 1.8 REQUIRED) find_package(Eigen3 3.3 REQUIRED) find_package(OpenCV 4.0 REQUIRED) find_package(OpenMP REQUIRED) find_package(yaml-cpp 0.6 REQUIRED) find_package(BLAS REQUIRED) find_package(OpenGL REQUIRED) find_package(CUDA 11.0 REQUIRED) find_package(GLUT REQUIRED) find_package(LAPACK REQUIRED) find_package(pybind11 2.6 REQUIRED) find_package(Python COMPONENTS Interpreter Development REQUIRED) find_package(ZeroMQ QUIET) ``` -------------------------------- ### Extracting Dataset Indices Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/docs/TRAINING.md Unzip and extract the downloaded dataset indices for training and testing using tar and unzip commands. ```shell unzip downloaded-file.zip # extract dataset indices tar xf train-data/megadepth_indices.tar tar xf train-data/scannet_indices.tar # extract testing data (optional) tar xf testdata/megadepth_test_1500.tar tar xf testdata/scannet_test_1500.tar ``` -------------------------------- ### Configure CUDA Standard and Compiler Flags Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Sets the CUDA standard to 17, makes it required, and configures CUDA compiler flags for optimization and stream management. ```cmake set(CMAKE_CUDA_STANDARD 17) set(CMAKE_CUDA_STANDARD_REQUIRED ON) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -O3 -use_fast_math --default-stream per-thread") ``` -------------------------------- ### Load ScanNet Data and Visualize Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/visualize_dump_results.ipynb Loads prediction and evaluation data for the ScanNet dataset from a .npy file and generates a visualization plot for a specific sample. ```python root_dir = Path("data/scannet/test") # Scannet npy_path = "dump/loftr_ds_indoor/LoFTR_pred_eval.npy" dumps = np.load(npy_path, allow_pickle=True) fig = make_prediction_and_evaluation_plot(root_dir, dumps[2], source='ScanNet') ``` -------------------------------- ### Optional Gurobi Support Configuration Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Configures the build to optionally include Gurobi support if the GUROBI variable is defined. It sets definitions, checks for GUROBI_HOME, and finds Gurobi libraries. ```cmake if(DEFINED GUROBI) message("Using Gurobi") add_definitions(-DGUROBI=1) if(NOT DEFINED GUROBI_HOME) message(FATAL_ERROR "GUROBI_HOME must be defined when using Gurobi") endif() include_directories("${GUROBI_HOME}/include") find_library(GUROBI_LIBRARY NAMES gurobi90 gurobi95 PATHS "${GUROBI_HOME}/lib" REQUIRED ) find_library(GUROBI_CXX_LIBRARY NAMES gurobi_c++ PATHS "${GUROBI_HOME}/lib" REQUIRED ) endif() ``` -------------------------------- ### Load MegaDepth Data and Visualize Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/visualize_dump_results.ipynb Loads prediction and evaluation data for the MegaDepth dataset from a .npy file and generates a visualization plot for a specific sample. ```python root_dir = Path("data/megadepth/test") # MegaDepth npy_path = "dump/loftr_ds_outdoor/LoFTR_pred_eval.npy" dumps = np.load(npy_path, allow_pickle=True) fig = make_prediction_and_evaluation_plot(root_dir, dumps[51], source='MegaDepth') ``` -------------------------------- ### Import necessary libraries Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/demo_single_pair.ipynb Imports essential libraries for LoFTR, including PyTorch, OpenCV, NumPy, Matplotlib, and utility functions for plotting. ```python import os os.chdir("..") from copy import deepcopy import torch import cv2 import numpy as np import matplotlib.cm as cm from src.utils.plotting import make_matching_figure ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Specifies the minimum required CMake version and names the project 'BundleTrack'. Languages supported are CUDA, CXX, and C. ```cmake cmake_minimum_required(VERSION 3.15) project(BundleTrack LANGUAGES CUDA CXX C) ``` -------------------------------- ### Build CUDA Shared Library Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Creates a shared library named 'MY_CUDA_LIB' from the collected CUDA source files. It configures properties for separable compilation, position-independent code, and output directory. ```cmake add_library(MY_CUDA_LIB SHARED ${CUDA_FILES}) set_target_properties(MY_CUDA_LIB PROPERTIES CUDA_SEPARABLE_COMPILATION ON POSITION_INDEPENDENT_CODE ON LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Add Python Bindings Module Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Creates Python bindings for the C++ code using pybind11, specifying the module name and source files for the bindings. ```cmake pybind11_add_module(my_cpp pybind_interface/pybind_api.cpp src/Frame.cpp ) ``` -------------------------------- ### Load and Inspect ScanNet Training Data Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/README.md Python code snippet demonstrating how to load a .npz file containing image pair information and overlapping scores for ScanNet training data. Shows how to access 'name' (image pair info) and 'score' (overlapping score). ```python npz_path = './cfg_1513_-1_0.2_0.8_0.15/scene_data/train/scene0000_01.npz' data = np.load(npz_path) data['name'] data['score'] len(data['name']) len(data['score']) ``` -------------------------------- ### Check CUDA Version and Warn if Below 11.0 Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Checks the CUDA compiler version and issues a warning if it is less than 11.0, as it might not support all specified architectures. ```cmake if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS "11.0") message(WARNING "CUDA version < 11.0 may not support all specified architectures") endif() ``` -------------------------------- ### Set Pybind11 C++ Standard Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Specifies the C++ standard to be used with Pybind11, ensuring compatibility. ```cmake set(PYBIND11_CPP_STANDARD -std=c++17) ``` -------------------------------- ### Set C++ Standard and Compiler Flags Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Sets the C++ standard to C++17, makes it required, disables extensions, and enables generation of compile_commands.json. Also sets base C++ flags including warnings and debug information. ```cmake set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g") ``` -------------------------------- ### Glob Source Files Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Uses file globbing to find all C++ source files within the 'src' directory and its subdirectories. ```cmake file(GLOB MY_SRC ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/cuda/*.cpp ${PROJECT_SOURCE_DIR}/src/cuda/Solver/*.cpp ) ``` -------------------------------- ### Link Libraries to CUDA Library Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Links necessary libraries to the 'MY_CUDA_LIB', including yaml-cpp, Boost, OpenCV, PCL, and CUDA libraries, making them available for use. ```cmake target_link_libraries(MY_CUDA_LIB PUBLIC yaml-cpp ${YAML_CPP_LIBRARIES} ${Boost_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${CUDA_LIBRARIES} ) ``` -------------------------------- ### Set Build Type to Release if Not Specified Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Ensures that the build type is set to 'Release' if it hasn't been explicitly defined by the user. ```cmake if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() ``` -------------------------------- ### Set Properties for Python Bindings Module Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Configures properties for the Python bindings module, including output directory, position-independent code, and separable compilation for CUDA. ```cmake set_target_properties(my_cpp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} POSITION_INDEPENDENT_CODE ON CUDA_SEPARABLE_COMPILATION ON ) ``` -------------------------------- ### Link Libraries for Main Library Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Specifies the public libraries to link against for the main shared library, including dependencies like YAML-CPP, CUDA, Boost, OpenCV, PCL, OpenGL, and Python. ```cmake target_link_libraries(${PROJECT_NAME} PUBLIC ${YAML_CPP_LIBRARIES} MY_CUDA_LIB ${Boost_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${OpenMP_CXX_FLAGS} ${OPENGL_LIBRARIES} ${CUDA_LIBRARIES} ${GLUT_LIBRARIES} ${PYTHON_LIBRARIES} ${G2O_LIBS} zmq ) ``` -------------------------------- ### Set CUDA Architectures Based on Version Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Dynamically sets the target CUDA architectures based on the compiler version. Uses a broader set for versions 11.8 and above, and a more limited set for older versions. ```cmake if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.8") set(CMAKE_CUDA_ARCHITECTURES "52;60;61;70;75;80;86;90") else() set(CMAKE_CUDA_ARCHITECTURES "52;60;61;70;75;80;86") endif() ``` -------------------------------- ### Define Feature Flags Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Adds preprocessor definitions for various feature flags, controlling aspects like G2O, timer usage, residual printing, RANSAC, and matching. ```cmake add_definitions(-DG2O=0) add_definitions(-DTIMER=0) add_definitions(-DPRINT_RESIDUALS_DENSE=0) add_definitions(-DPRINT_RESIDUALS_SPARSE=0) add_definitions(-DCUDA_RANSAC=1) add_definitions(-DCUDA_MATCHING=1) ``` -------------------------------- ### Glob CUDA Source Files Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Uses file globbing to find all CUDA source files (.cu) within the 'src' directory and its CUDA-specific subdirectories. ```cmake file(GLOB CUDA_FILES "${PROJECT_SOURCE_DIR}/src/*.cu" "${PROJECT_SOURCE_DIR}/src/cuda/*.cu" "${PROJECT_SOURCE_DIR}/src/cuda/Solver/*.cu" ) ``` -------------------------------- ### Link Libraries for Python Bindings Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Specifies the private libraries to link against for the Python bindings module, including the main project library and various third-party dependencies. ```cmake target_link_libraries(my_cpp PRIVATE ${PROJECT_NAME} MY_CUDA_LIB yaml-cpp ${YAML_CPP_LIBRARIES} ${Boost_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${CUDA_LIBRARIES} ${CUDA_CUDART_LIBRARY} ${PYTHON_LIBRARIES} ${OpenMP_CXX_FLAGS} zmq ) ``` -------------------------------- ### BibTeX Entry for BundleSDF Paper Source: https://github.com/nvlabs/bundlesdf/blob/master/readme.md This is the BibTeX entry for the BundleSDF paper published in CVPR 2023. Use this for academic citations. ```bibtex @InProceedings{bundlesdfwen2023, author = {Bowen Wen and Jonathan Tremblay and Valts Blukis and Stephen Tyree and Thomas M"{u}ller and Alex Evans and Dieter Fox and Jan Kautz and Stan Birchfield}, title = {{BundleSDF}: {N}eural 6-{DoF} Tracking and {3D} Reconstruction of Unknown Objects}, booktitle = {CVPR}, year = {2023}, } ``` -------------------------------- ### Conditional Gurobi Linking Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Conditionally links Gurobi libraries if the GUROBI variable is defined, ensuring Gurobi support is only included when available. ```cmake if(DEFINED GUROBI) target_link_libraries(${PROJECT_NAME} PUBLIC ${GUROBI_LIBRARY} ${GUROBI_CXX_LIBRARY}) endif() ``` -------------------------------- ### Remove Problematic PCL Components Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/CMakeLists.txt Removes the 'pcl_simulation' component from the PCL libraries list, likely to avoid conflicts or issues during the build process. ```cmake list(REMOVE_ITEM PCL_LIBRARIES pcl_simulation) ``` -------------------------------- ### Prediction and Evaluation Plotting Function Source: https://github.com/nvlabs/bundlesdf/blob/master/BundleTrack/LoFTR/notebooks/visualize_dump_results.ipynb Defines a function to generate a plot visualizing feature matches, errors, and pose information. It handles image loading, resizing (for ScanNet), and uses a colormap to represent epipolar errors. ```python def make_prediction_and_evaluation_plot(root_dir, pe, path=None, source='ScanNet'): img0 = cv2.imread(str(root_dir / pe['pair_names'][0]), cv2.IMREAD_GRAYSCALE) img1 = cv2.imread(str(root_dir / pe['pair_names'][1]), cv2.IMREAD_GRAYSCALE) if source == 'ScanNet': img0 = cv2.resize(img0, (640, 480)) img1 = cv2.resize(img1, (640, 480)) thr = 5e-4 mkpts0 = pe['mkpts0_f'] mkpts1 = pe['mkpts1_f'] color = error_colormap(pe['epi_errs'], thr, alpha=0.3) text = [ f"LoFTR", f"#Matches: {len(mkpts0)}", f"$\Delta$R:{pe['R_errs']:.2f}°, $\Delta$t:{pe['t_errs']:.2f}°", ] if path: make_matching_figure(img0, img1, mkpts0, mkpts1, color, text=text, path=path) else: return make_matching_figure(img0, img1, mkpts0, mkpts1, color, text=text) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.