Skip to content

Commit

Permalink
v2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcseacave committed Jan 6, 2024
1 parent add11b7 commit da4b76c
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 51 deletions.
39 changes: 18 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ SET(OpenMVS_BUILD_TOOLS ON CACHE BOOL "Build example applications")
SET(OpenMVS_USE_OPENMP ON CACHE BOOL "Enable OpenMP library")
SET(OpenMVS_USE_OPENGL ON CACHE BOOL "Enable OpenGL library")
SET(OpenMVS_USE_BREAKPAD ON CACHE BOOL "Enable BreakPad library")
SET(OpenMVS_USE_PYTHON OFF CACHE BOOL "Enable Python library bindings")
SET(OpenMVS_USE_PYTHON ON CACHE BOOL "Enable Python library bindings")
SET(OpenMVS_USE_CERES OFF CACHE BOOL "Enable CERES optimization library")
SET(OpenMVS_USE_CUDA ON CACHE BOOL "Enable CUDA library")
SET(OpenMVS_USE_FAST_FLOAT2INT ON CACHE BOOL "Use an optimized code to convert real numbers to int")
SET(OpenMVS_USE_FAST_FLOAT2INT OFF CACHE BOOL "Use an optimized code to convert real numbers to int")
SET(OpenMVS_USE_FAST_INVSQRT OFF CACHE BOOL "Use an optimized code to compute the inverse square root (slower in fact on modern compilers)")
SET(OpenMVS_USE_FAST_CBRT ON CACHE BOOL "Use an optimized code to compute the cubic root")
SET(OpenMVS_USE_FAST_CBRT OFF CACHE BOOL "Use an optimized code to compute the cubic root")
SET(OpenMVS_USE_SSE ON CACHE BOOL "Enable SSE optimizations")
SET(OpenMVS_MAX_CUDA_COMPATIBILITY OFF CACHE BOOL "Build for maximum CUDA device compatibility")
SET(OpenMVS_ENABLE_TESTS ON CACHE BOOL "Enable test code")
SET(OpenMVS_USE_SSE ON CACHE BOOL "Enable SSE optimizations")

# Load automatically VCPKG toolchain if available
IF(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{VCPKG_ROOT})
Expand All @@ -52,7 +52,7 @@ ENDIF()
PROJECT(OpenMVS)

SET(OpenMVS_MAJOR_VERSION 2)
SET(OpenMVS_MINOR_VERSION 2)
SET(OpenMVS_MINOR_VERSION 3)
SET(OpenMVS_PATCH_VERSION 0)
SET(OpenMVS_VERSION ${OpenMVS_MAJOR_VERSION}.${OpenMVS_MINOR_VERSION}.${OpenMVS_PATCH_VERSION})

Expand Down Expand Up @@ -114,16 +114,15 @@ if(OpenMVS_USE_CUDA)
ENABLE_LANGUAGE(CUDA)
# CUDA-11.x can not be compiled using C++14 standard on Windows
string(REGEX MATCH "^[0-9]+" CUDA_MAJOR ${CMAKE_CUDA_COMPILER_VERSION})
if(${CUDA_MAJOR} GREATER 10 AND CMAKE_CXX_COMPILER MATCHES "MSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29")
message("Working around windows build failure with visual studio. Visual studio 16.10 introduced a compiler bug with compilng CUDA code with C++14. Set the cuda standard to 17 as a workaround.")
set(CMAKE_CUDA_STANDARD 17)
if(${CUDA_MAJOR} GREATER 10)
SET(CMAKE_CUDA_STANDARD 17)
endif()
EXECUTE_PROCESS(COMMAND "${CMAKE_CUDA_COMPILER}" --list-gpu-arch
OUTPUT_VARIABLE LIST_GPU_ARCH
ERROR_QUIET)
if(NOT LIST_GPU_ARCH AND OpenMVS_MAX_CUDA_COMPATIBILITY)
message(WARNING "Cannot compile for max CUDA compatibility, nvcc does not support --list-gpu-arch")
set(OpenMVS_MAX_CUDA_COMPATIBILITY NO)
SET(OpenMVS_MAX_CUDA_COMPATIBILITY OFF)
endif()
if(NOT OpenMVS_MAX_CUDA_COMPATIBILITY)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
Expand Down Expand Up @@ -179,19 +178,19 @@ endif()

SET(Boost_EXTRA_COMPONENTS "")
if(OpenMVS_USE_PYTHON)
FIND_PACKAGE(PythonLibs 3.0 REQUIRED)
if(PythonLibs_FOUND)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
LIST(APPEND OpenMVS_EXTRA_INCLUDES ${PYTHON_INCLUDE_DIRS})
LIST(APPEND OpenMVS_EXTRA_LIBS ${PYTHON_LIBRARIES})
LIST(APPEND Boost_EXTRA_COMPONENTS python3)
MESSAGE(STATUS "Python ${PYTHON_VERSION} found (include: ${PYTHON_INCLUDE_DIRS})")
FIND_PACKAGE(Python3 COMPONENTS Interpreter Development REQUIRED)
if(Python3_FOUND)
INCLUDE_DIRECTORIES(${Python3_INCLUDE_DIRS})
LIST(APPEND OpenMVS_EXTRA_INCLUDES ${Python3_INCLUDE_DIRS})
LIST(APPEND OpenMVS_EXTRA_LIBS ${Python3_LIBRARIES})
LIST(APPEND Boost_EXTRA_COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
MESSAGE(STATUS "Python ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} found (include: ${Python3_INCLUDE_DIRS})")
else()
MESSAGE("-- Can't find Python. Continuing without it.")
endif()
endif()

FIND_PACKAGE(Boost REQUIRED COMPONENTS iostreams program_options system serialization ${Boost_EXTRA_COMPONENTS})
FIND_PACKAGE(Boost REQUIRED COMPONENTS iostreams program_options system serialization OPTIONAL_COMPONENTS ${Boost_EXTRA_COMPONENTS})
if(Boost_FOUND)
LIST(APPEND OpenMVS_EXTRA_INCLUDES ${Boost_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
Expand All @@ -202,10 +201,8 @@ if(Boost_FOUND)
LIST(APPEND Boost_LIBRARIES zstd)
endif()
SET(_USE_BOOST TRUE)
if(OpenMVS_USE_PYTHON)
if(Boost_python3_FOUND)
SET(_USE_BOOST_PYTHON TRUE)
endif()
if(OpenMVS_USE_PYTHON AND Boost_${Boost_EXTRA_COMPONENTS}_FOUND)
SET(_USE_BOOST_PYTHON TRUE)
endif()
endif()

Expand Down
24 changes: 16 additions & 8 deletions build/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -407,33 +407,41 @@ macro(optimize_default_compiler_settings)
else()
set(CXX_CHECK_PREFIX "--std=")
endif()
check_cxx_compiler_flag("${CXX_CHECK_PREFIX}c++20" SUPPORTS_STD_CXX20)
check_cxx_compiler_flag("${CXX_CHECK_PREFIX}c++17" SUPPORTS_STD_CXX17)
check_cxx_compiler_flag("${CXX_CHECK_PREFIX}c++14" SUPPORTS_STD_CXX14)
check_cxx_compiler_flag("${CXX_CHECK_PREFIX}c++11" SUPPORTS_STD_CXX11)
if(SUPPORTS_STD_CXX17)
if(SUPPORTS_STD_CXX20)
set(CMAKE_CXX_STANDARD 20)
elseif(SUPPORTS_STD_CXX17)
set(CMAKE_CXX_STANDARD 17)
elseif(SUPPORTS_STD_CXX14)
set(CMAKE_CXX_STANDARD 14)
elseif(SUPPORTS_STD_CXX11)
set(CMAKE_CXX_STANDARD 11)
endif()
else()
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_17" CXX_STD_INDEX)
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_20" CXX_STD_INDEX)
if(${CXX_STD_INDEX} GREATER -1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
else()
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_14" CXX_STD_INDEX)
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_17" CXX_STD_INDEX)
if(${CXX_STD_INDEX} GREATER -1)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
else()
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_11" CXX_STD_INDEX)
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_14" CXX_STD_INDEX)
if(${CXX_STD_INDEX} GREATER -1)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
else()
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_11" CXX_STD_INDEX)
if(${CXX_STD_INDEX} GREATER -1)
set(CMAKE_CXX_STANDARD 11)
endif()
endif()
endif()
endif()
endif()
if(CLANG AND (CMAKE_CXX_STANDARD EQUAL 11 OR CMAKE_CXX_STANDARD EQUAL 14 OR CMAKE_CXX_STANDARD EQUAL 17))
if(CLANG AND (CMAKE_CXX_STANDARD EQUAL 11 OR CMAKE_CXX_STANDARD EQUAL 14 OR CMAKE_CXX_STANDARD EQUAL 17 OR CMAKE_CXX_STANDARD EQUAL 20))
set(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++")
add_extra_compiler_option(-stdlib=libc++)
endif()
Expand Down
4 changes: 2 additions & 2 deletions libs/Common/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ class TPoint2 : public cv::Point_<TYPE>
#endif

// conversion to another data type
template <typename T> inline operator TPoint2<T> () const { return TPoint2<T>(x,y); }
template <typename T> inline operator TPoint2<T> () const { return TPoint2<T>((T)x,(T)y); }

// pointer to the first element access
inline const TYPE* ptr() const { return &x; }
Expand Down Expand Up @@ -1391,7 +1391,7 @@ class TPoint3 : public cv::Point3_<TYPE>
#endif

// conversion to another data type
template <typename T> inline operator TPoint3<T> () const { return TPoint3<T>(x,y,z); }
template <typename T> inline operator TPoint3<T> () const { return TPoint3<T>((T)x,(T)y,(T)z); }

// pointer to the first element access
inline const TYPE* ptr() const { return &x; }
Expand Down
18 changes: 9 additions & 9 deletions libs/Common/Types.inl
Original file line number Diff line number Diff line change
Expand Up @@ -574,57 +574,57 @@ FORCEINLINE bool ISEQUAL(const cv::Matx<TYPE,m,n>& v1, const cv::Matx<TYPE,m,n>&
template <typename TYPE, typename INTTYPE=int>
FORCEINLINE SEACAVE::TPoint2<INTTYPE> Floor2Int(const cv::Point_<TYPE>& v)
{
return SEACAVE::TPoint2<INTTYPE>(FLOOR2INT(v.x), FLOOR2INT(v.y));
return SEACAVE::TPoint2<INTTYPE>(FLOOR2INT<INTTYPE>(v.x), FLOOR2INT<INTTYPE>(v.y));
}
template <typename TYPE, typename INTTYPE=int>
FORCEINLINE SEACAVE::TPoint2<INTTYPE> Ceil2Int(const cv::Point_<TYPE>& v)
{
return SEACAVE::TPoint2<INTTYPE>(CEIL2INT(v.x), CEIL2INT(v.y));
return SEACAVE::TPoint2<INTTYPE>(CEIL2INT<INTTYPE>(v.x), CEIL2INT<INTTYPE>(v.y));
}
template <typename TYPE, typename INTTYPE=int>
FORCEINLINE SEACAVE::TPoint2<INTTYPE> Round2Int(const cv::Point_<TYPE>& v)
{
return SEACAVE::TPoint2<INTTYPE>(ROUND2INT(v.x), ROUND2INT(v.y));
return SEACAVE::TPoint2<INTTYPE>(ROUND2INT<INTTYPE>(v.x), ROUND2INT<INTTYPE>(v.y));
}

template <typename TYPE, typename INTTYPE=int>
FORCEINLINE SEACAVE::TPoint3<INTTYPE> Floor2Int(const cv::Point3_<TYPE>& v)
{
return SEACAVE::TPoint3<INTTYPE>(FLOOR2INT(v.x), FLOOR2INT(v.y), FLOOR2INT(v.z));
return SEACAVE::TPoint3<INTTYPE>(FLOOR2INT<INTTYPE>(v.x), FLOOR2INT<INTTYPE>(v.y), FLOOR2INT<INTTYPE>(v.z));
}
template <typename TYPE, typename INTTYPE=int>
FORCEINLINE SEACAVE::TPoint3<INTTYPE> Ceil2Int(const cv::Point3_<TYPE>& v)
{
return SEACAVE::TPoint3<INTTYPE>(CEIL2INT(v.x), CEIL2INT(v.y), CEIL2INT(v.z));
return SEACAVE::TPoint3<INTTYPE>(CEIL2INT<INTTYPE>(v.x), CEIL2INT<INTTYPE>(v.y), CEIL2INT<INTTYPE>(v.z));
}
template <typename TYPE, typename INTTYPE=int>
FORCEINLINE SEACAVE::TPoint3<INTTYPE> Round2Int(const cv::Point3_<TYPE>& v)
{
return SEACAVE::TPoint3<INTTYPE>(ROUND2INT(v.x), ROUND2INT(v.y), ROUND2INT(v.z));
return SEACAVE::TPoint3<INTTYPE>(ROUND2INT<INTTYPE>(v.x), ROUND2INT<INTTYPE>(v.y), ROUND2INT<INTTYPE>(v.z));
}

template <typename TYPE, int m, int n, typename INTTYPE=int>
FORCEINLINE SEACAVE::TMatrix<INTTYPE,m,n> Floor2Int(const cv::Matx<TYPE,m,n>& v)
{
SEACAVE::TMatrix<INTTYPE,m,n> nv;
for (int i=0; i<m*n; ++i)
nv.val[i] = Floor2Int(v.val[i]);
nv.val[i] = FLOOR2INT<INTTYPE>(v.val[i]);
return nv;
}
template <typename TYPE, int m, int n, typename INTTYPE=int>
FORCEINLINE SEACAVE::TMatrix<INTTYPE,m,n> Ceil2Int(const cv::Matx<TYPE,m,n>& v)
{
SEACAVE::TMatrix<INTTYPE,m,n> nv;
for (int i=0; i<m*n; ++i)
nv.val[i] = Ceil2Int(v.val[i]);
nv.val[i] = CEIL2INT<INTTYPE>(v.val[i]);
return nv;
}
template <typename TYPE, int m, int n, typename INTTYPE=int>
FORCEINLINE SEACAVE::TMatrix<INTTYPE,m,n> Round2Int(const cv::Matx<TYPE,m,n>& v)
{
SEACAVE::TMatrix<INTTYPE,m,n> nv;
for (int i=0; i<m*n; ++i)
nv.val[i] = Round2Int(v.val[i]);
nv.val[i] = ROUND2INT<INTTYPE>(v.val[i]);
return nv;
}

Expand Down
6 changes: 3 additions & 3 deletions libs/Common/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ class GENERAL_API Util
public:
static String getAppName() {
#ifdef _MSC_VER
TCHAR buf[MAX_PATH+1];
GetModuleFileName(NULL, buf, MAX_PATH);
return ensureUnifySlash(String(buf));
String buf(MAX_PATH+1, '\0');
GetModuleFileName(NULL, &buf.front(), MAX_PATH);
return ensureUnifySlash(buf);
#else // _MSC_VER
LPTSTR home = getenv("HOME");
if (home == NULL)
Expand Down
2 changes: 2 additions & 0 deletions libs/MVS/PythonWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* containing it.
*/

#include "ConfigLocal.h"

#ifdef _USE_BOOST_PYTHON

#undef _USRDLL
Expand Down
6 changes: 3 additions & 3 deletions libs/MVS/SceneRefineCUDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2400,13 +2400,13 @@ void MeshRefineCUDA::SubdivideMesh(uint32_t maxArea, float fDecimate, unsigned n
ListFaceAreas(maxAreas);
ASSERT(!maxAreas.IsEmpty());

const float maxArea((float)(maxArea > 0 ? maxArea : 64));
const float maxAreaf((float)(maxArea > 0 ? maxArea : 64));
const float medianArea(6.f*(float)Mesh::AreaArr(maxAreas).GetMedian());
if (medianArea < maxArea) {
if (medianArea < maxAreaf) {
maxAreas.Empty();

// decimate to the auto detected resolution
scene.mesh.Clean(MAXF(0.1f, medianArea/maxArea), 0.f, false, nCloseHoles, 0u, 0.f, false);
scene.mesh.Clean(MAXF(0.1f, medianArea/maxAreaf), 0.f, false, nCloseHoles, 0u, 0.f, false);
scene.mesh.Clean(1.f, 0.f, false, nCloseHoles, 0u, 0.f, true);

#ifdef MESHOPT_ENSUREEDGESIZE
Expand Down
4 changes: 2 additions & 2 deletions libs/MVS/SceneTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ bool MeshTexture::FaceViewSelection(unsigned minCommonCameras, float fOutlierThr

#if TEXOPT_INFERENCE == TEXOPT_INFERENCE_LBP
// initialize inference structures
const LBPInference::EnergyType MaxEnergy(fRatioDataSmoothness*LBPInference::MaxEnergy);
const LBPInference::EnergyType MaxEnergy(fRatioDataSmoothness*(LBPInference::EnergyType)LBPInference::MaxEnergy);
LBPInference inference; {
inference.SetNumNodes(virtualFaces.size());
inference.SetSmoothCost(SmoothnessPotts);
Expand Down Expand Up @@ -1219,7 +1219,7 @@ bool MeshTexture::FaceViewSelection(unsigned minCommonCameras, float fOutlierThr

#if TEXOPT_INFERENCE == TEXOPT_INFERENCE_LBP
// initialize inference structures
const LBPInference::EnergyType MaxEnergy(fRatioDataSmoothness*LBPInference::MaxEnergy);
const LBPInference::EnergyType MaxEnergy(fRatioDataSmoothness*(LBPInference::EnergyType)LBPInference::MaxEnergy);
LBPInference inference; {
inference.SetNumNodes(faces.size());
inference.SetSmoothCost(SmoothnessPotts);
Expand Down
6 changes: 4 additions & 2 deletions libs/MVS/SemiGlobalMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,8 @@ void SemiGlobalMatcher::Disparity2DepthMap(const DisparityMap& disparityMap, con
auto pixel = [&](int, int r, int c) {
const ImageRef x(c,r); Point2f u;
ProjectVertex_3x3_2_2(H.val, x.ptr(), u.ptr());
u.x -= halfWindowSizeX; u.y -= halfWindowSizeY;
u.x -= (float)halfWindowSizeX;
u.y -= (float)halfWindowSizeY;
float disparity;
if (!disparityMap.sampleSafe(disparity, u, [](Disparity d) { return d != NO_DISP; })) {
depthMap(x) = 0;
Expand All @@ -1897,7 +1898,8 @@ void SemiGlobalMatcher::Disparity2DepthMap(const DisparityMap& disparityMap, con
auto pixel = [&](int, int r, int c) {
const ImageRef x(c,r); Point2f u;
ProjectVertex_3x3_2_2(H.val, x.ptr(), u.ptr());
u.x -= halfWindowSizeX; u.y -= halfWindowSizeY;
u.x -= (float)halfWindowSizeX;
u.y -= (float)halfWindowSizeY;
float disparity;
if (!disparityMap.sampleSafe(disparity, u, [](Disparity d) { return d != NO_DISP; }))
depthMap(x) = 0;
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openmvs",
"version": "2.2.0",
"version": "2.3.0",
"description": "OpenMVS: open Multi-View Stereo reconstruction library",
"homepage": "https://cdcseacave.github.io/openMVS",
"dependencies": [
Expand Down

0 comments on commit da4b76c

Please sign in to comment.