Compare commits
3 Commits
master
...
feat/cmake
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ec6a85921 | |||
| cab98936dd | |||
| 7405454480 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
rpt_wrap.*
|
||||
rptPYTHON_wrap.*
|
||||
rpt.py
|
||||
*.bin
|
||||
|
||||
|
||||
17
CMakeLists.txt
Normal file
17
CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
|
||||
project(RapidPoseTriangulation
|
||||
VERSION 0.1.0
|
||||
LANGUAGES CXX
|
||||
DESCRIPTION "Rapid Pose Triangulation library with Python bindings"
|
||||
)
|
||||
|
||||
# Global settings
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Add subdirectories
|
||||
add_subdirectory(rpt)
|
||||
add_subdirectory(swig)
|
||||
@ -32,9 +32,9 @@ RUN cat /onnxruntime/cmake/deps.txt && \
|
||||
ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/cmake-3.30.1-linux-x86_64/bin:${PATH}
|
||||
ARG CMAKE_CUDA_ARCHITECTURES=75;80;90
|
||||
ENV TRT_VERSION=10.5.0.18
|
||||
RUN /bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh
|
||||
RUN /bin/sh onnxruntime/dockerfiles/scripts/checkout_submodules.sh ${trt_version}
|
||||
RUN ls
|
||||
RUN /bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh \
|
||||
&& /bin/sh onnxruntime/dockerfiles/scripts/checkout_submodules.sh ${trt_version}
|
||||
|
||||
RUN cd onnxruntime && \
|
||||
/bin/sh build.sh --allow_running_as_root --parallel --build_shared_lib \
|
||||
--cuda_home /usr/local/cuda --cudnn_home /usr/lib/x86_64-linux-gnu/ --use_tensorrt \
|
||||
|
||||
24
rpt/CMakeLists.txt
Normal file
24
rpt/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
# RPT Core Library
|
||||
|
||||
set(RPT_SOURCES
|
||||
camera.cpp
|
||||
interface.cpp
|
||||
triangulator.cpp
|
||||
)
|
||||
|
||||
add_library(rpt_core STATIC ${RPT_SOURCES})
|
||||
|
||||
target_include_directories(rpt_core PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_options(rpt_core PRIVATE
|
||||
-fPIC
|
||||
-march=native
|
||||
-Wall
|
||||
)
|
||||
|
||||
# Release mode optimizations
|
||||
target_compile_options(rpt_core PRIVATE
|
||||
$<$<CONFIG:Release>:-O3;-flto=auto>
|
||||
)
|
||||
@ -3,6 +3,7 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#include "camera.hpp"
|
||||
|
||||
@ -208,7 +209,7 @@ void CameraInternal::undistort_point_fisheye(std::array<float, 3> &p, const std:
|
||||
// https://github.com/opencv/opencv/blob/4.x/modules/calib3d/src/fisheye.cpp#L429
|
||||
|
||||
float theta_d = std::sqrt(p[0] * p[0] + p[1] * p[1]);
|
||||
float pi_half = std::numbers::pi * 0.5;
|
||||
float pi_half = M_PI * 0.5;
|
||||
theta_d = std::min(std::max(-pi_half, theta_d), pi_half);
|
||||
|
||||
if (theta_d < 1e-6)
|
||||
|
||||
@ -377,7 +377,7 @@ std::vector<std::vector<std::array<float, 4>>> TriangulatorInternal::triangulate
|
||||
// Triangulate and score
|
||||
auto [pose3d, score] = triangulate_and_score(
|
||||
pose1_core, pose2_core, cam1, cam2, roomparams, core_limbs_idx);
|
||||
all_scored_poses[i] = std::move(std::make_pair(pose3d, score));
|
||||
all_scored_poses[i] = std::make_pair(std::move(pose3d), score);
|
||||
}
|
||||
|
||||
// Drop low scoring poses
|
||||
|
||||
43
swig/CMakeLists.txt
Normal file
43
swig/CMakeLists.txt
Normal file
@ -0,0 +1,43 @@
|
||||
# SWIG Python bindings for RapidPoseTriangulation
|
||||
|
||||
# Find required packages
|
||||
find_package(SWIG REQUIRED COMPONENTS python)
|
||||
find_package(Python3 REQUIRED COMPONENTS Development)
|
||||
|
||||
# Include SWIG macros
|
||||
include(UseSWIG)
|
||||
|
||||
# Compiler flags for SWIG wrapper
|
||||
set(RPT_COMPILE_FLAGS -fPIC -march=native -Wall)
|
||||
|
||||
# Release mode optimizations
|
||||
list(APPEND RPT_COMPILE_FLAGS $<$<CONFIG:Release>:-O3;-flto=auto>)
|
||||
|
||||
# SWIG interface
|
||||
set_property(SOURCE rpt.i PROPERTY CPLUSPLUS ON)
|
||||
set_property(SOURCE rpt.i PROPERTY SWIG_MODULE_NAME rpt)
|
||||
|
||||
# Set output directory for generated files to match original Makefile behavior
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
swig_add_library(rpt
|
||||
TYPE MODULE
|
||||
LANGUAGE python
|
||||
OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTFILE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
SOURCES rpt.i
|
||||
)
|
||||
|
||||
# Link the SWIG module
|
||||
target_link_libraries(rpt PRIVATE rpt_core Python3::Module)
|
||||
target_compile_options(rpt PRIVATE ${RPT_COMPILE_FLAGS})
|
||||
|
||||
# Set the output directory
|
||||
set_target_properties(rpt PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Ensure SWIG can find headers
|
||||
target_include_directories(rpt PRIVATE
|
||||
${Python3_INCLUDE_DIRS}
|
||||
)
|
||||
@ -1,14 +0,0 @@
|
||||
# Standard compile options for the C++ executable
|
||||
FLAGS = -fPIC -O3 -march=native -Wall -Werror -flto=auto
|
||||
|
||||
# The Python interface through SWIG
|
||||
PYTHON_VERSION = $(shell python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}");')
|
||||
PYTHONI = -I/usr/include/python$(PYTHON_VERSION)/
|
||||
PYTHONL = -Xlinker -export-dynamic
|
||||
|
||||
# Default super-target
|
||||
all:
|
||||
cd ../rpt/ && g++ $(FLAGS) -std=c++2a -c *.cpp ; cd ../swig/
|
||||
swig -c++ -python -keyword -o rpt_wrap.cxx rpt.i
|
||||
g++ $(FLAGS) $(PYTHONI) -c rpt_wrap.cxx -o rpt_wrap.o
|
||||
g++ $(FLAGS) $(PYTHONL) -shared ../rpt/*.o rpt_wrap.o -o _rpt.so
|
||||
Reference in New Issue
Block a user