Skip to content

Commit

Permalink
mvs: split CameraCUDA in Maths and Camera
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcseacave committed Aug 26, 2024
1 parent 8e42439 commit b1d8f0d
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 57 deletions.
5 changes: 2 additions & 3 deletions libs/Common/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@
#endif



//optimization flags
// optimization flags
#if defined(_MSC_VER)
# define ALIGN(n) __declspec(align(n))
# define NOINITVTABLE __declspec(novtable) //disable generating code to initialize the vfptr in the constructor(s) and destructor of the class
Expand Down Expand Up @@ -229,7 +228,7 @@
#else
#define ASSERT(exp, ...) {if (!(exp)) __debugbreak();}
#endif // _INC_CRTDBG
#define TRACE(...) {TCHAR buffer[2048]; _sntprintf(buffer, 2048, __VA_ARGS__); OutputDebugString(buffer);}
#define TRACE(...) {TCHAR buffer[2048]; _sntprintf(buffer, 2048, __VA_ARGS__); OutputDebugString(buffer);}
#else // _MSC_VER
#include <assert.h>
#define ASSERT(exp, ...) assert(exp)
Expand Down
12 changes: 12 additions & 0 deletions libs/Common/List.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// I N C L U D E S /////////////////////////////////////////////////

#include <utility>
#include <type_traits>


// D E F I N E S ///////////////////////////////////////////////////
Expand Down Expand Up @@ -1154,6 +1155,17 @@ class cList
}
}

// remove duplicated values; the values are expected to be sorted, set bSort if not
template <bool bSort=true>
inline void RemoveDuplicates()
{
if (bSort)
Sort();
const IDX index(std::unique(Begin(), End()) - Begin());
if (index < _size)
RemoveLast(_size-index);
}

inline void RemoveAtMove(IDX index)
{
ASSERT(index < _size);
Expand Down
8 changes: 8 additions & 0 deletions libs/MVS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ if(_USE_CUDA)
FILE(GLOB LIBRARY_FILES_CUDA "*.cu")
LIST(APPEND LIBRARY_FILES_C ${LIBRARY_FILES_CUDA})
endif()
FILE(GLOB CUDA_LIBRARY_FILES_C "CUDA/*.cpp")
FILE(GLOB CUDA_LIBRARY_FILES_H "CUDA/*.h" "CUDA/*.inl")
if(_USE_CUDA)
FILE(GLOB CUDA_LIBRARY_FILES_CUDA "CUDA/*.cu")
LIST(APPEND CUDA_LIBRARY_FILES_C ${CUDA_LIBRARY_FILES_CUDA})
endif()
SOURCE_GROUP("CUDA" FILES ${CUDA_LIBRARY_FILES_C} ${CUDA_LIBRARY_FILES_H})

GET_FILENAME_COMPONENT(PATH_PythonWrapper_cpp ${CMAKE_CURRENT_SOURCE_DIR}/PythonWrapper.cpp ABSOLUTE)
LIST(REMOVE_ITEM LIBRARY_FILES_C "${PATH_PythonWrapper_cpp}")

cxx_library_with_type(MVS "Libs" "" "${cxx_default}"
${LIBRARY_FILES_C} ${LIBRARY_FILES_H}
${CUDA_LIBRARY_FILES_C} ${CUDA_LIBRARY_FILES_H}
)

# Manually set Common.h as the precompiled header
Expand Down
25 changes: 2 additions & 23 deletions libs/MVS/CameraCUDA.h → libs/MVS/CUDA/Camera.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* CameraCUDA.h
* Camera.h
*
* Copyright (c) 2014-2024 SEACAVE
*
Expand Down Expand Up @@ -35,25 +35,10 @@

// I N C L U D E S /////////////////////////////////////////////////

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdint>
#include <float.h>
#include <string>
#include <vector>

// Eigen
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int
#include <Eigen/Dense>

// CUDA toolkit
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cuda_texture_types.h>
#include <curand_kernel.h>
#include <vector_types.h>

#include "../Common/UtilCUDADevice.h"
#include "Maths.h"


// D E F I N E S ///////////////////////////////////////////////////
Expand All @@ -65,12 +50,6 @@ namespace MVS {

namespace CUDA {

typedef Eigen::Matrix<int,2,1> Point2i;
typedef Eigen::Matrix<float,2,1> Point2;
typedef Eigen::Matrix<float,3,1> Point3;
typedef Eigen::Matrix<float,4,1> Point4;
typedef Eigen::Matrix<float,3,3> Matrix3;

// Linear camera model
struct LinearCameraModel {
Point2 f; // focal length
Expand Down
Loading

0 comments on commit b1d8f0d

Please sign in to comment.