Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
420ccf8
Started adding 16bit and 32bit support for tiff
pierotofy Oct 28, 2020
80a783d
Read TIFF refactoring
pierotofy Oct 30, 2020
638cbfa
Reading grayscale 16bit tiffs
pierotofy Oct 30, 2020
baf516c
Percentile min/max scaling, fixes
pierotofy Nov 2, 2020
ba552d5
Support for 32bit float TIFFs
pierotofy Nov 2, 2020
cee37b0
Fix tabs
pierotofy Nov 2, 2020
d52d681
Refactoring
pierotofy Nov 3, 2020
6d8337d
Fix ComputePercentileMinMax edge case
pierotofy Nov 3, 2020
7634066
Fix style
pierotofy Nov 3, 2020
f0accc6
Remove file logging
pierotofy Dec 5, 2020
ec3c547
Export num views in PLY
pierotofy Jan 12, 2021
b859487
Do not write log
pierotofy May 15, 2021
1f525eb
add mock cuda-device opt
pierotofy May 27, 2022
e1f48b8
Do not precompile headers on Windows
pierotofy Jun 6, 2022
05fee28
Add support for PF_R32G32B32 inputs
pierotofy Jul 26, 2022
6952ade
Fix ignore mask on GPU, remove disk space info
pierotofy Sep 19, 2022
8dd9223
Ignore masks in outer scope
pierotofy Sep 20, 2022
8ecc0f8
Remove vcpkg manifest mode
pierotofy Dec 1, 2022
59a0275
Fix merge, add support for PF_R16G16B16
pierotofy May 26, 2023
f0fe735
Disable CMP0127 and SSE optimizations for ARM
DodgySpaniard Aug 21, 2023
ff2d81d
Disable builds for unused projects.
DodgySpaniard Aug 21, 2023
1117ce7
Adapt PLY Properties FPCFilter
DodgySpaniard Aug 21, 2023
59ed513
Export views field in PLY
pierotofy Aug 21, 2023
b0b814b
Add read permissions to GO
pierotofy Feb 24, 2025
8bedb23
Allow disabling subdirectory on install
sylveon May 16, 2026
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ ENDIF()
# ${OpenMVS_BINARY_DIR}.
PROJECT(OpenMVS)

cmake_policy(SET CMP0127 NEW)
cmake_dependent_option(OpenMVS_USE_SSE "Enable SSE optimizations" ON "NOT CMAKE_SYSTEM_PROCESSOR MATCHES \"^(arm|ARM|aarch64|AARCH64).\"" OFF)
# cmake_policy(SET CMP0127 NEW)
# cmake_dependent_option(OpenMVS_USE_SSE "Enable SSE optimizations" ON "NOT CMAKE_SYSTEM_PROCESSOR MATCHES \"^(arm|ARM|aarch64|AARCH64).\"" OFF)

SET(OpenMVS_MAJOR_VERSION 2)
SET(OpenMVS_MINOR_VERSION 2)
Expand Down
14 changes: 7 additions & 7 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Add applications
ADD_SUBDIRECTORY(InterfaceCOLMAP)
ADD_SUBDIRECTORY(InterfaceMetashape)
ADD_SUBDIRECTORY(InterfaceMVSNet)
ADD_SUBDIRECTORY(InterfacePolycam)
#ADD_SUBDIRECTORY(InterfaceCOLMAP)
#ADD_SUBDIRECTORY(InterfaceMetashape)
#ADD_SUBDIRECTORY(InterfaceMVSNet)
#ADD_SUBDIRECTORY(InterfacePolycam)
ADD_SUBDIRECTORY(DensifyPointCloud)
ADD_SUBDIRECTORY(ReconstructMesh)
ADD_SUBDIRECTORY(RefineMesh)
ADD_SUBDIRECTORY(TextureMesh)
ADD_SUBDIRECTORY(TransformScene)
ADD_SUBDIRECTORY(Viewer)
#ADD_SUBDIRECTORY(TextureMesh)
#ADD_SUBDIRECTORY(TransformScene)
#ADD_SUBDIRECTORY(Viewer)
if(OpenMVS_ENABLE_TESTS)
ADD_SUBDIRECTORY(Tests)
endif()
5 changes: 4 additions & 1 deletion apps/DensifyPointCloud/DensifyPointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ int nExportNumViews;
int nArchiveType;
int nProcessPriority;
unsigned nMaxThreads;
int mockCudaDevice;
String strConfigFileName;
boost::program_options::variables_map vm;
} // namespace OPT
Expand Down Expand Up @@ -101,6 +102,8 @@ bool Initialize(size_t argc, LPCTSTR* argv)
#endif
#ifdef _USE_CUDA
("cuda-device", boost::program_options::value(&CUDA::desiredDeviceID)->default_value(-1), "CUDA device number to be used for depth-map estimation (-2 - CPU processing, -1 - best GPU, >=0 - device index)")
#else
("cuda-device", boost::program_options::value(&OPT::mockCudaDevice)->default_value(-1), "Just a placeholder (not a CUDA build)")
#endif
;

Expand Down Expand Up @@ -196,7 +199,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
}

// initialize the log file
OPEN_LOGFILE(MAKE_PATH(APPNAME _T("-")+Util::getUniqueName(0)+_T(".log")).c_str());
//OPEN_LOGFILE(MAKE_PATH(APPNAME _T("-")+Util::getUniqueName(0)+_T(".log")).c_str());

// print application details: version and command line
Util::LogBuild();
Expand Down
2 changes: 1 addition & 1 deletion apps/ReconstructMesh/ReconstructMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ bool Initialize(size_t argc, LPCTSTR* argv)
}

// initialize the log file
OPEN_LOGFILE(MAKE_PATH(APPNAME _T("-")+Util::getUniqueName(0)+_T(".log")).c_str());
// OPEN_LOGFILE(MAKE_PATH(APPNAME _T("-")+Util::getUniqueName(0)+_T(".log")).c_str());

// print application details: version and command line
Util::LogBuild();
Expand Down
4 changes: 3 additions & 1 deletion apps/Viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ cxx_executable_with_flags(${VIEWER_NAME} "Apps" "${cxx_default}" "MVS;${OPENGL_L

# Manually set Common.h as the precompiled header
IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16.0)
TARGET_PRECOMPILE_HEADERS(${VIEWER_NAME} PRIVATE "Common.h")
if(NOT WIN32) # Smaller but slower build on Windows
TARGET_PRECOMPILE_HEADERS(${VIEWER_NAME} PRIVATE "Common.h")
endif()
endif()

# Install
Expand Down
7 changes: 6 additions & 1 deletion build/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ OPTION(BUILD_RTTI_ENABLED "Enable support run-time type information" ON)
OPTION(BUILD_STATIC_RUNTIME "Link staticaly the run-time library" OFF)
OPTION(CMAKE_SUPPRESS_REGENERATION "This will cause CMake to not put in the rules that re-run CMake. This might be useful if you want to use the generated build files on another machine" OFF)
OPTION(CMAKE_USE_RELATIVE_PATHS "Try to use relative paths in generated projects" OFF)
OPTION(INSTALL_USE_SUBDIR "Install into <dir>/OpenMVS subdirectories" ON)

# Organize projects into folders
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down Expand Up @@ -817,7 +818,11 @@ macro(ConfigLibrary)
else()
set(${varp} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
set(${var} "${${varp}}/${PROJECT_NAME}")
if(INSTALL_USE_SUBDIR)
set(${var} "${${varp}}/${PROJECT_NAME}")
else()
set(${var} "${${varp}}")
endif()
endforeach()
endmacro()

Expand Down
4 changes: 3 additions & 1 deletion libs/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ cxx_library_with_type(Common "Libs" "" "${cxx_default}"

# Manually set Common.h as the precompiled header
IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16.0)
TARGET_PRECOMPILE_HEADERS(Common PRIVATE "Common.h")
if(NOT WIN32) # Smaller but slower build on Windows
TARGET_PRECOMPILE_HEADERS(Common PRIVATE "Common.h")
endif()
endif()

# Link its dependencies
Expand Down
2 changes: 1 addition & 1 deletion libs/Common/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class GENERAL_API File : public IOStream {
if (flags & NOBUFFER)
m |= O_DIRECT;
#endif
h = ::open(aFileName, m, S_IRUSR | S_IWUSR);
h = ::open(aFileName, m, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
}

virtual void close() {
Expand Down
10 changes: 5 additions & 5 deletions libs/Common/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,16 @@ String Util::GetOSInfo()

String Util::GetDiskInfo(const String& path)
{
#if defined(_SUPPORT_CPP17) && (!defined(__GNUC__) || (__GNUC__ > 7))
// #if defined(_SUPPORT_CPP17) && (!defined(__GNUC__) || (__GNUC__ > 8))

const std::filesystem::space_info si = std::filesystem::space(path.c_str());
return String::FormatString("%s (%s) space", formatBytes(si.available).c_str(), formatBytes(si.capacity).c_str());
// const std::filesystem::space_info si = std::filesystem::space(path.c_str());
// return String::FormatString("%s (%s) space", formatBytes(si.available).c_str(), formatBytes(si.capacity).c_str());

#else
// #else

return String();

#endif // _SUPPORT_CPP17
// #endif // _SUPPORT_CPP17
}
/*----------------------------------------------------------------*/

Expand Down
43 changes: 43 additions & 0 deletions libs/Common/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,49 @@ class GENERAL_API Util
lastMsgLen = msgLen;
}
};

template<typename T>
static std::pair<T,T> ComputePercentileMinMax(const T *data, size_t size){
if (size == 0)
return std::make_pair(0, 0);

// Find min/max
T aMin = data[0];
T aMax = data[0];

for (size_t i = 1; i < size; i++) {
if (data[i] > aMax) aMax = data[i];
if (data[i] < aMin) aMin = data[i];
}

const float range = static_cast<float>(aMax - aMin);
if (range == 0.0f)
return std::make_pair(aMin, aMax);

float closestMinP = 9999.0f;
float closestMaxP = 9999.0f;

T min = 0;
T max = 0;

// Get min/max values at the 10th and 90th percentile
for (size_t i = 0; i < size; i++) {
const float percentile = (static_cast<float>(data[i]) - static_cast<float>(aMin)) / range;
const float minP = abs(percentile - 0.1f);
const float maxP = abs(percentile - 0.9f);

if (minP < closestMinP) {
min = data[i];
closestMinP = minP;
}
if (maxP < closestMaxP) {
max = data[i];
closestMaxP = maxP;
}
}

return std::make_pair(min, max);
}
};
/*----------------------------------------------------------------*/

Expand Down
4 changes: 3 additions & 1 deletion libs/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ cxx_library_with_type(IO "Libs" "" "${cxx_default}"

# Manually set Common.h as the precompiled header
IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16.0)
TARGET_PRECOMPILE_HEADERS(IO PRIVATE "Common.h")
if(NOT WIN32) # Smaller but slower build on Windows
TARGET_PRECOMPILE_HEADERS(IO PRIVATE "Common.h")
endif()
endif()

# Link its dependencies
Expand Down
89 changes: 89 additions & 0 deletions libs/IO/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ CImage::Size CImage::GetStride(PIXELFORMAT pixFormat)
{
case PF_A8:
case PF_GRAY8:
case PF_GRAYU16:
case PF_GRAYF32:
return 1;
case PF_R5G6B5:
return 2;
Expand Down Expand Up @@ -237,6 +239,8 @@ bool CImage::FormatHasAlpha(PIXELFORMAT format)
case PF_DXT5:
return true;
case PF_GRAY8:
case PF_GRAYU16:
case PF_GRAYF32:
case PF_R5G6B5:
case PF_B8G8R8:
case PF_R8G8B8:
Expand Down Expand Up @@ -409,6 +413,91 @@ bool CImage::FilterFormat(void* pDst, PIXELFORMAT formatDst, Size strideDst, con
((uint8_t*)pDst)[2] = ((uint8_t*)pSrc)[1];
}
return true;

case PF_GRAYU16:{
// from PF_GRAYU16 to PF_R8G8B8

uint16_t *pData = (uint16_t*)pSrc;
std::pair<uint16_t, uint16_t> mm = Util::ComputePercentileMinMax<uint16_t>(pData, nSzize);
uint16_t min = mm.first;
uint16_t max = mm.second;

for (Size i=0; i<nSzize; ++i,(uint8_t*&)pDst+=strideDst,(uint8_t*&)pSrc+=strideSrc) {
uint16_t v = std::max(min, std::min(max, *((uint16_t*)pSrc)));
uint8_t c = (uint8_t)((255.0 * (double)(v - min) / (double)(max - min)) + 0.5);

((uint8_t*)pDst)[0] = c;
((uint8_t*)pDst)[1] = c;
((uint8_t*)pDst)[2] = c;

}
return true;
}

case PF_GRAYF32:{
// from PF_GRAYF32 to PF_R8G8B8

float *pData = (float*)pSrc;
std::pair<float, float> mm = Util::ComputePercentileMinMax<float>(pData, nSzize);
float min = mm.first;
float max = mm.second;

for (Size i=0; i<nSzize; ++i,(uint8_t*&)pDst+=strideDst,(uint8_t*&)pSrc+=strideSrc) {
float v = std::max(min, std::min(max, *((float*)pSrc)));
uint8_t c = (uint8_t)((255.0 * (double)(v - min) / (double)(max - min)) + 0.5);

((uint8_t*)pDst)[0] = c;
((uint8_t*)pDst)[1] = c;
((uint8_t*)pDst)[2] = c;

}
return true;
}

case PF_R16G16B16:{
// from PF_R16G16B16 to PF_R8G8B8
uint16_t *pData = (uint16_t*)pSrc;
std::pair<uint16_t, uint16_t> mm = Util::ComputePercentileMinMax<uint16_t>(pData, nSzize);
uint16_t min = mm.first;
uint16_t max = mm.second;

for (Size i=0; i<nSzize; ++i,(uint8_t*&)pDst+=strideDst,(uint8_t*&)pSrc+=strideSrc) {
uint16_t v1 = std::max(min, std::min(max, *((uint16_t*)pSrc)));
uint8_t c1 = (uint8_t)((255.0 * (double)(v1 - min) / (double)(max - min)) + 0.5);
uint16_t v2 = std::max(min, std::min(max, *((uint16_t*)pSrc + 1)));
uint8_t c2 = (uint8_t)((255.0 * (double)(v2 - min) / (double)(max - min)) + 0.5);
uint16_t v3 = std::max(min, std::min(max, *((uint16_t*)pSrc + 2)));
uint8_t c3 = (uint8_t)((255.0 * (double)(v3 - min) / (double)(max - min)) + 0.5);

((uint8_t*)pDst)[0] = c3;
((uint8_t*)pDst)[1] = c2;
((uint8_t*)pDst)[2] = c1;
}
return true;
}

case PF_R32G32B32:{
// from PF_R32G32B32 to PF_R8G8B8
float *pData = (float*)pSrc;
std::pair<float, float> mm = Util::ComputePercentileMinMax<float>(pData, nSzize);
float min = mm.first;
float max = mm.second;

for (Size i=0; i<nSzize; ++i,(uint8_t*&)pDst+=strideDst,(uint8_t*&)pSrc+=strideSrc) {
float v1 = std::max(min, std::min(max, *((float*)pSrc)));
uint8_t c1 = (uint8_t)((255.0 * (double)(v1 - min) / (double)(max - min)) + 0.5);
float v2 = std::max(min, std::min(max, *((float*)pSrc + 1)));
uint8_t c2 = (uint8_t)((255.0 * (double)(v2 - min) / (double)(max - min)) + 0.5);
float v3 = std::max(min, std::min(max, *((float*)pSrc + 2)));
uint8_t c3 = (uint8_t)((255.0 * (double)(v3 - min) / (double)(max - min)) + 0.5);

((uint8_t*)pDst)[0] = c3;
((uint8_t*)pDst)[1] = c2;
((uint8_t*)pDst)[2] = c1;
}
return true;
}

}
break;

Expand Down
5 changes: 5 additions & 0 deletions libs/IO/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ typedef enum PIXELFORMAT_TYPE {
// gray
PF_A8,
PF_GRAY8,
PF_GRAYU16, // unsigned 16
PF_GRAYF32, // float 32
// uncompressed RGB
PF_R5G6B5,
PF_R8G8B8,
PF_R8G8B8A8,
PF_A8R8G8B8,
PF_R16G16B16,
PF_R32G32B32,
// uncompressed BGR
PF_B8G8R8,
PF_B8G8R8A8,
Expand Down Expand Up @@ -125,4 +129,5 @@ typedef CSharedPtr<CImage> IMAGEPTR;

} // namespace SEACAVE


#endif // __SEACAVE_IMAGE_H__
Loading