Skip to content

Commit

Permalink
Merge branch 'develop' into dev/hdrMerge_autoRefLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
demoulinv authored Jan 23, 2023
2 parents 53d4b21 + 648cee8 commit 3207c9a
Show file tree
Hide file tree
Showing 102 changed files with 9,585 additions and 6,983 deletions.
63 changes: 63 additions & 0 deletions src/aliceVision/depthMap/BufPtr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// This file is part of the AliceVision project.
// Copyright (c) 2017 AliceVision contributors.
// This Source Code Form is subject to the terms of the Mozilla Public License,
// v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#pragma once

// allows code sharing between NVCC and other compilers
#if defined(__NVCC__)
#define CUDA_HOST_DEVICE __host__ __device__
#define CUDA_HOST __host__
#else
#define CUDA_HOST_DEVICE
#define CUDA_HOST
#endif

namespace aliceVision {
namespace depthMap {

template <typename T>
class BufPtr
{
public:

CUDA_HOST_DEVICE BufPtr(T* ptr, size_t pitch)
: _ptr( (unsigned char*)ptr )
, _pitch( pitch )
{}

CUDA_HOST_DEVICE inline T* ptr() { return (T*)(_ptr); }
CUDA_HOST_DEVICE inline T* row(size_t y) { return (T*)(_ptr + y * _pitch); }
CUDA_HOST_DEVICE inline T& at(size_t x, size_t y) { return row(y)[x]; }

CUDA_HOST_DEVICE inline const T* ptr() const { return (const T*)(_ptr); }
CUDA_HOST_DEVICE inline const T* row(size_t y) const { return (const T*)(_ptr + y * _pitch); }
CUDA_HOST_DEVICE inline const T& at(size_t x, size_t y) const { return row(y)[x]; }

private:
BufPtr();
BufPtr(const BufPtr&);
BufPtr& operator*=(const BufPtr&);

unsigned char* const _ptr;
const size_t _pitch;
};


template <typename T>
static inline T* get3DBufferAt_h(T* ptr, size_t spitch, size_t pitch, size_t x, size_t y, size_t z)
{
return ((T*)(((char*)ptr) + z * spitch + y * pitch)) + x;
}

template <typename T>
static inline const T* get3DBufferAt_h(const T* ptr, size_t spitch, size_t pitch, size_t x, size_t y, size_t z)
{
return ((const T*)(((const char*)ptr) + z * spitch + y * pitch)) + x;
}

} // namespace depthMap
} // namespace aliceVision

142 changes: 99 additions & 43 deletions src/aliceVision/depthMap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,75 +1,130 @@
# Headers
set(depthMap_files_headers
BufPtr.hpp
computeOnMultiGPUs.hpp
depthMap.hpp
DepthSimMap.hpp
depthMapUtils.hpp
DepthMapParams.hpp
Refine.hpp
RefineParams.hpp
Sgm.hpp
SgmDepthList.hpp
SgmParams.hpp
Tile.hpp
volumeIO.hpp
)

# Sources
set(depthMap_files_sources
computeOnMultiGPUs.cpp
depthMap.cpp
DepthSimMap.cpp
depthMapUtils.cpp
Refine.cpp
Sgm.cpp
SgmParams.cpp
SgmDepthList.cpp
volumeIO.cpp
)

# Cuda Headers
set(depthMap_cuda_files_headers
# Headers
cuda/deviceCommon/device_patch_es_glob.hpp
cuda/planeSweeping/host_utils.h
cuda/planeSweeping/plane_sweeping_cuda.hpp
# deviceCommon
cuda/deviceCommon/device_color.cu
cuda/deviceCommon/device_global.cu
cuda/deviceCommon/device_matrix.cu
cuda/deviceCommon/device_matrix.cuh
cuda/deviceCommon/device_patch_es.cu
cuda/deviceCommon/device_simStat.cu
cuda/deviceCommon/device_operators.cuh
cuda/deviceCommon/device_utils.cuh
cuda/deviceCommon/device_utils.h
# planeSweeping
cuda/planeSweeping/device_code.cu
cuda/planeSweeping/device_code_refine.cu
cuda/planeSweeping/device_code_volume.cu
cuda/planeSweeping/device_code_fuse.cu
# normalmap
cuda/normalmap/device_eig33.cuh
# Cuda Host Headers Only
set(depthMap_cuda_host_headers
cuda/host/LRUCameraCache.hpp
cuda/host/LRUCache.hpp
cuda/host/divUp.hpp
cuda/host/memory.hpp
)

set_source_files_properties(${depthMap_cuda_files_headers}
# Cuda Host Sources
set(depthMap_cuda_host_sources
cuda/host/utils.hpp
cuda/host/utils.cpp
cuda/host/DeviceStreamManager.cpp
cuda/host/DeviceStreamManager.hpp
cuda/host/DeviceCache.cpp
cuda/host/DeviceCache.hpp
cuda/host/DeviceCamera.cpp
cuda/host/DeviceCamera.hpp
)

# device CUDA Headers Only
set(depthMap_cuda_device_headers
cuda/device/buffer.cuh
cuda/device/color.cuh
cuda/device/eig33.cuh
cuda/device/matrix.cuh
cuda/device/operators.cuh
cuda/device/Patch.cuh
cuda/device/SimStat.cuh
)

# device CUDA Sources
set(depthMap_cuda_device_sources
cuda/device/DeviceCameraParams.hpp
cuda/device/DeviceCameraParams.cu
)

# imageProcessing CUDA Sources
set(depthMap_cuda_imageProcessing_sources
cuda/imageProcessing/deviceGaussianFilter.hpp
cuda/imageProcessing/deviceGaussianFilter.cu
cuda/imageProcessing/deviceColorConversion.hpp
cuda/imageProcessing/deviceColorConversion.cu
)

# normalMapping CUDA Headers Only
set(depthMap_cuda_normalMapping_headers
cuda/normalMapping/deviceNormalMapKernels.cuh
)

# normalMapping CUDA Sources
set(depthMap_cuda_normalMapping_sources
cuda/normalMapping/deviceNormalMap.hpp
cuda/normalMapping/deviceNormalMap.cu
cuda/normalMapping/DeviceNormalMapper.hpp
cuda/normalMapping/DeviceNormalMapper.cpp
)

# planeSweeping CUDA Headers Only
set(depthMap_cuda_planeSweeping_headers
cuda/planeSweeping/deviceDepthSimilarityMapKernels.cuh
cuda/planeSweeping/deviceSimilarityVolumeKernels.cuh
)

# planeSweeping CUDA Sources
set(depthMap_cuda_planeSweeping_sources
cuda/planeSweeping/similarity.hpp
cuda/planeSweeping/deviceDepthSimilarityMap.hpp
cuda/planeSweeping/deviceDepthSimilarityMap.cu
cuda/planeSweeping/deviceSimilarityVolume.hpp
cuda/planeSweeping/deviceSimilarityVolume.cu
)

set_source_files_properties(${depthMap_cuda_host_headers}
${depthMap_cuda_device_headers}
${depthMap_cuda_normalMapping_headers}
${depthMap_cuda_planeSweeping_headers}

PROPERTIES HEADER_FILE_ONLY true
)

source_group("aliceVision_depthMap_cuda_host" FILES ${depthMap_cuda_host_headers} ${depthMap_cuda_host_sources})
source_group("aliceVision_depthMap_cuda_device" FILES ${depthMap_cuda_device_headers} ${depthMap_cuda_device_sources})
source_group("aliceVision_depthMap_cuda_imageProcessing" FILES ${depthMap_cuda_imageProcessing_sources})
source_group("aliceVision_depthMap_cuda_normalMapping" FILES ${depthMap_cuda_normalMapping_headers} ${depthMap_cuda_normalMapping_sources})
source_group("aliceVision_depthMap_cuda_planeSweeping" FILES ${depthMap_cuda_planeSweeping_headers} ${depthMap_cuda_planeSweeping_sources})

# Cuda Sources
set(depthMap_cuda_files_sources
cuda/commonStructures.hpp
cuda/FrameCacheMemory.cpp
cuda/FrameCacheMemory.hpp
cuda/LRUCache.hpp
cuda/OneTC.hpp
cuda/PlaneSweepingCuda.cpp
cuda/PlaneSweepingCuda.hpp
cuda/planeSweeping/plane_sweeping_cuda.hpp
cuda/planeSweeping/plane_sweeping_cuda.cu
cuda/normalmap/normal_map.hpp
cuda/normalmap/normal_map.cu
cuda/images/gauss_filter.hpp
cuda/images/gauss_filter.cu
${depthMap_cuda_files_headers}
${depthMap_cuda_host_headers}
${depthMap_cuda_host_sources}
${depthMap_cuda_device_headers}
${depthMap_cuda_device_sources}
${depthMap_cuda_imageProcessing_sources}
${depthMap_cuda_normalMapping_headers}
${depthMap_cuda_normalMapping_sources}
${depthMap_cuda_planeSweeping_headers}
${depthMap_cuda_planeSweeping_sources}
)

source_group("aliceVision_depthMap_cuda" FILES ${depthMap_cuda_files_sources})

alicevision_add_library(aliceVision_depthMap
USE_CUDA
SOURCES
Expand All @@ -81,6 +136,7 @@ alicevision_add_library(aliceVision_depthMap
aliceVision_mvsUtils
aliceVision_system
Boost::filesystem
assimp::assimp
${CUDA_CUDADEVRT_LIBRARY}
${CUDA_CUBLAS_LIBRARIES} #TODO shouldn't be here, but required to build on some machines
PRIVATE_LINKS
Expand Down
37 changes: 37 additions & 0 deletions src/aliceVision/depthMap/DepthMapParams.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This file is part of the AliceVision project.
// Copyright (c) 2022 AliceVision contributors.
// This Source Code Form is subject to the terms of the Mozilla Public License,
// v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#pragma once

#include <aliceVision/mvsUtils/TileParams.hpp>
#include <aliceVision/depthMap/SgmParams.hpp>
#include <aliceVision/depthMap/RefineParams.hpp>

namespace aliceVision {
namespace depthMap {

/**
* @brief Depth Map Parameters
*/
struct DepthMapParams
{
// user parameters

mvsUtils::TileParams tileParams; //< tiling parameters
SgmParams sgmParams; //< parameters of Sgm process
RefineParams refineParams; //< parameters of Refine process
int maxTCams = 10; //< global T cameras maximum
bool chooseTCamsPerTile = true; //< choose T cameras per R tile or for the entire R image
bool exportTilePattern = false; //< export tile pattern obj
bool autoAdjustSmallImage = true; //< allow program to override parameters for the single tile case

// constant parameters

const bool useRefine = true; //< for debug purposes: enable or disable Refine process
};

} // namespace depthMap
} // namespace aliceVision
Loading

0 comments on commit 3207c9a

Please sign in to comment.