Skip to content

Commit

Permalink
Merge pull request opencv#2 from mihaibujanca/dynamicfusion
Browse files Browse the repository at this point in the history
More directory restructuring, getting CUDA through opencv rather than…
  • Loading branch information
mihaibujanca committed Sep 9, 2017
2 parents cd918ef + 26cbdcd commit 1974106
Show file tree
Hide file tree
Showing 40 changed files with 475 additions and 553 deletions.
71 changes: 20 additions & 51 deletions modules/dynamicfusion/CMakeLists.txt
@@ -1,58 +1,10 @@
set(the_description "Non-rigid 3D reconstruction")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DFORCE_INLINERS -D_MWAITXINTRIN_H_INCLUDED")

#
## ---[ Solution name
#
## ---[ utility
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(cmake/Utils.cmake)
#include(cmake/Targets.cmake)
#
## ---[ find dependencies
find_package(CUDA REQUIRED)
#find_package(OpenNI)
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS} ${Boost_INCLUDE_DIR} ${CUDA_INCLUDE_DIRS} ${OPENNI_INCLUDE_DIR} "kfusion/src/utils" "kfusion/include/nanoflann")
#if(OPENNI_FOUND)
# message("FOUND OPENNI AT: ${OPENNI_INCLUDE_DIR}")
#endif()
## ---[ misc settings
#if(USE_PROJECT_FOLDERS)
# set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
#endif()
#
## ---[ cuda settings
#set(HAVE_CUDA 1)
#list(APPEND CUDA_NVCC_FLAGS "-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_61,code=sm_61")
#
#if(UNIX OR APPLE)
# list(APPEND CUDA_NVCC_FLAGS "-Xcompiler;-fPIC;")
#endif()
#
#warnings_disable(CMAKE_CXX_FLAGS /wd4985)
#
#set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "--ftz=true;--prec-div=false;--prec-sqrt=false")
#add_module_library(kfusion)
#if(OPENNI_FOUND)
# target_compile_definitions(kfusion PRIVATE OPENNI_FOUND=1)
#endif()
#target_link_libraries(kfusion ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${OPENNI_LIBRARY} ${CERES_LIBRARIES})
#add_subdirectory(apps)
#
#if(BUILD_TESTS)
# find_package(GTest REQUIRED)
# if( GTEST_FOUND )
# message( "Found Gtest at ${GTEST_ROOT}")
# message( "GTest Libs: ${GTEST_BOTH_LIBRARIES}")
# message( "GTest Include: ${GTEST_INCLUDE_DIRS}")
# include_directories(${GTEST_INCLUDE_DIRS})
# add_subdirectory(tests)
# endif()
#endif()
find_package(Boost REQUIRED COMPONENTS system filesystem program_options)
ocv_define_module(dynamicfusion opencv_core opencv_calib3d opencv_viz opencv_highgui)
include(cmake/Targets.cmake)

ocv_define_module(dynamicfusion opencv_core opencv_viz opencv_imgproc)

ocv_warnings_disable(CMAKE_CXX_FLAGS
-Wundef
Expand All @@ -63,3 +15,20 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS
-Wunused-parameter
-Wunused-function
)

find_package(Ceres QUIET)

if (NOT Ceres_FOUND)
message(STATUS "${the_module} has been disabled because Ceres library has not been found")
ocv_module_disable(${the_module})
else()
include_directories(${CERES_INCLUDE_DIRS})
ocv_target_link_libraries(${the_module} ${CERES_LIBRARIES})
endif()
if(NOT HAVE_CUDA)
message(STATUS "${the_module} currently requires CUDA to run")
ocv_module_disable(${the_module})
else()
include_directories(${CUDA_INCLUDE_DIRS})
ocv_target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
endif()
78 changes: 0 additions & 78 deletions modules/dynamicfusion/cmake/Modules/FindOpenNI.cmake

This file was deleted.

57 changes: 24 additions & 33 deletions modules/dynamicfusion/cmake/Targets.cmake
Expand Up @@ -2,8 +2,8 @@
# short command to setup source group
function(kf_source_group group)
cmake_parse_arguments(VW_SOURCE_GROUP "" "" "GLOB" ${ARGN})
file(GLOB srcs ${VW_SOURCE_GROUP_GLOB})
#list(LENGTH ${srcs} ___size)
file(GLOB srcs ${VW_SOURCE_GROUP_GLOB})
#list(LENGTH ${srcs} ___size)
#if (___size GREATER 0)
source_group(${group} FILES ${srcs})
#endif()
Expand All @@ -12,7 +12,7 @@ endfunction()

################################################################################################
# short command getting sources from standard directores
macro(pickup_std_sources)
macro(pickup_std_sources)
kf_source_group("Include" GLOB "include/${module_name}/*.h*")
kf_source_group("Include\\cuda" GLOB "include/${module_name}/cuda/*.h*")
kf_source_group("Source" GLOB "src/*.cpp" "src/*.h*")
Expand All @@ -25,13 +25,13 @@ endmacro()
################################################################################################
# short command for declaring includes from other modules
macro(declare_deps_includes)
foreach(__arg ${ARGN})
foreach(__arg ${ARGN})
get_filename_component(___path "${CMAKE_SOURCE_DIR}/modules/${__arg}/include" ABSOLUTE)
if (EXISTS ${___path})
if (EXISTS ${___path})
include_directories(${___path})
endif()
endforeach()

unset(___path)
unset(__arg)
endmacro()
Expand All @@ -40,21 +40,21 @@ endmacro()
################################################################################################
# short command for setting defeault target properties
function(default_properties target)
set_target_properties(${target} PROPERTIES
set_target_properties(${target} PROPERTIES
DEBUG_POSTFIX "d"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

if (NOT ${target} MATCHES "^test_")
install(TARGETS ${the_target} RUNTIME DESTINATION ".")
endif()
endfunction()

function(test_props target)
#os_project_label(${target} "[test]")
#os_project_label(${target} "[test]")
if(USE_PROJECT_FOLDERS)
set_target_properties(${target} PROPERTIES FOLDER "Tests")
endif()
endif()
endfunction()

function(app_props target)
Expand All @@ -68,11 +68,11 @@ endfunction()
################################################################################################
# short command for setting defeault target properties
function(default_properties target)
set_target_properties(${target} PROPERTIES
set_target_properties(${target} PROPERTIES
DEBUG_POSTFIX "d"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

if (NOT ${target} MATCHES "^test_")
install(TARGETS ${the_target} RUNTIME DESTINATION ".")
endif()
Expand All @@ -82,32 +82,32 @@ endfunction()
################################################################################################
# short command for adding library module
macro(add_module_library name)
set(module_name ${name})
set(module_name ${name})
pickup_std_sources()
include_directories(include src src/cuda src/utils)

set(__has_cuda OFF)
check_cuda(__has_cuda)
check_cuda(__has_cuda)

set(__lib_type STATIC)
if (${ARGV1} MATCHES "SHARED|STATIC")
set(__lib_type ${ARGV1})
endif()

if (__has_cuda)
if (__has_cuda)
cuda_add_library(${module_name} ${__lib_type} ${sources})
else()
add_library(${module_name} ${__lib_type} ${sources})
endif()

if(MSVC)
set_target_properties(${module_name} PROPERTIES DEFINE_SYMBOL KFUSION_API_EXPORTS)
else()
add_definitions(-DKFUSION_API_EXPORTS)
endif()
endif()

default_properties(${module_name})

if(USE_PROJECT_FOLDERS)
set_target_properties(${module_name} PROPERTIES FOLDER "Libraries")
endif()
Expand All @@ -125,16 +125,7 @@ endmacro()
################################################################################################
# short command for adding application module
macro(add_application target sources)
add_executable(${target} ${sources})
add_executable(${target} ${sources})
default_properties(${target})
app_props(${target})
endmacro()


################################################################################################
# short command for adding test target
macro(add_test the_target)
add_executable(${the_target} ${ARGN})
default_properties(${the_target})
test_props(${the_target})
endmacro()
6 changes: 4 additions & 2 deletions modules/dynamicfusion/include/opencv2/dynamicfusion.hpp
@@ -1,5 +1,7 @@
#ifndef OPENCV_DYNAMICFUSION_HPP
#define OPENCV_DYNAMICFUSION_HPP
#include <opencv2/kfusion/kinfu.hpp>
#include <opencv2/kfusion/cuda/tsdf_volume.hpp>
#include <opencv2/dynamicfusion/kinfu.hpp>
#include <opencv2/dynamicfusion/warp_field.hpp>
#include <opencv2/dynamicfusion/types.hpp>
#include <opencv2/dynamicfusion/cuda/tsdf_volume.hpp>
#endif //OPENCV_DYNAMICFUSION_HPP
Expand Up @@ -13,7 +13,8 @@
//__kf_device__
//kfusion::device::TsdfVolume::TsdfVolume(const TsdfVolume& other)
// : data(other.data), dims(other.dims), voxel_size(other.voxel_size), trunc_dist(other.trunc_dist), max_weight(other.max_weight) {}

namespace cv
{
__kf_device__ kfusion::device::TsdfVolume::elem_type* kfusion::device::TsdfVolume::operator()(int x, int y, int z)
{ return data + x + y*dims.x + z*dims.y*dims.x; }

Expand Down Expand Up @@ -120,8 +121,4 @@ namespace kfusion
template<> __kf_device__ void kfusion::device::gmem::StCs(const ushort2& val, ushort2* ptr) { *ptr = val; }
#endif






}

0 comments on commit 1974106

Please sign in to comment.