Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,26 @@ else()
set(GPU_RUNTIME "CPU")
endif()

set(CMAKE_CXX_STANDARD 17)
# Use C++20 when the compiler supports it (required by libtorch >= 2.13),
# otherwise fall back to C++17
if("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
set(OPENSPLAT_CXX_STANDARD 20)
else()
set(OPENSPLAT_CXX_STANDARD 17)
endif()
message(STATUS "Using C++ standard: ${OPENSPLAT_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD ${OPENSPLAT_CXX_STANDARD})
if((GPU_RUNTIME STREQUAL "CUDA") OR (GPU_RUNTIME STREQUAL "HIP"))
enable_language(${GPU_RUNTIME})
set(CMAKE_${GPU_RUNTIME}_STANDARD 17)
set(${GPU_RUNTIME}_STANDARD 17)
string(TOLOWER "${GPU_RUNTIME}" GPU_RUNTIME_LOWER)
if("${GPU_RUNTIME_LOWER}_std_${OPENSPLAT_CXX_STANDARD}" IN_LIST CMAKE_${GPU_RUNTIME}_COMPILE_FEATURES)
set(OPENSPLAT_GPU_STANDARD ${OPENSPLAT_CXX_STANDARD})
else()
set(OPENSPLAT_GPU_STANDARD 17)
endif()
message(STATUS "Using ${GPU_RUNTIME} standard: ${OPENSPLAT_GPU_STANDARD}")
set(CMAKE_${GPU_RUNTIME}_STANDARD ${OPENSPLAT_GPU_STANDARD})
set(${GPU_RUNTIME}_STANDARD ${OPENSPLAT_GPU_STANDARD})
endif()

if (NOT WIN32 AND NOT APPLE)
Expand Down Expand Up @@ -305,7 +320,7 @@ if(OPENSPLAT_USE_PCH)
endif()

install(TARGETS opensplat DESTINATION bin)
set_property(TARGET opensplat PROPERTY CXX_STANDARD 17)
set_property(TARGET opensplat PROPERTY CXX_STANDARD ${OPENSPLAT_CXX_STANDARD})
target_include_directories(opensplat PRIVATE
${PROJECT_SOURCE_DIR}/rasterizer
${GPU_INCLUDE_DIRS}
Expand Down Expand Up @@ -351,7 +366,7 @@ if(OPENSPLAT_BUILD_SIMPLE_TRAINER)
if (NOT WIN32)
target_link_libraries(simple_trainer PUBLIC pthread)
endif()
set_property(TARGET simple_trainer PROPERTY CXX_STANDARD 17)
set_property(TARGET simple_trainer PROPERTY CXX_STANDARD ${OPENSPLAT_CXX_STANDARD})
if(GPU_RUNTIME STREQUAL "HIP")
target_compile_definitions(simple_trainer PRIVATE USE_HIP __HIP_PLATFORM_AMD__)
elseif(GPU_RUNTIME STREQUAL "CUDA")
Expand All @@ -366,7 +381,7 @@ endif()
# the DLLs need to be copied to avoid memory errors.
if (MSVC)
file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
file(GLOB OPENCV_DLL "${OPENCV_DIR}/x64/vc16/bin/opencv_world490.dll")
file(GLOB OPENCV_DLL "${OPENCV_DIR}/x64/vc16/bin/opencv_world*[0-9].dll")
set(DLLS_TO_COPY ${TORCH_DLLS} ${OPENCV_DLL})
add_custom_command(TARGET opensplat
POST_BUILD
Expand Down
13 changes: 13 additions & 0 deletions colmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ InputData inputDataFromColmap(const std::string &projectRoot){
cam->k2 = readBinary<double>(camf);
cam->p1 = readBinary<double>(camf);
cam->p2 = readBinary<double>(camf);
}else if (model == FullOpenCV){
cam->fx = readBinary<double>(camf);
cam->fy = readBinary<double>(camf);
cam->cx = readBinary<double>(camf);
cam->cy = readBinary<double>(camf);
cam->k1 = readBinary<double>(camf);
cam->k2 = readBinary<double>(camf);
cam->p1 = readBinary<double>(camf);
cam->p2 = readBinary<double>(camf);
cam->k3 = readBinary<double>(camf);
cam->k4 = readBinary<double>(camf);
cam->k5 = readBinary<double>(camf);
cam->k6 = readBinary<double>(camf);
}else{
throw std::runtime_error("Unsupported camera model: " + std::to_string(model));
}
Expand Down
4 changes: 2 additions & 2 deletions input_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ torch::Tensor Camera::getImage(int downscaleFactor){
}

bool Camera::hasDistortionParameters(){
return k1 != 0.0f || k2 != 0.0f || k3 != 0.0f || p1 != 0.0f || p2 != 0.0f;
return k1 != 0.0f || k2 != 0.0f || k3 != 0.0f || k4 != 0.0f || k5 != 0.0f || k6 != 0.0f || p1 != 0.0f || p2 != 0.0f;
}

std::vector<float> Camera::undistortionParameters(){
std::vector<float> p = { k1, k2, p1, p2, k3, 0.0f, 0.0f, 0.0f };
std::vector<float> p = { k1, k2, p1, p2, k3, k4, k5, k6 };
return p;
}

Expand Down
3 changes: 3 additions & 0 deletions input_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ struct Camera{
float k1 = 0;
float k2 = 0;
float k3 = 0;
float k4 = 0;
float k5 = 0;
float k6 = 0;
float p1 = 0;
float p2 = 0;
torch::Tensor camToWorld;
Expand Down
Loading