TensorRT inference for SuperPoint feature detection, with an C++/Eigen3 API.
- CUDA + TensorRT (
libnvinfer-dev) - Eigen3
- Python 3 + PyTorch (for export only)
SuperPoint architecture and weights are vendored in this repo (python/, weights/). No network fetch required for export.
./scripts/export_and_build.sh
# Optional overrides:
WIDTH=640 HEIGHT=480 MAX_KP=1024 ./scripts/export_and_build.shManual export:
python/.venv/bin/python python/export_superpoint_to_onnx.py \
--width 640 --height 480 --max-keypoints 1024 \
-o weights/superpoint_640x480_k1024.onnxBuild the TensorRT engine with trtexec (required before running inference):
trtexec \
--onnx=weights/superpoint_640x480_k1024.onnx \
--saveEngine=weights/superpoint_640x480_k1024.onnx.engine \
--skipInferenceSuperPointTrt::loadEngine() loads this pre-built engine file at runtime.
#include "superpoint_trt/SuperPointTrt.hpp"
sptrt::SuperPointTrtConfig cfg;
cfg.engine = "weights/superpoint_640x480_k1024.onnx.engine";
cfg.image_width = 640;
cfg.image_height = 480;
cfg.max_keypoints = 1024;
sptrt::SuperPointTrt detector(cfg);
detector.loadEngine();
std::vector<std::uint8_t> gray(detector.imagePixels());
sptrt::MonoImage image{0.0, detector.imageWidth(), detector.imageHeight(),
gray.data()};
auto frame = detector.detect(image);Set image_width and image_height to match the exported ONNX/engine. MonoImage::data must point to a contiguous buffer of width * height bytes.
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j8Link against superpoint_trt and ensure CUDA/TensorRT libraries are on LD_LIBRARY_PATH.
Requires OpenCV (core, imgcodecs, imgproc, features2d) and test images at test/data/img0.png, test/data/img1.png.
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DSPTRT_BUILD_OPENCV_TESTS=ON
make -j8
./sptrt_opencv_tests --gtest_filter=SuperPointTrt.DetectMatchAndVisualizeOpenCvImagesWrites match visualizations to build/test/superpoint_bruteforce_matches.png (SuperPoint descriptor L2 + ratio test) and build/test/orb_bruteforce_matches.png (ORB Hamming + ratio test, up to 1024 features), plus per-image keypoint overlays at build/test/img0_keypoints.png and build/test/img1_keypoints.png.
Example output from the OpenCV visualization test on test/data/img0.png and test/data/img1.png (640×480 inference, up to 1024 keypoints). SuperPoint detect() average: ~6.1 ms per frame on an NVIDIA GeForce RTX 4090 Laptop GPU (after warmup).
| img0 keypoints | img1 keypoints |
![]() |
![]() |
Brute-force matches (SuperPoint descriptor L2 + Lowe ratio test; 132 accepted):
Brute-force matches (ORB descriptor Hamming distance + Lowe ratio test; 111 accepted)

- SuperPoint ONNX uses a fixed input resolution and
max_keypoints(top-k on the score map). Re-export when changing resolution or keypoint budget. - SuperPoint weights follow the rpautrat PyTorch port (
weights/superpoint_v6_from_tf.pth).
SuperPoint rpautrat PyTorch port: MIT.


