├── .gitignore ├── .gitmodules ├── App ├── CMakeLists.txt ├── Map2Mesh │ ├── CMakeLists.txt │ └── exe_Map2Mesh.cpp ├── SCFusion │ ├── CMakeLists.txt │ ├── main_gui_infinitam.cpp │ └── main_infinitam.cpp ├── TrainingDataGenerator │ ├── CMakeLists.txt │ ├── JsonUtils.h │ ├── Scan2CADAnnotionLoader.h │ ├── Scan2CADObjectLoader.cpp │ ├── Scan2CADObjectLoader.h │ ├── ScanNetMeshLoader.cpp │ ├── ScanNetMeshLoader.h │ ├── ScanNetScan2CADLoader.cpp │ ├── ScanNetScan2CADLoader.h │ ├── ScanNetScan2CAD_SceneToSkip.h │ ├── TrainingDataGenerator.cu │ ├── TrainingDataGenerator.h │ ├── TrainingDataGeneratorInstantiation.cu │ ├── assimp_obj_loader.cpp │ ├── assimp_obj_loader.h │ ├── exe_GroundtruthGenerator_ScanNetScan2CAD.cpp │ ├── exe_TrainingDataGenerator_ScanNetScan2CAD.cpp │ ├── loadCloud2Array.hpp │ └── third_party │ │ ├── json11.cpp │ │ └── json11.hpp ├── extractPoseFromScanNet │ ├── CMakeLists.txt │ └── main.cpp └── rotation │ ├── CMakeLists.txt │ ├── pclloader.hpp │ └── rotmesh.cpp ├── CMakeLists.txt ├── Configurations └── Config_ScanNet.txt ├── ConnectedComponent ├── CMakeLists.txt ├── ConnectedComponent │ ├── CPU │ │ └── ConnectedComponent_CPU.h │ ├── CUDA │ │ ├── ConnectedComponent_CUDA.h │ │ └── ConnectedComponent_CUDA.tcu │ ├── Interface │ │ └── ConnectedComponent.h │ └── Shared │ │ ├── ConnectedComponent_shared.h │ │ └── disjointSet.h └── exe_cc.cpp ├── DenseCRF ├── CMakeLists.txt ├── densecrf.cpp ├── densecrf.h ├── fastmath.h ├── permutohedral.h ├── test │ ├── CMakeLists.txt │ └── test.cpp ├── util.cpp └── util.h ├── FernRelocLib ├── CMakeLists.txt ├── FernConservatory.cpp ├── PoseDatabase.cpp ├── RelocDatabase.cpp ├── Relocaliser.cpp └── include │ └── FernRelocLib │ ├── FernConservatory.h │ ├── PixelUtils.h │ ├── PoseDatabase.h │ ├── RelocDatabase.h │ └── Relocaliser.h ├── Files ├── LabelColorLists.txt ├── LabelColorLists_NYU13.txt ├── LabelColorLists_SunCG11.txt ├── Label_NYU13.h ├── Label_NYU40.h ├── Label_ScanNet.h ├── Label_SunCG11.h └── WnidToNYU13.h ├── ImageLoader ├── CMakeLists.txt ├── CPU │ ├── RIO.hpp │ ├── ScanNet.hpp │ ├── ScanNet │ │ ├── example.cpp │ │ ├── sensorData.cpp │ │ ├── sensorData.h │ │ └── sensorData1 │ │ │ ├── stb_image.h │ │ │ └── stb_image_write.h │ ├── ScanNetPose.hpp │ └── util.h ├── include │ └── ImageLoader │ │ ├── ImageLoadFactory.h │ │ └── ImageLoader.hpp └── src │ ├── RIO.cpp │ ├── ScanNet.cpp │ ├── ScanNetPose.cpp │ └── SceneNetRGBD.cpp ├── LICENSE ├── MainLib ├── CMakeLists.txt ├── CPUInstantiations.cpp ├── CPUInstantiations_SC.cpp ├── CUDAInstantiations.cu ├── CUDAInstantiations_SC.cu ├── Core │ ├── BasicSLAM │ │ ├── CMakeLists.txt │ │ ├── CPUInstantiations.cpp │ │ ├── MainEngine.h │ │ └── MainEngine.tpp │ ├── BasicSurfel │ │ ├── CMakeLists.txt │ │ ├── CPUInstantiations.cpp │ │ ├── ITMBasicSurfelEngine.h │ │ └── ITMBasicSurfelEngine.tpp │ ├── CMakeLists.txt │ ├── DenseMapper │ │ ├── CMakeLists.txt │ │ ├── CPUInstantiations.cpp │ │ ├── ITMDenseMapper.h │ │ └── ITMDenseMapper.tpp │ ├── DenseSurfelMapper │ │ ├── CMakeLists.txt │ │ ├── CPUInstantiations.cpp │ │ ├── ITMDenseSurfelMapper.h │ │ └── ITMDenseSurfelMapper.tpp │ ├── ITMMainEngine.h │ ├── ITMTrackingController.h │ └── SceneCompletion │ │ ├── CMakeLists.txt │ │ ├── CPUInstantiations.cpp │ │ ├── DenseCRFOptimization.h │ │ ├── SceneCompletion.h │ │ └── SceneCompletion.tpp ├── Engines │ ├── CMakeLists.txt │ ├── LowLevel │ │ ├── CMakeLists.txt │ │ ├── CPU │ │ │ ├── ITMLowLevelEngine_CPU.cpp │ │ │ └── ITMLowLevelEngine_CPU.h │ │ ├── CUDA │ │ │ ├── ITMLowLevelEngine_CUDA.cu │ │ │ └── ITMLowLevelEngine_CUDA.h │ │ ├── ITMLowLevelEngineFactory.cpp │ │ ├── ITMLowLevelEngineFactory.h │ │ ├── Interface │ │ │ └── ITMLowLevelEngine.h │ │ └── Shared │ │ │ └── ITMLowLevelEngine_Shared.h │ ├── Meshing │ │ ├── CMakeLists.txt │ │ ├── CPU │ │ │ ├── ITMMeshingEngine_CPU.h │ │ │ └── ITMMeshingEngine_CPU.tpp │ │ ├── CPUInstantiations.cpp │ │ ├── CUDA │ │ │ ├── ITMMeshingEngine_CUDA.h │ │ │ ├── ITMMeshingEngine_CUDA.tcu │ │ │ └── mattdean1 │ │ │ │ ├── Submission.cu │ │ │ │ ├── kernels.cu │ │ │ │ ├── kernels.h │ │ │ │ ├── scan.cu │ │ │ │ ├── scan.h │ │ │ │ ├── utils.cpp │ │ │ │ └── utils.h │ │ ├── CUDAInstantiations.cu │ │ ├── ITMMeshingEngineFactory.h │ │ ├── Interface │ │ │ └── ITMMeshingEngine.h │ │ ├── MeshEngine.h │ │ ├── MeshEngine.tpp │ │ └── Shared │ │ │ └── ITMMeshingEngine_Shared.h │ ├── PointExtraction │ │ ├── CMakeLists.txt │ │ ├── CPU │ │ │ ├── PointCloudExtractionEngine_CPU.h │ │ │ └── PointCloudExtractionEngine_CPU.tpp │ │ ├── CPUInstantiations.cpp │ │ ├── CUDA │ │ │ ├── PointCloudExtractionEngine_CUDA.h │ │ │ └── PointCloudExtractionEngine_CUDA.tcu │ │ ├── CUDAInstantiations.cu │ │ ├── Interface │ │ │ └── PointCloudExtractionEngine.h │ │ ├── PointCloudEngine.h │ │ ├── PointCloudEngine.tpp │ │ ├── PointCloudExtractionEngineFactory.h │ │ └── Shared │ │ │ └── PointCloudExtraction_Shared.h │ ├── Reconstruction │ │ ├── CMakeLists.txt │ │ ├── CPU │ │ │ ├── ITMSceneReconstructionEngine_CPU.h │ │ │ ├── ITMSceneReconstructionEngine_CPU.tpp │ │ │ ├── ITMSurfelSceneReconstructionEngine_CPU.h │ │ │ └── ITMSurfelSceneReconstructionEngine_CPU.tpp │ │ ├── CPUSurfelInstantiations.cpp │ │ ├── CPUVoxelInstantiations.cpp │ │ ├── CUDA │ │ │ ├── ITMSceneReconstructionEngine_CUDA.h │ │ │ ├── ITMSceneReconstructionEngine_CUDA.tcu │ │ │ ├── ITMSurfelSceneReconstructionEngine_CUDA.h │ │ │ └── ITMSurfelSceneReconstructionEngine_CUDA.tcu │ │ ├── CUDASurfelInstantiations.cu │ │ ├── CUDAVoxelInstantiations.cu │ │ ├── ITMSceneReconstructionEngineFactory.h │ │ ├── ITMSurfelSceneReconstructionEngineFactory.h │ │ ├── ITMSurfelSceneReconstructionEngineFactory.tpp │ │ ├── Interface │ │ │ ├── ITMSceneReconstructionEngine.h │ │ │ ├── ITMSurfelSceneReconstructionEngine.h │ │ │ └── ITMSurfelSceneReconstructionEngine.tpp │ │ ├── Metal │ │ │ ├── ITMSceneReconstructionEngine.metal │ │ │ ├── ITMSceneReconstructionEngine_Metal.h │ │ │ └── ITMSceneReconstructionEngine_Metal.mm │ │ └── Shared │ │ │ ├── ITMSceneReconstructionEngine_Shared.h │ │ │ └── ITMSurfelSceneReconstructionEngine_Shared.h │ ├── SceneCompletion │ │ ├── CMakeLists.txt │ │ ├── CUDA │ │ │ ├── SceneCompletionEngine_CUDA.h │ │ │ └── SceneCompletionEngine_CUDA.tcu │ │ ├── CUDAInstantiations.cu │ │ ├── FusionPolicies.h │ │ ├── Interface │ │ │ ├── ForkNet.cpp │ │ │ ├── ForkNet.h │ │ │ ├── SceneCompletionEngine.h │ │ │ ├── SceneInpainting.cpp │ │ │ └── SceneInpainting.h │ │ ├── SceneCompletionEngineFactory.h │ │ └── Shared │ │ │ └── SceneCompletion_Shared.h │ ├── Swapping │ │ ├── CMakeLists.txt │ │ ├── CPU │ │ │ ├── ITMSwappingEngine_CPU.h │ │ │ └── ITMSwappingEngine_CPU.tpp │ │ ├── CPUInstantiations.cpp │ │ ├── CUDA │ │ │ ├── ITMSwappingEngine_CUDA.h │ │ │ └── ITMSwappingEngine_CUDA.tcu │ │ ├── CUDAInstantiations.cu │ │ ├── ITMSwappingEngineFactory.h │ │ ├── Interface │ │ │ └── ITMSwappingEngine.h │ │ ├── Metal │ │ │ ├── ITMSwappingEngine.metal │ │ │ ├── ITMSwappingEngine_Metal.h │ │ │ └── ITMSwappingEngine_Metal.mm │ │ └── Shared │ │ │ └── ITMSwappingEngine_Shared.h │ ├── ViewBuilding │ │ ├── CMakeLists.txt │ │ ├── CPU │ │ │ ├── ITMViewBuilder_CPU.cpp │ │ │ └── ITMViewBuilder_CPU.h │ │ ├── CUDA │ │ │ ├── ITMViewBuilder_CUDA.cu │ │ │ └── ITMViewBuilder_CUDA.h │ │ ├── ITMViewBuilderFactory.cpp │ │ ├── ITMViewBuilderFactory.h │ │ ├── Interface │ │ │ └── ITMViewBuilder.h │ │ └── Shared │ │ │ └── ITMViewBuilder_Shared.h │ └── Visualisation │ │ ├── CMakeLists.txt │ │ ├── CPU │ │ ├── ITMMultiVisualisationEngine_CPU.h │ │ ├── ITMMultiVisualisationEngine_CPU.tpp │ │ ├── ITMSurfelVisualisationEngine_CPU.h │ │ ├── ITMSurfelVisualisationEngine_CPU.tpp │ │ ├── ITMVisualisationEngine_CPU.h │ │ └── ITMVisualisationEngine_CPU.tpp │ │ ├── CPUSurfelInstantiations.cpp │ │ ├── CPUVoxelInstantiations.cpp │ │ ├── CUDA │ │ ├── ITMMultiVisualisationEngine_CUDA.h │ │ ├── ITMMultiVisualisationEngine_CUDA.tcu │ │ ├── ITMSurfelVisualisationEngine_CUDA.h │ │ ├── ITMSurfelVisualisationEngine_CUDA.tcu │ │ ├── ITMVisualisationEngine_CUDA.h │ │ ├── ITMVisualisationEngine_CUDA.tcu │ │ ├── ITMVisualisationHelpers_CUDA.cu │ │ └── ITMVisualisationHelpers_CUDA.h │ │ ├── CUDASurfelInstantiations.cu │ │ ├── CUDAVoxelInstantiations.cu │ │ ├── ITMMultiVisualisationEngineFactory.h │ │ ├── ITMSurfelVisualisationEngineFactory.h │ │ ├── ITMSurfelVisualisationEngineFactory.tpp │ │ ├── ITMVisualisationEngineFactory.h │ │ ├── Interface │ │ ├── ITMMultiVisualisationEngine.h │ │ ├── ITMSurfelVisualisationEngine.h │ │ ├── ITMSurfelVisualisationEngine.tpp │ │ ├── ITMVisualisationEngine.cpp │ │ └── ITMVisualisationEngine.h │ │ ├── Metal │ │ ├── ITMVisualisationEngine.metal │ │ ├── ITMVisualisationEngine_Metal.h │ │ └── ITMVisualisationEngine_Metal.mm │ │ └── Shared │ │ ├── ITMSurfelVisualisationEngine_Settings.h │ │ ├── ITMSurfelVisualisationEngine_Shared.h │ │ └── ITMVisualisationEngine_Shared.h ├── ITMLibDefines.h ├── MainEngine │ ├── CMakeLists.txt │ ├── SCFusion │ │ ├── CMakeLists.txt │ │ ├── SLAM.cpp │ │ └── SLAM.h │ └── SLAM_base │ │ ├── CMakeLists.txt │ │ ├── SLAM.cpp │ │ └── SLAM.h ├── Objects │ ├── Camera │ │ ├── ITMCalibIO.cpp │ │ ├── ITMCalibIO.h │ │ ├── ITMDisparityCalib.h │ │ ├── ITMDistortionCalib.h │ │ ├── ITMExtrinsics.h │ │ ├── ITMIntrinsics.h │ │ └── ITMRGBDCalib.h │ ├── Meshing │ │ └── ITMMesh.h │ ├── Misc │ │ ├── ITMIMUCalibrator.h │ │ ├── ITMIMUMeasurement.h │ │ └── ITMPointCloud.h │ ├── PointCloud │ │ └── PointCloud.h │ ├── RenderStates │ │ ├── ITMRenderState.h │ │ ├── ITMRenderStateFactory.h │ │ ├── ITMRenderState_VH.h │ │ ├── ITMSurfelRenderState.cpp │ │ └── ITMSurfelRenderState.h │ ├── Scene │ │ ├── DistanceField_shared.h │ │ ├── ITMGlobalCache.h │ │ ├── ITMLocalMap.h │ │ ├── ITMLocalScene.h │ │ ├── ITMLocalVBA.h │ │ ├── ITMMultiSceneAccess.h │ │ ├── ITMPlainVoxelArray.h │ │ ├── ITMRepresentationAccess.h │ │ ├── ITMScene.h │ │ ├── ITMSurfelScene.h │ │ ├── ITMSurfelTypes.h │ │ ├── ITMVoxelBlockHash.h │ │ ├── ITMVoxelTypes.h │ │ ├── IntegratePolicies.h │ │ ├── PlainVolume.h │ │ ├── SCPlainVoxelArray.h │ │ └── VoxelIndexInterface.h │ ├── SceneCompletion │ │ └── SceneCompletionBuffer.h │ ├── Tracking │ │ ├── ITMDepthHierarchyLevel.h │ │ ├── ITMImageHierarchy.h │ │ ├── ITMIntensityHierarchyLevel.h │ │ ├── ITMRGBHierarchyLevel.h │ │ ├── ITMSceneHierarchyLevel.h │ │ ├── ITMTemplatedHierarchyLevel.h │ │ ├── ITMTrackingState.h │ │ ├── ITMViewHierarchyLevel.h │ │ └── TrackerIterationType.h │ └── Views │ │ ├── ITMView.h │ │ └── ITMViewIMU.h ├── Trackers │ ├── CMakeLists.txt │ ├── CPU │ │ ├── ITMColorTracker_CPU.cpp │ │ ├── ITMColorTracker_CPU.h │ │ ├── ITMDepthTracker_CPU.cpp │ │ ├── ITMDepthTracker_CPU.h │ │ ├── ITMExtendedTracker_CPU.cpp │ │ └── ITMExtendedTracker_CPU.h │ ├── CUDA │ │ ├── ITMColorTracker_CUDA.cu │ │ ├── ITMColorTracker_CUDA.h │ │ ├── ITMDepthTracker_CUDA.cu │ │ ├── ITMDepthTracker_CUDA.h │ │ ├── ITMExtendedTracker_CUDA.cu │ │ └── ITMExtendedTracker_CUDA.h │ ├── ITMTrackerFactory.h │ ├── Interface │ │ ├── ITMColorTracker.cpp │ │ ├── ITMColorTracker.h │ │ ├── ITMCompositeTracker.h │ │ ├── ITMDepthTracker.cpp │ │ ├── ITMDepthTracker.h │ │ ├── ITMExtendedTracker.cpp │ │ ├── ITMExtendedTracker.h │ │ ├── ITMFileBasedTracker.cpp │ │ ├── ITMFileBasedTracker.h │ │ ├── ITMForceFailTracker.cpp │ │ ├── ITMForceFailTracker.h │ │ ├── ITMIMUTracker.cpp │ │ ├── ITMIMUTracker.h │ │ └── ITMTracker.h │ ├── Metal │ │ ├── ITMExtendedTracker.metal │ │ ├── ITMExtendedTracker_Metal.h │ │ └── ITMExtendedTracker_Metal.mm │ └── Shared │ │ ├── ITMColorTracker_Shared.h │ │ ├── ITMDepthTracker_Shared.h │ │ └── ITMExtendedTracker_Shared.h └── Utils │ ├── CPFIO.h │ ├── CUDAStreamHandler.hpp │ ├── Exceptions.h │ ├── ITMCUDAUtils.h │ ├── ITMImageTypes.h │ ├── ITMLibSettings.cpp │ ├── ITMLibSettings.h │ ├── ITMMath.h │ ├── ITMMemoryBlockTypes.h │ ├── ITMPixelUtils.h │ ├── ITMProjectionUtils.h │ ├── ITMSceneParams.h │ ├── ITMSurfelSceneParams.h │ ├── InSegIO.h │ ├── LibSettingsIO.cpp │ ├── LibSettingsIO.h │ ├── SceneCompletionParams.h │ └── ThreadUnit.hpp ├── MeshVoxelizer ├── CMakeLists.txt ├── MeshVoxelizer.cpp ├── MeshVoxelizer.cu ├── MeshVoxelizer.h ├── PlatformIndependence.h ├── defines.h └── helper_math.h ├── PytorchCpp ├── CMakeLists.txt ├── PytorchCpp.cpp └── include │ └── PytorchCpp │ └── PytorchCpp.h ├── README.md ├── SLAMWrapper ├── CMakeLists.txt ├── gui_kernel.cu └── include │ ├── SLAMGUI │ ├── GUI_SCSLAM.hpp │ ├── GUI_SCSLAM.tpp │ ├── GUI_SLAM.hpp │ ├── GUI_SLAM.tpp │ ├── GUI_SurfelSLAM.hpp │ ├── GUI_SurfelSLAM.tpp │ └── gui_kernel.hpp │ └── SLAMTools │ ├── EvaluationHelper.h │ ├── Parser.hpp │ └── SLAMWrapper.h ├── cmake ├── CUDACheckCompute.cmake ├── FindCUDA.cmake ├── FindCUDA │ ├── make2cmake.cmake │ ├── parse_cubin.cmake │ ├── run_nvcc.cmake │ └── select_compute_arch.cmake ├── FindFreeType2.cmake ├── FindGLM.cmake ├── FindPackageHandleStandardArgs.cmake ├── FindPackageMessage.cmake ├── Findgl3w.cmake ├── Flags.cmake ├── LinkEigen3.cmake ├── LinkFreetype.cmake ├── LinkGTest.cmake ├── LinkOpenCV.cmake ├── LinkPCL.cmake ├── LinkPytorch.cmake ├── SetAppTarget.cmake ├── SetCUDAAppTarget.cmake ├── SetCUDALibTarget.cmake ├── SetLibTarget.cmake ├── UseCUDA.cmake ├── UseCxxTools.cmake ├── UseEigen3.cmake ├── UseFreetype.cmake ├── UseOpenCV.cmake ├── UseOpenMP.cmake ├── UsePytorch.cmake ├── cmake_macro_addExternalProject │ ├── ExternalProject.cmake.in │ └── macro.cmake └── cuda_compute_capability.cpp └── scripts ├── GenerateTrainingData_ScanNetScan2CAD_skip200.py └── RUN_FLIP_SCANNET_MESH.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | cmake-* 3 | build 4 | volume 5 | Models/ 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ORUtils"] 2 | path = ORUtils 3 | url = https://github.com/ShunChengWu/ORUtils 4 | [submodule "stb"] 5 | path = stb 6 | url = git@github.com:nothings/stb.git 7 | [submodule "libGUI3D"] 8 | path = libGUI3D 9 | url = https://github.com/ShunChengWu/libGUI3D.git 10 | [submodule "cnpy"] 11 | path = cnpy 12 | url = git@github.com:rogersce/cnpy.git 13 | -------------------------------------------------------------------------------- /App/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #IF(BUILD_DATAGENERATOR) 2 | # ADD_SUBDIRECTORY(SyntheticDatasetGenerator) 3 | # ADD_SUBDIRECTORY(ModelTextureViewer) 4 | #ENDIF(BUILD_DATAGENERATOR) 5 | #ADD_SUBDIRECTORY(SLAM) 6 | #ADD_SUBDIRECTORY(GUI3D) 7 | 8 | IF(BUILD_DATA_GENERATOR_SCANNET) 9 | #ADD_SUBDIRECTORY(Scan2CADCpp) # for checking unseen wnid and can_ids 10 | ENDIF(BUILD_DATA_GENERATOR_SCANNET) 11 | 12 | IF(BUILD_TRAININGDATA_GENERATOR) 13 | ADD_SUBDIRECTORY(rotation) 14 | ADD_SUBDIRECTORY(TrainingDataGenerator) 15 | ENDIF(BUILD_TRAININGDATA_GENERATOR) 16 | 17 | ADD_SUBDIRECTORY(Map2Mesh) 18 | ADD_SUBDIRECTORY(SCFusion) 19 | 20 | 21 | IF(BUILD_DATA_GENERATOR) 22 | ADD_SUBDIRECTORY(extractPoseFromScanNet) 23 | ADD_SUBDIRECTORY(rotation) 24 | ADD_SUBDIRECTORY(TrainingDataGenerator) 25 | ENDIF(BUILD_DATA_GENERATOR) 26 | 27 | 28 | -------------------------------------------------------------------------------- /App/Map2Mesh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ### -- 3rd party 3 | INCLUDE(UseCUDA) 4 | #INCLUDE(UseFreetype) 5 | 6 | ########################################################################################### 7 | SET(basetargetname exe_Map2Mesh) 8 | file(GLOB srcs *.cpp) 9 | file(GLOB headers *.hpp *.h) 10 | file(GLOB cuda *.cu) 11 | SET(sources 12 | ${srcs} 13 | ${cuda} 14 | ) 15 | SET(headers ${headers}) 16 | 17 | LIST(APPEND NAMES OFusionRGB1Label)# TSDF 18 | LIST(LENGTH NAMES count) 19 | MATH(EXPR count "${count}-1") 20 | FOREACH(i RANGE ${count} ) 21 | LIST(GET NAMES ${i} name) 22 | SET(NAME_SUFFIX _${name}) 23 | SET(targetname ${basetargetname}${NAME_SUFFIX}) 24 | 25 | INCLUDE(SetCUDAAppTarget) 26 | TARGET_LINK_LIBRARIES(${targetname} 27 | PUBLIC SLAMBase${NAME_SUFFIX} 28 | PUBLIC CxxTools 29 | PUBLIC SLAM_Wrapper 30 | ) 31 | set_target_properties(${targetname} PROPERTIES LINKER_LANGUAGE CXX) 32 | set_target_properties(${targetname} PROPERTIES CXX_STANDARD 11) 33 | ENDFOREACH() 34 | -------------------------------------------------------------------------------- /App/Map2Mesh/exe_Map2Mesh.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef SCFUSION::SLAMBase SLAMType; 6 | struct Params{ 7 | std::string pth_in, pth_out, labelColorPath="/home/sc/research/scslam/Files/LabelColorLists_SceneNetRGBD.txt"; 8 | bool labelOnly=false, checkState=false; 9 | Params()=default; 10 | }; 11 | 12 | int ParseCommandLine(int argc, char** argv, Params *params){ 13 | tools::Parser parser(argc,argv); 14 | parser.addOption(pkgcname("pth_in", ¶ms->pth_in), "Path to ground truth.", true); 15 | parser.addOption(pkgcname("labelColorPath", ¶ms->labelColorPath), "label color path.", false); 16 | parser.addOption(pkgcname("pth_out", ¶ms->pth_out), "Path to output folder.", true); 17 | parser.addOption(pkgcname("labelOnly", ¶ms->labelOnly), "labelOnly"); 18 | parser.addOption(pkgcname("checkState", ¶ms->checkState), "checkState"); 19 | if(parser.showMsg()<0) 20 | exit(EXIT_FAILURE); 21 | return 0; 22 | } 23 | 24 | int main (int argc, char ** argv) try { 25 | Params params; 26 | ParseCommandLine(argc, argv, ¶ms); 27 | auto calib = ITMLib::ITMRGBDCalib(); 28 | auto settings = ITMLib::ITMLibSettings(); 29 | settings.deviceType = ITMLib::ITMLibSettings::DEVICE_CUDA; 30 | settings.createPointExtractionEngine = false; 31 | settings.createMeshingEngine = true; 32 | settings.labelColorPath=params.labelColorPath; 33 | calib.intrinsics_rgb.SetFrom(640,480,525,525, 320,240); 34 | calib.intrinsics_d.SetFrom(640,480,525,525, 320,240); 35 | SLAMType slam(&settings, &calib); 36 | slam.LoadFromFile(params.pth_in); 37 | tools::PathTool::create_folder(params.pth_out); 38 | slam.saveSceneToMesh(params.pth_out,params.labelOnly,params.checkState); 39 | } catch (const std::exception &exc) { 40 | std::cout << exc.what() << std::endl; 41 | return -1; 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /App/TrainingDataGenerator/Scan2CADObjectLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Scan2CADAnnotionLoader.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Scan2CADObjectLoader { 10 | typedef pcl::PointXYZRGB PointT; 11 | public: 12 | struct Scan2CADMeshHolder{ 13 | unsigned int id, label; 14 | pcl::PolygonMeshPtr mesh; 15 | pcl::PointCloud::Ptr cloud; 16 | }; 17 | Scan2CADObjectLoader(std::string pth_scannet,std::string pth_shapenet, std::string pth_alignments); 18 | 19 | std::vector> GetMeshes(const std::string &scan_id); 20 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 21 | private: 22 | std::string msPathScanNet, msPathShapeNet, msPathAlignments; 23 | Scan2CADAnnotionLoader mScan2CadAnnotionLoader; 24 | Eigen::Matrix4d mExtrinsics; 25 | 26 | pcl::PolygonMeshPtr loadCloud(const std::string &pth_ply); 27 | }; -------------------------------------------------------------------------------- /App/TrainingDataGenerator/ScanNetMeshLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | class ScanNetMeshLoader { 7 | typedef pcl::PointXYZRGB PointT; 8 | public: 9 | struct ScanNetMeshHolder{ 10 | std::string name; 11 | pcl::PolygonMeshPtr mesh; 12 | pcl::PointCloud::Ptr cloud; 13 | }; 14 | ScanNetMeshLoader(const std::string& folder); 15 | std::shared_ptr GetMesh(int idx); 16 | size_t size(); 17 | private: 18 | std::vector msPaths; 19 | 20 | pcl::PolygonMeshPtr loadCloud(const std::string &pth_ply); 21 | }; 22 | -------------------------------------------------------------------------------- /App/TrainingDataGenerator/ScanNetScan2CAD_SceneToSkip.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | static const std::set scene_to_skip{ 6 | "scene0019_01", "scene0223_00", "scene0356_01", "scene0461_00", "scene0646_02", "scene0697_00", "scene0697_01", 7 | "scene0697_02", "scene0697_03" 8 | }; -------------------------------------------------------------------------------- /App/TrainingDataGenerator/TrainingDataGeneratorInstantiation.cu: -------------------------------------------------------------------------------- 1 | #include "TrainingDataGenerator.cu" 2 | 3 | template class SCFUSION::TrainingDataGenerator; 4 | template class SCFUSION::TrainingDataGenerator; 5 | template class SCFUSION::TrainingDataGenerator; 6 | 7 | 8 | //template class SCFUSION::TrainingDataGenerator; 9 | //template class SCFUSION::TrainingDataGenerator; 10 | //template class SCFUSION::TrainingDataGenerator; 11 | -------------------------------------------------------------------------------- /App/extractPoseFromScanNet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ### -- 3rd party 3 | #INCLUDE(${PROJECT_SOURCE_DIR}/cmake/UseCUDA.cmake) 4 | 5 | ######################################### SceneNet To Numpy ############################################ 6 | set(targetname exe_ExtractPoseFromScanNet) 7 | SET(sources 8 | main.cpp 9 | ) 10 | SET(headers) 11 | INCLUDE(UseEigen3) 12 | INCLUDE(SetAppTarget) 13 | target_link_libraries(${targetname} 14 | PRIVATE ImageLoader 15 | PRIVATE CxxTools 16 | ) 17 | set_target_properties(${targetname} PROPERTIES LINKER_LANGUAGE CXX) 18 | set_target_properties(${targetname} PROPERTIES CXX_STANDARD 14) 19 | target_compile_definitions(${targetname} PUBLIC -DCOMPILE_WITHOUT_CUDA) -------------------------------------------------------------------------------- /App/rotation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ### 2 | ## Find Module 3 | ### 4 | FIND_PACKAGE(PCL 1.8 REQUIRED) 5 | 6 | SET(targetname exe_rotate_mesh) 7 | ADD_EXECUTABLE(${targetname} rotmesh.cpp pclloader.hpp) 8 | SET_TARGET_PROPERTIES(${targetname} PROPERTIES CXX_STANDARD 11) 9 | TARGET_LINK_LIBRARIES(${targetname} 10 | PUBLIC ${PCL_LIBRARIES} 11 | PUBLIC CxxTools) 12 | TARGET_LINK_DIRECTORIES(${targetname} PUBLIC ${PCL_LIBRARY_DIRS}) 13 | TARGET_INCLUDE_DIRECTORIES(${targetname} PUBLIC ${PCL_INCLUDE_DIRS}) -------------------------------------------------------------------------------- /ConnectedComponent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(targetname ConnectedComponent) 3 | 4 | ### includes ### 5 | INCLUDE(UseCUDA) 6 | 7 | file(GLOB_RECURSE headers ConnectedComponent/*.h) 8 | file(GLOB_RECURSE templates) 9 | file(GLOB_RECURSE sources 10 | ConnectedComponent/*.c 11 | ConnectedComponent/*.cpp 12 | ConnectedComponent/*.cu 13 | ConnectedComponent/*.tpp 14 | ConnectedComponent/*.tcu 15 | ) 16 | INCLUDE(SetCUDALibTarget) 17 | target_link_libraries(${targetname} 18 | PUBLIC ORUtils 19 | PUBLIC CxxTools 20 | ) 21 | 22 | FIND_PACKAGE(GTest) 23 | IF(GTEST_INCLUDE_DIR) 24 | set(targetname TEST_CC) 25 | set(sources exe_cc.cpp) 26 | INCLUDE(SetCUDAAppTarget) 27 | target_link_libraries(${targetname} 28 | PUBLIC ConnectedComponent 29 | ) 30 | INCLUDE(LinkGTest) 31 | ENDIF(GTEST_INCLUDE_DIR) 32 | 33 | 34 | -------------------------------------------------------------------------------- /ConnectedComponent/ConnectedComponent/Interface/ConnectedComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Shared/disjointSet.h" 3 | #include 4 | #include 5 | 6 | namespace SCFUSION { 7 | class ConnectedComponent { 8 | public: 9 | explicit ConnectedComponent(size_t size, MemoryDeviceType type):type_(type){ 10 | djset.reset(new DisjointSet(size, type_)); 11 | }; 12 | 13 | virtual void process(ORUtils::Image *image, ORUtils::Image *output) = 0; 14 | // template 15 | virtual void process(bool *input, uint *output, const uint *input_dims_data, const uint *block_dims_data, uint dims) {}; 16 | protected: 17 | MemoryDeviceType type_; 18 | std::unique_ptr djset; 19 | }; 20 | } -------------------------------------------------------------------------------- /ConnectedComponent/ConnectedComponent/Shared/disjointSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | namespace SCFUSION { 5 | class DisjointSet{ 6 | public: 7 | explicit DisjointSet(int size, MemoryDeviceType type):rootNum(0), type_(type), 8 | parents(size, type_), parents_data(nullptr){ 9 | Reset(); 10 | } 11 | ~DisjointSet()= default; 12 | 13 | void Reset(){ 14 | parents.SetTo(-1); 15 | parents_data = parents.GetData(MEMORYDEVICE_CPU); 16 | } 17 | 18 | void Resize(size_t size){ 19 | if(parents.dataSize != size) 20 | parents.Resize(size,false); 21 | Reset(); 22 | } 23 | 24 | int find(int x) { 25 | if (parents_data[x] < 0) 26 | return x; 27 | else 28 | return parents_data[x] = find(parents_data[x]); 29 | } 30 | 31 | bool isEqual(int x, int y) { 32 | return find(x) == find(y); 33 | } 34 | 35 | bool unionSet(int x, int y) { 36 | x = find(x); 37 | y = find(y); 38 | if (x == y) { 39 | return false; 40 | } 41 | if (parents_data[x] > parents_data[y]) { 42 | std::swap(x, y); 43 | } 44 | parents_data[x] += parents_data[y]; 45 | parents_data[y] = x; 46 | 47 | rootNum--; 48 | 49 | return true; 50 | } 51 | 52 | int getSize(int x){ 53 | return -parents_data[find(x)]; 54 | } 55 | int getTotalSize(){ 56 | return static_cast(parents.dataSize); 57 | } 58 | 59 | int getRootNum(){ 60 | return rootNum; 61 | } 62 | 63 | const int * getParents(){return parents_data;} 64 | private: 65 | int rootNum; 66 | MemoryDeviceType type_; 67 | ORUtils::MemoryBlock parents; 68 | int *parents_data; 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /DenseCRF/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(targetname DenseCRF) 2 | 3 | OPTION(BUILD_DENSECRF_TEST "Build test of Dense Conditional Random Field" ON) 4 | 5 | 6 | file(GLOB_RECURSE srcs 7 | densecrf.cpp 8 | util.cpp) 9 | 10 | ADD_LIBRARY(${targetname} ${srcs}) 11 | SET_TARGET_PROPERTIES(${targetname} PROPERTIES 12 | CXX_STANDARD 11) 13 | 14 | 15 | IF(BUILD_DENSECRF_TEST) 16 | ADD_SUBDIRECTORY(test) 17 | ENDIF(BUILD_DENSECRF_TEST) 18 | -------------------------------------------------------------------------------- /DenseCRF/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(targetname test_denseCRF) 2 | 3 | ADD_EXECUTABLE(${targetname} test.cpp) 4 | target_link_libraries (${targetname} PUBLIC DenseCRF) 5 | set_property(TARGET ${targetname} PROPERTY CXX_STANDARD 14) 6 | set_target_properties(${targetname} PROPERTIES LINKER_LANGUAGE CXX) 7 | -------------------------------------------------------------------------------- /DenseCRF/util.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "util.h" 29 | #include 30 | 31 | float* allocate(size_t N) { 32 | float * r = NULL; 33 | if (N>0) 34 | #ifdef SSE_DENSE_CRF 35 | r = (float*)_mm_malloc( N*sizeof(float)+16, 16 ); 36 | #else 37 | r = new float[N]; 38 | #endif 39 | memset( r, 0, sizeof(float)*N); 40 | return r; 41 | } 42 | void deallocate(float*& ptr) { 43 | if (ptr) 44 | #ifdef SSE_DENSE_CRF 45 | _mm_free( ptr ); 46 | #else 47 | delete[] ptr; 48 | #endif 49 | ptr = NULL; 50 | } 51 | -------------------------------------------------------------------------------- /DenseCRF/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include "densecrf.h" 31 | #include "permutohedral.h" 32 | 33 | // Memory handling switches between SSE and new 34 | float* allocate ( size_t N ) ; 35 | void deallocate ( float *& ptr ) ; 36 | -------------------------------------------------------------------------------- /FernRelocLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################### 2 | # CMakeLists.txt for FernRelocLib # 3 | ################################### 4 | 5 | ########################### 6 | # Specify the target name # 7 | ########################### 8 | 9 | SET(targetname FernRelocLib) 10 | 11 | ################################ 12 | # Specify the libraries to use # 13 | ################################ 14 | 15 | INCLUDE(UseCUDA) 16 | INCLUDE(UseOpenMP) 17 | 18 | ############################# 19 | # Specify the project files # 20 | ############################# 21 | FILE(GLOB sources *.cpp) 22 | FILE(GLOB headers *.cpp) 23 | 24 | ############################# 25 | # Specify the source groups # 26 | ############################# 27 | 28 | SOURCE_GROUP("" FILES ${sources} ${headers}) 29 | 30 | ########################################## 31 | # Specify the target and where to put it # 32 | ########################################## 33 | 34 | INCLUDE(SetCUDALibTarget) 35 | target_link_libraries(${targetname} 36 | PUBLIC ORUtils 37 | ) 38 | target_include_directories(${targetname} PUBLIC ./include) 39 | -------------------------------------------------------------------------------- /FernRelocLib/PoseDatabase.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | using namespace FernRelocLib; 9 | 10 | PoseDatabase::PoseDatabase(void) {} 11 | PoseDatabase::~PoseDatabase(void) {} 12 | 13 | void PoseDatabase::storePose(int id, const ORUtils::SE3Pose & pose, int sceneId) 14 | { 15 | if (id < 0) return; 16 | if ((unsigned)id >= mPoses.size()) mPoses.resize(id + 1); 17 | 18 | mPoses[id] = PoseInScene(pose, sceneId); 19 | } 20 | 21 | PoseDatabase::PoseInScene PoseDatabase::retrieveWAPose(int k, int ids[], float distances[]) const 22 | { 23 | ORUtils::Matrix4 m; 24 | m.setZeros(); 25 | 26 | int sceneID = -1; 27 | float sumWeights = 0.0f; 28 | for (int i = 0; i < k; ++i) 29 | { 30 | const PoseInScene & pose = retrievePose(ids[i]); 31 | if (sceneID == -1) sceneID = pose.sceneIdx; 32 | else if (sceneID != pose.sceneIdx) continue; 33 | 34 | float weight = 1.0f - distances[i]; 35 | m += pose.pose.GetM() * weight; 36 | sumWeights += weight; 37 | } 38 | 39 | m = m * (1.0f / sumWeights); 40 | return PoseDatabase::PoseInScene(ORUtils::SE3Pose(m), sceneID); 41 | } 42 | 43 | void PoseDatabase::SaveToFile(const std::string &fileName) 44 | { 45 | std::ofstream ofs(fileName.c_str()); 46 | if (!ofs) throw std::runtime_error("Could not open " + fileName + " for reading"); 47 | 48 | size_t numPoses = mPoses.size(); 49 | ofs << numPoses << '\n'; 50 | 51 | for (size_t i = 0; i < numPoses; i++) 52 | { 53 | ofs << mPoses[i].sceneIdx << ' '; 54 | 55 | const float *params = mPoses[i].pose.GetParams(); 56 | std::copy(params, params + 6, std::ostream_iterator(ofs, " ")); 57 | 58 | ofs << '\n'; 59 | } 60 | } 61 | 62 | void PoseDatabase::LoadFromFile(const std::string &fileName) 63 | { 64 | int tot, sceneID; 65 | float tx, ty, tz, rx, ry, rz; 66 | 67 | std::ifstream ifs(fileName.c_str()); 68 | if (!ifs) throw std::runtime_error("unable to open " + fileName); 69 | 70 | ifs >> tot; 71 | for (int i = 0; i < tot; i++) 72 | { 73 | ifs >> sceneID >> tx >> ty >> tz >> rx >> ry >> rz; 74 | ORUtils::SE3Pose pose(tx, ty, tz, rx, ry, rz); 75 | storePose(i, pose, sceneID); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /FernRelocLib/include/FernRelocLib/FernConservatory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace FernRelocLib 11 | { 12 | struct FernTester 13 | { 14 | ORUtils::Vector2 location; 15 | float threshold; 16 | }; 17 | 18 | class FernConservatory 19 | { 20 | public: 21 | FernConservatory(int numFerns, ORUtils::Vector2 imgSize, ORUtils::Vector2 bounds, int decisionsPerFern = 1); 22 | ~FernConservatory(void); 23 | 24 | // takes a (small) image, applies the binary tests in the ferns, creates 25 | // the code fragments as an array 26 | void computeCode(const ORUtils::Image *img, char *codeFragments) const; 27 | void computeCode(const ORUtils::Image< ORUtils::Vector4 > *img, char *codeFragments) const; 28 | 29 | void SaveToFile(const std::string &fernsFileName); 30 | void LoadFromFile(const std::string &fernsFileName); 31 | 32 | int getNumFerns(void) const { return mNumFerns; } 33 | int getNumCodes(void) const { return 1 << mNumDecisions; } 34 | int getNumDecisions(void) const { return mNumDecisions; } 35 | 36 | private: 37 | int mNumFerns; 38 | int mNumDecisions; 39 | FernTester *mEncoders; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /FernRelocLib/include/FernRelocLib/PoseDatabase.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace FernRelocLib 10 | { 11 | class PoseDatabase 12 | { 13 | public: 14 | struct PoseInScene 15 | { 16 | PoseInScene() {} 17 | PoseInScene(const ORUtils::SE3Pose & _pose, int _sceneIdx) : pose(_pose), sceneIdx(_sceneIdx) {} 18 | ORUtils::SE3Pose pose; 19 | int sceneIdx; 20 | }; 21 | 22 | PoseDatabase(); 23 | ~PoseDatabase(); 24 | 25 | void storePose(int id, const ORUtils::SE3Pose & pose, int sceneId); 26 | int numPoses() const { return (int)mPoses.size(); } 27 | 28 | const PoseInScene & retrievePose(int id) const { return mPoses[id]; } 29 | PoseInScene retrieveWAPose(int k, int ids[], float weights[]) const; 30 | 31 | void SaveToFile(const std::string &fileName); 32 | void LoadFromFile(const std::string &fileName); 33 | 34 | private: 35 | std::vector mPoses; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /FernRelocLib/include/FernRelocLib/RelocDatabase.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | namespace FernRelocLib 9 | { 10 | class RelocDatabase 11 | { 12 | public: 13 | RelocDatabase(int codeLength, int codeFragmentDim); 14 | ~RelocDatabase(void); 15 | 16 | /** @return Number of valid similar entries that were found. Mostly 17 | relevant in case of an empty database. 18 | */ 19 | int findMostSimilar(const char *codeFragments, int nearestNeighbours[], float distances[], int k); 20 | 21 | /** @return ID of newly added entry */ 22 | int addEntry(const char *codeFragments); 23 | 24 | void SaveToFile(const std::string &framesFileName) const; 25 | void LoadFromFile(const std::string &filename); 26 | 27 | private: 28 | int mTotalEntries; 29 | 30 | int mCodeLength, mCodeFragmentDim; 31 | std::vector *mIds; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /Files/Label_NYU13.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | static std::map NYU13{ 7 | {0, "Unknown"}, 8 | {1, "Bed"}, 9 | {2, "Books"}, 10 | {3, "Ceiling"}, 11 | {4, "Chair"}, 12 | {5, "Floor"}, 13 | {6, "Furniture"}, 14 | {7, "Objects"}, 15 | {8, "Picture"}, 16 | {9, "Sofa"}, 17 | {10, "Table"}, 18 | {11, "TV"}, 19 | {12, "Wall"}, 20 | {13, "Window"}, 21 | }; 22 | 23 | static std::map, unsigned short> NYU13ColorToLabel { 24 | {ORUtils::Vector3(255,255,255),0}, 25 | {ORUtils::Vector3(0,0,255),1}, 26 | {ORUtils::Vector3(232,88,47),2}, 27 | {ORUtils::Vector3(0,217,0),3}, 28 | {ORUtils::Vector3(148,0,240),4}, 29 | {ORUtils::Vector3(222,241,23),5}, 30 | {ORUtils::Vector3(255,205,205),6}, 31 | {ORUtils::Vector3(0,223,228),7}, 32 | {ORUtils::Vector3(106,135,204),8}, 33 | {ORUtils::Vector3(116,28,1),9}, 34 | {ORUtils::Vector3(240,35,235),10}, 35 | {ORUtils::Vector3(0,166,156),11}, 36 | {ORUtils::Vector3(249,139,0),12}, 37 | {ORUtils::Vector3(225,228,194),13}, 38 | }; 39 | 40 | 41 | static std::map> NYU13ColorLabel { 42 | {0, ORUtils::Vector4(0.0, 0.0, 0.0, 255)}, 43 | {1, ORUtils::Vector4(0.0, 0.0, 1.0, 255)}, 44 | {2, ORUtils::Vector4(0.9137, 0.349, 0.1882, 255)}, 45 | {3, ORUtils::Vector4(0.0, 0.8549, 0.0, 255)}, 46 | {4, ORUtils::Vector4(0.5843, 0.0, 0.9412, 255)}, 47 | {5, ORUtils::Vector4(0.8706, 0.9451, 0.0941, 255)}, 48 | {6, ORUtils::Vector4(1.0, 0.8078, 0.8078, 255)}, 49 | {7, ORUtils::Vector4(0.0, 0.8784, 0.898, 255)}, 50 | {8, ORUtils::Vector4(0.4157, 0.5333, 0.8, 255)}, 51 | {9, ORUtils::Vector4(0.4588, 0.1137, 0.1608, 255)}, 52 | {10, ORUtils::Vector4(0.9412, 0.1373, 0.9216, 255)}, 53 | {11, ORUtils::Vector4(0.0, 0.6549, 0.6118, 255)}, 54 | {12, ORUtils::Vector4(0.9765, 0.5451, 0.0, 255)}, 55 | {13, ORUtils::Vector4(0.8824, 0.898, 0.7608, 255)}, 56 | }; 57 | -------------------------------------------------------------------------------- /ImageLoader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) 2 | 3 | UNSET(COMPILE_WITH_CUDA) 4 | ############################################################################### 5 | ### -- 3rd party 6 | INCLUDE(UseCUDA) 7 | INCLUDE(UseOpenCV) 8 | INCLUDE(UseEigen3) 9 | 10 | ########################################################################################### 11 | SET(targetname ImageLoader) 12 | file(GLOB_RECURSE srcs *.cpp) 13 | file(GLOB_RECURSE headers *.h *.hpp) 14 | SET(sources 15 | ${srcs} 16 | ) 17 | 18 | SET(headers 19 | ${headers} 20 | ) 21 | 22 | INCLUDE(SetCUDALibTarget) 23 | target_link_libraries(${targetname} 24 | # PUBLIC CxxTools 25 | PUBLIC ${OpenCV_LIBS} 26 | ) 27 | INCLUDE(LinkOpenCV) 28 | INCLUDE(LinkEigen3) 29 | target_include_directories(${targetname} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) 30 | set_target_properties(${targetname} PROPERTIES LINKER_LANGUAGE CXX) 31 | set_target_properties(${targetname} PROPERTIES CXX_STANDARD 11) 32 | target_include_directories(${targetname} PUBLIC ./include) 33 | -------------------------------------------------------------------------------- /ImageLoader/CPU/RIO.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //#include "../../ORUtils/Image.h" 3 | //#include "../../ORUtils/Matrix.h" 4 | #include 5 | #include 6 | #include <../include/ImageLoader/ImageLoader.hpp> 7 | 8 | namespace SCFUSION { 9 | namespace IO{ 10 | class RIOReader : public ImageLoader { 11 | public: 12 | RIOReader(const std::string &folder); 13 | 14 | int Init() override; 15 | 16 | int Next() override; 17 | 18 | int NumberOfImages() override; 19 | 20 | int getDepth(ORUtils::Image *depthptr) override; 21 | 22 | int getColor(ORUtils::Image> *colorptr) override; 23 | 24 | int getDepth(ORUtils::Image *depthptr) override {return -1;}; 25 | 26 | int getColor(ORUtils::Image> *colorptr) override ; 27 | 28 | int getPose(ORUtils::Matrix4 *pose) override; 29 | 30 | int getLabel(ORUtils::Image *labelptr) override{return -1;} 31 | 32 | int getDepth(int idx, ORUtils::Image *depthptr) override ; 33 | int getColor(int idx, ORUtils::Image> *colorptr) override ; 34 | int getColor(int idx, ORUtils::Image> *colorptr) override ; 35 | int getLabel(int idx, ORUtils::Image *labelptr) override {return -1;} 36 | int getPose(int idx, ORUtils::Matrix4 *pose) override ; 37 | private: 38 | std::string folder; 39 | std::vector cam_extrinsics; 40 | std::vector depth_images; 41 | std::vector color_images; 42 | size_t img_counter, img_max_counter; 43 | std::string path_K_, path_extrin_, path_depth_imgs_, path_color_imgs_; 44 | cv::Mat color_mat, depth_mat; 45 | }; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ImageLoader/CPU/ScanNet.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../include/ImageLoader/ImageLoader.hpp" 3 | #include "ScanNet/sensorData.h" 4 | #include 5 | #include 6 | //#include "../../ORUtils/Image.h" 7 | //#include "../../ORUtils/Matrix.h" 8 | 9 | namespace SCFUSION { 10 | namespace IO{ 11 | class ScanNet : public ImageLoader { 12 | public: 13 | ScanNet(const std::string &path_to_sens); 14 | 15 | ~ScanNet() override; 16 | 17 | int Init() override; 18 | 19 | int Next() override; 20 | 21 | int NumberOfImages() override; 22 | 23 | int getDepth(ORUtils::Image *depthptr) override; 24 | 25 | int getColor(ORUtils::Image> *colorptr) override; 26 | 27 | int getDepth(ORUtils::Image *depthptr) override {return -1;}; 28 | 29 | int getColor(ORUtils::Image> *colorptr) override; 30 | 31 | int getPose(ORUtils::Matrix4 *pose) override; 32 | 33 | int getLabel(ORUtils::Image *labelptr) override; 34 | 35 | 36 | int getDepth(int idx, ORUtils::Image *depthptr) override ; 37 | int getColor(int idx, ORUtils::Image> *colorptr) override ; 38 | int getColor(int idx, ORUtils::Image> *colorptr) override ; 39 | int getLabel(int idx, ORUtils::Image *labelptr) override ; 40 | int getPose(int idx, ORUtils::Matrix4 *pose) override ; 41 | private: 42 | std::string main_path; 43 | ::ml::SensorData *loader; 44 | std::string path; 45 | size_t img_counter, img_max_counter; 46 | cv::Mat label_mat; 47 | }; 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ImageLoader/CPU/ScanNetPose.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../include/ImageLoader/ImageLoader.hpp" 3 | #include "ScanNet/sensorData.h" 4 | #include 5 | #include 6 | //#include "../../ORUtils/Image.h" 7 | //#include "../../ORUtils/Matrix.h" 8 | //#include 9 | //#include 10 | 11 | namespace SCFUSION { 12 | namespace IO{ 13 | class ScanNetPose : public ImageLoader { 14 | public: 15 | ScanNetPose(const std::string &path_to_sens); 16 | 17 | ~ScanNetPose() override; 18 | 19 | int Init() override; 20 | 21 | int Next() override; 22 | 23 | int NumberOfImages() override; 24 | 25 | int getDepth(ORUtils::Image *depthptr) override { return 1; }; 26 | 27 | int getColor(ORUtils::Image> *colorptr) { return 1; }; 28 | 29 | int getDepth(ORUtils::Image *depthptr) override {return -1;}; 30 | 31 | int getColor(ORUtils::Image> *colorptr) { return 1; }; 32 | 33 | int getPose(ORUtils::Matrix4 *pose) override; 34 | 35 | int getLabel(ORUtils::Image *labelptr) { return 1; }; 36 | 37 | 38 | int getDepth(int idx, ORUtils::Image *depthptr) { return 1; }; 39 | int getColor(int idx, ORUtils::Image> *colorptr) { return 1; }; 40 | int getColor(int idx, ORUtils::Image> *colorptr) { return 1; }; 41 | int getLabel(int idx, ORUtils::Image *labelptr) { return 1; }; 42 | int getPose(int idx, ORUtils::Matrix4 *pose) override ; 43 | private: 44 | std::string main_path; 45 | std::string path; 46 | size_t img_counter, img_max_counter; 47 | std::vector> mvPoses; 48 | }; 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ImageLoader/CPU/util.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by sc on 11/25/20. 3 | // 4 | 5 | #ifndef SCSLAM_PROEJCT_UTIL_H 6 | #define SCSLAM_PROEJCT_UTIL_H 7 | #include 8 | #include 9 | #include 10 | namespace SCFUSION { 11 | inline std::vector LoadMatrixFromFile(const std::string &filename, int M, int N) { 12 | std::vector matrix; 13 | std::fstream fp(filename, std::ios::in); 14 | if (!fp) 15 | throw std::runtime_error("LoadMatrixFromFile::Cannot open file for reading.\n"); 16 | 17 | float tmp; 18 | while (fp >> tmp) { 19 | matrix.push_back(tmp); 20 | } 21 | fp.close(); 22 | if (matrix.size() == 4) { 23 | std::vector tmp; 24 | tmp.push_back(matrix[0]); 25 | tmp.push_back(0); 26 | tmp.push_back(matrix[2]); 27 | tmp.push_back(0); 28 | tmp.push_back(matrix[1]); 29 | tmp.push_back(matrix[3]); 30 | tmp.push_back(0); 31 | tmp.push_back(0); 32 | tmp.push_back(1); 33 | matrix.swap(tmp); 34 | } else if (matrix.size() < (size_t) M * N) { 35 | printf("Input format was not %d*%d matrix. matrix.size() = %zu\n", M, N, matrix.size()); 36 | // The file is in different format. 37 | if (matrix.size() == 6 && M * N == 9) { 38 | std::vector tmp; 39 | tmp.push_back(matrix[2]); 40 | tmp.push_back(0); 41 | tmp.push_back(matrix[4]); 42 | tmp.push_back(0); 43 | tmp.push_back(matrix[3]); 44 | tmp.push_back(matrix[5]); 45 | tmp.push_back(0); 46 | tmp.push_back(0); 47 | tmp.push_back(1); 48 | matrix.swap(tmp); 49 | } else 50 | throw std::runtime_error("Input format doesn't support!.\n"); 51 | 52 | } 53 | 54 | return matrix; 55 | } 56 | } 57 | #endif //SCSLAM_PROEJCT_UTIL_H 58 | -------------------------------------------------------------------------------- /ImageLoader/include/ImageLoader/ImageLoadFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //#include "../../../ORUtils/Logging.h" 3 | #include 4 | #include "../../CPU/ScanNetPose.hpp" 5 | 6 | #ifdef COMPILE_WITH_OPENCV 7 | #include "../../CPU/ScanNet.hpp" 8 | #include "../../CPU/RIO.hpp" 9 | #endif 10 | 11 | namespace SCFUSION { 12 | 13 | struct ImageLoaderFactory { 14 | static SCFUSION::IO::ImageLoader * MakeImageLoader(SCFUSION::IO::InputDateType::INPUTDATATYPE inputdatatype, const std::string &folder = "", const std::string &cam_K = "", 15 | const std::string > = "", const std::string &depthFolderName = "", const std::string &colorFolderName = "") { 16 | SCFUSION::IO::ImageLoader *imageLoader = nullptr; 17 | switch (inputdatatype) { 18 | case SCFUSION::IO::InputDateType::INPUTTYPE_SCANNET: { 19 | imageLoader = (new SCFUSION::IO::ScanNet(folder)); 20 | } 21 | break; 22 | case SCFUSION::IO::InputDateType::INPUTTYPE_RIO: { 23 | #ifdef WITH_OPENCV 24 | imageLoader = new SCFUSION::IO::RIOReader(folder ); 25 | break; 26 | #else 27 | throw std::runtime_error("INPUTTYPE_RIO Require OpenCV\n"); 28 | #endif 29 | } 30 | case SCFUSION::IO::InputDateType::INPUTTYPE_SCANNET_POSE: { 31 | imageLoader = (new SCFUSION::IO::ScanNetPose(folder)); 32 | } 33 | break; 34 | } 35 | return imageLoader; 36 | } 37 | }; 38 | 39 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2020, ShunChengWu 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /MainLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ### -- 3rd party 3 | INCLUDE(UseCUDA) 4 | 5 | ################# 6 | # Utils LIBRARY # 7 | ################# 8 | set(targetname ITMUtils) 9 | file(GLOB_RECURSE headers Utils/*.h) 10 | file(GLOB_RECURSE sources Utils/*.cpp) 11 | INCLUDE(SetLibTarget) 12 | TARGET_INCLUDE_DIRECTORIES(${targetname} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 13 | list(APPEND SOURCES ${${targetname}_sources}) 14 | list(APPEND HEADERS ${${targetname}_headers}) 15 | 16 | ################### 17 | # Objects LIBRARY # 18 | ################### 19 | set(targetname ITMObjects) 20 | file(GLOB_RECURSE headers Objects/*.h) 21 | file(GLOB_RECURSE sources Objects/*.cpp Objects/*.tcu Objects/*.cu) 22 | INCLUDE(SetLibTarget) 23 | TARGET_INCLUDE_DIRECTORIES(${targetname} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 24 | list(APPEND SOURCES ${${targetname}_sources}) 25 | list(APPEND HEADERS ${${targetname}_headers}) 26 | 27 | ADD_SUBDIRECTORY(Trackers) 28 | ADD_SUBDIRECTORY(Engines) 29 | ADD_SUBDIRECTORY(Core) 30 | ADD_SUBDIRECTORY(MainEngine) -------------------------------------------------------------------------------- /MainLib/CPUInstantiations_SC.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "ITMLibDefines.h" 3 | #include "Core/SceneCompletion.tpp" 4 | 5 | //Core 6 | template class SCSLAM::SceneCompletion; -------------------------------------------------------------------------------- /MainLib/CUDAInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "ITMLibDefines.h" 3 | #include "Engines/Meshing/CUDA/ITMMeshingEngine_CUDA.tcu" 4 | #include "Engines/PointExtraction/CUDA/PointCloudExtractionEngine_CUDA.tcu" 5 | #include "Engines/Reconstruction/CUDA/ITMSceneReconstructionEngine_CUDA.tcu" 6 | #include "Engines/Reconstruction/CUDA/ITMSurfelSceneReconstructionEngine_CUDA.tcu" 7 | #include "Engines/Swapping/CUDA/ITMSwappingEngine_CUDA.tcu" 8 | #include "Engines/Visualisation/CUDA/ITMSurfelVisualisationEngine_CUDA.tcu" 9 | #include "Engines/Visualisation/CUDA/ITMVisualisationEngine_CUDA.tcu" 10 | #include "Objects/Scene/UnitMapSaver/CUDA/UnitMapSaver_CUDA.tcu" 11 | 12 | 13 | // Engines 14 | template class ITMLib::ITMMeshingEngine_CUDA; 15 | template class SCSLAM::PointCloudExtractionEngine_CUDA; 16 | template class ITMLib::ITMSceneReconstructionEngine_CUDA; 17 | template class ITMLib::ITMSurfelSceneReconstructionEngine_CUDA; 18 | template class ITMLib::ITMSurfelSceneReconstructionEngine_CUDA; 19 | template class ITMLib::ITMSwappingEngine_CUDA; 20 | template class ITMLib::ITMVisualisationEngine_CUDA; 21 | template class ITMLib::ITMSurfelVisualisationEngine_CUDA; 22 | template class ITMLib::ITMSurfelVisualisationEngine_CUDA; 23 | template class SCSLAM::UnitMapSave_CUDA; 24 | -------------------------------------------------------------------------------- /MainLib/CUDAInstantiations_SC.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "ITMLibDefines.h" 3 | #include "Engines/SceneCompletion/CUDA/SceneCompletionEngine_CUDA.tcu" 4 | 5 | // Engines 6 | template class SCSLAM::SceneCompletionEngine_CUDA; 7 | -------------------------------------------------------------------------------- /MainLib/Core/BasicSLAM/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##################### 2 | # BasicSLAM LIBRARY # 3 | ##################### 4 | set(targetname BasicSLAM) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${VOXELCOUNTS} ) 15 | LIST(GET VOXELNAMES ${i} name) 16 | LIST(GET VOXELTYPES ${i} type) 17 | SET(FIELD_TYPE VOXELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 20 | ADD_LIBRARY(${targetname_suffix} ${${targetname}_sources} ${${targetname}_headers}) 21 | TARGET_LINK_LIBRARIES(${targetname_suffix} 22 | PUBLIC FernRelocLib 23 | PUBLIC CxxTools 24 | PUBLIC LowLevelEngine 25 | PUBLIC ViewBuildingEngine 26 | PUBLIC TrackingEngine 27 | PUBLIC DenseMapper${NAME_SUFFIX} 28 | PUBLIC VisualizationEngine${NAME_SUFFIX} 29 | ) 30 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 31 | ENDFOREACH() -------------------------------------------------------------------------------- /MainLib/Core/BasicSLAM/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "MainEngine.tpp" 4 | 5 | // Engines 6 | template class SCFUSION::MainEngine; -------------------------------------------------------------------------------- /MainLib/Core/BasicSurfel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##################### 2 | # BasicSLAM LIBRARY # 3 | ##################### 4 | set(targetname BasicSurfelEngine) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${SURFELCOUNTS} ) 15 | LIST(GET SURFELNAMES ${i} name) 16 | LIST(GET SURFELTYPES ${i} type) 17 | SET(FIELD_TYPE SURFELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 20 | 21 | ADD_LIBRARY(${targetname_suffix} 22 | ${${targetname}_sources} 23 | ${${targetname}_headers} 24 | ) 25 | TARGET_LINK_LIBRARIES(${targetname_suffix} 26 | PUBLIC FernRelocLib 27 | PUBLIC LowLevelEngine 28 | PUBLIC ViewBuildingEngine 29 | PUBLIC TrackingEngine 30 | PUBLIC SurfelDenseMapper${NAME_SUFFIX} 31 | ) 32 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC SURFELTYPE=${type}) 33 | ENDFOREACH() -------------------------------------------------------------------------------- /MainLib/Core/BasicSurfel/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "ITMBasicSurfelEngine.tpp" 4 | 5 | // Engines 6 | template class ITMLib::ITMBasicSurfelEngine; -------------------------------------------------------------------------------- /MainLib/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(BasicSLAM) 2 | ADD_SUBDIRECTORY(DenseMapper) 3 | ADD_SUBDIRECTORY(SceneCompletion) 4 | IF(SURFELCOUNTS) 5 | ADD_SUBDIRECTORY(BasicSurfel) 6 | ADD_SUBDIRECTORY(DenseSurfelMapper) 7 | ENDIF(SURFELCOUNTS) -------------------------------------------------------------------------------- /MainLib/Core/DenseMapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ####################### 2 | # DenseMapper LIBRARY # 3 | ####################### 4 | set(targetname DenseMapper) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${VOXELCOUNTS} ) 15 | LIST(GET VOXELNAMES ${i} name) 16 | LIST(GET VOXELTYPES ${i} type) 17 | SET(FIELD_TYPE VOXELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 20 | ADD_LIBRARY(${targetname_suffix} 21 | ${${targetname}_sources} 22 | ${${targetname}_headers} 23 | ) 24 | TARGET_LINK_LIBRARIES(${targetname_suffix} 25 | PUBLIC ReconstructionEngine${NAME_SUFFIX} 26 | PUBLIC SwappingEngine${NAME_SUFFIX} 27 | ) 28 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 29 | ENDFOREACH() -------------------------------------------------------------------------------- /MainLib/Core/DenseMapper/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "ITMDenseMapper.tpp" 4 | template class ITMLib::ITMDenseMapper; -------------------------------------------------------------------------------- /MainLib/Core/DenseMapper/ITMDenseMapper.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../Engines/Reconstruction/Interface/ITMSceneReconstructionEngine.h" 6 | #include "../../Engines/Swapping/Interface/ITMSwappingEngine.h" 7 | #include "../../Utils/ITMLibSettings.h" 8 | 9 | namespace ITMLib 10 | { 11 | /** \brief 12 | */ 13 | template 14 | class ITMDenseMapper 15 | { 16 | protected: 17 | ITMSceneReconstructionEngine *sceneRecoEngine; 18 | ITMSwappingEngine *swappingEngine; 19 | 20 | ITMLibSettings::SwappingMode swappingMode; 21 | 22 | public: 23 | void setStream(void *stream) { 24 | sceneRecoEngine->setStream(stream); 25 | // add swapping engine here if needed 26 | } 27 | void syncStream() { 28 | sceneRecoEngine->syncStream(); 29 | }; 30 | 31 | void ResetScene(ITMScene *scene) const; 32 | 33 | /// Process a single frame 34 | void ProcessFrame(const ITMView *view, const ITMTrackingState *trackingState, ITMScene *scene, ITMRenderState *renderState_live, bool resetVisibleList = false); 35 | 36 | /// Update the visible list (this can be called to update the visible list when fusion is turned off) 37 | void UpdateVisibleList(const ITMView *view, const ITMTrackingState *trackingState, ITMScene *scene, ITMRenderState *renderState, bool resetVisibleList = false); 38 | 39 | /// Performa integration of local memory and active memory. 40 | void UpdateVisibleVolume(ITMScene *scene, ITMRenderState *renderState); 41 | 42 | ITMSceneReconstructionEngine* getSceneRecoEngine(){ return sceneRecoEngine; } 43 | 44 | /** \brief Constructor 45 | Ommitting a separate image size for the depth images 46 | will assume same resolution as for the RGB images. 47 | */ 48 | explicit ITMDenseMapper(const ITMLibSettings *settings); 49 | ~ITMDenseMapper(); 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /MainLib/Core/DenseSurfelMapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ####################### 2 | # DenseMapper LIBRARY # 3 | ####################### 4 | set(targetname SurfelDenseMapper) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | FOREACH(i RANGE ${SURFELCOUNTS} ) 14 | LIST(GET SURFELNAMES ${i} name) 15 | LIST(GET SURFELTYPES ${i} type) 16 | SET(FIELD_TYPE SURFELTYPE=${type}) 17 | SET(NAME_SUFFIX _${name}) 18 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 19 | 20 | ADD_LIBRARY(${targetname_suffix} 21 | ${${targetname}_sources} 22 | ${${targetname}_headers} 23 | ) 24 | TARGET_LINK_LIBRARIES(${targetname_suffix} 25 | PUBLIC SurfelReconstructionEngine${NAME_SUFFIX} 26 | PUBLIC SurfelVisualizationEngine${NAME_SUFFIX} 27 | ) 28 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC SURFELTYPE=${type}) 29 | ENDFOREACH() -------------------------------------------------------------------------------- /MainLib/Core/DenseSurfelMapper/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "ITMDenseSurfelMapper.tpp" 4 | template class ITMLib::ITMDenseSurfelMapper; -------------------------------------------------------------------------------- /MainLib/Core/DenseSurfelMapper/ITMDenseSurfelMapper.tpp: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #include "ITMDenseSurfelMapper.h" 4 | 5 | #include "../../Engines/Reconstruction/ITMSurfelSceneReconstructionEngineFactory.h" 6 | 7 | namespace ITMLib 8 | { 9 | 10 | //#################### CONSTRUCTORS #################### 11 | 12 | template 13 | ITMDenseSurfelMapper::ITMDenseSurfelMapper(const Vector2i& depthImageSize, ITMLibSettings::DeviceType deviceType) 14 | : m_reconstructionEngine(ITMSurfelSceneReconstructionEngineFactory::make_surfel_scene_reconstruction_engine(depthImageSize, deviceType)) 15 | {} 16 | 17 | //#################### DESTRUCTOR #################### 18 | 19 | template 20 | ITMDenseSurfelMapper::~ITMDenseSurfelMapper() 21 | { 22 | delete m_reconstructionEngine; 23 | } 24 | 25 | //#################### PUBLIC MEMBER FUNCTIONS #################### 26 | 27 | template 28 | void ITMDenseSurfelMapper::ProcessFrame(const ITMView *view, const ITMTrackingState *trackingState, ITMSurfelScene *scene, ITMSurfelRenderState *liveRenderState) const 29 | { 30 | m_reconstructionEngine->IntegrateIntoScene(scene, view, trackingState, liveRenderState); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /MainLib/Core/SceneCompletion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ########################### 2 | # SceneCompletion LIBRARY # 3 | ########################### 4 | set(targetname SceneCompletion) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${VOXELCOUNTS} ) 15 | LIST(GET VOXELNAMES ${i} name) 16 | LIST(GET VOXELTYPES ${i} type) 17 | SET(FIELD_TYPE VOXELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 20 | ADD_LIBRARY(${targetname_suffix} ${${targetname}_sources} ${${targetname}_headers}) 21 | TARGET_LINK_LIBRARIES(${targetname_suffix} 22 | PUBLIC SceneCompletionEngine${NAME_SUFFIX} 23 | PUBLIC ReconstructionEngine${NAME_SUFFIX} 24 | PUBLIC DenseCRF 25 | ) 26 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 27 | SET_TARGET_PROPERTIES(${targetname_suffix} PROPERTIES CXX_STANDARD 14) 28 | ENDFOREACH() -------------------------------------------------------------------------------- /MainLib/Core/SceneCompletion/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "SceneCompletion.tpp" 4 | 5 | //Core 6 | template class SCFUSION::SceneCompletion; -------------------------------------------------------------------------------- /MainLib/Engines/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(Meshing) 2 | ADD_SUBDIRECTORY(PointExtraction) 3 | ADD_SUBDIRECTORY(LowLevel) 4 | ADD_SUBDIRECTORY(Reconstruction) 5 | ADD_SUBDIRECTORY(SceneCompletion) 6 | #ADD_SUBDIRECTORY(Segmentation) 7 | ADD_SUBDIRECTORY(Swapping) 8 | ADD_SUBDIRECTORY(ViewBuilding) 9 | ADD_SUBDIRECTORY(Visualisation) -------------------------------------------------------------------------------- /MainLib/Engines/LowLevel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ########################## 2 | # LowLevelEngine LIBRARY # 3 | ########################## 4 | set(targetname LowLevelEngine) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | ADD_LIBRARY(${targetname} OBJECT ${${targetname}_sources} ${${targetname}_headers}) -------------------------------------------------------------------------------- /MainLib/Engines/LowLevel/CPU/ITMLowLevelEngine_CPU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMLowLevelEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMLowLevelEngine_CPU : public ITMLowLevelEngine 10 | { 11 | public: 12 | void CopyImage(ITMUChar4Image *image_out, const ITMUChar4Image *image_in) const; 13 | void CopyImage(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 14 | void CopyImage(ITMFloat4Image *image_out, const ITMFloat4Image *image_in) const; 15 | 16 | void ConvertColourToIntensity(ITMFloatImage *image_out, const ITMUChar4Image *image_in) const; 17 | 18 | void FilterIntensity(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 19 | 20 | void FilterSubsample(ITMUChar4Image *image_out, const ITMUChar4Image *image_in) const; 21 | void FilterSubsample(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 22 | void FilterSubsampleWithHoles(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 23 | void FilterSubsampleWithHoles(ITMFloat4Image *image_out, const ITMFloat4Image *image_in) const; 24 | 25 | void BilateralFilter5x5(ITMFloatImage *img, float depthUncertaintyCoef) const; 26 | 27 | void GradientX(ITMShort4Image *grad_out, const ITMUChar4Image *image_in) const; 28 | void GradientY(ITMShort4Image *grad_out, const ITMUChar4Image *image_in) const; 29 | void GradientXY(ITMFloat2Image *grad_out, const ITMFloatImage *image_in) const; 30 | 31 | int CountValidDepths(const ITMFloatImage *image_in) const; 32 | 33 | ITMLowLevelEngine_CPU(void); 34 | ~ITMLowLevelEngine_CPU(void); 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /MainLib/Engines/LowLevel/CUDA/ITMLowLevelEngine_CUDA.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMLowLevelEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMLowLevelEngine_CUDA : public ITMLowLevelEngine 10 | { 11 | private: 12 | int *counterTempData_device, *counterTempData_host; 13 | 14 | public: 15 | void CopyImage(ITMUChar4Image *image_out, const ITMUChar4Image *image_in) const; 16 | void CopyImage(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 17 | void CopyImage(ITMFloat4Image *image_out, const ITMFloat4Image *image_in) const; 18 | 19 | void ConvertColourToIntensity(ITMFloatImage *image_out, const ITMUChar4Image *image_in) const; 20 | 21 | void FilterIntensity(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 22 | 23 | void FilterSubsample(ITMUChar4Image *image_out, const ITMUChar4Image *image_in) const; 24 | void FilterSubsample(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 25 | void FilterSubsampleWithHoles(ITMFloatImage *image_out, const ITMFloatImage *image_in) const; 26 | void FilterSubsampleWithHoles(ITMFloat4Image *image_out, const ITMFloat4Image *image_in) const; 27 | 28 | void BilateralFilter5x5(ITMFloatImage *img, float depthUncertaintyCoef) const; 29 | 30 | void GradientX(ITMShort4Image *grad_out, const ITMUChar4Image *image_in) const; 31 | void GradientY(ITMShort4Image *grad_out, const ITMUChar4Image *image_in) const; 32 | void GradientXY(ITMFloat2Image *grad_out, const ITMFloatImage *image_in) const; 33 | 34 | int CountValidDepths(const ITMFloatImage *image_in) const; 35 | 36 | ITMLowLevelEngine_CUDA(void); 37 | ~ITMLowLevelEngine_CUDA(void); 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /MainLib/Engines/LowLevel/ITMLowLevelEngineFactory.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #include "ITMLowLevelEngineFactory.h" 4 | 5 | #include "CPU/ITMLowLevelEngine_CPU.h" 6 | #ifndef COMPILE_WITHOUT_CUDA 7 | #include "CUDA/ITMLowLevelEngine_CUDA.h" 8 | #endif 9 | 10 | namespace ITMLib 11 | { 12 | 13 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 14 | 15 | ITMLowLevelEngine *ITMLowLevelEngineFactory::MakeLowLevelEngine(ITMLibSettings::DeviceType deviceType) 16 | { 17 | ITMLowLevelEngine *lowLevelEngine = NULL; 18 | 19 | switch(deviceType) 20 | { 21 | case ITMLibSettings::DEVICE_CPU: 22 | lowLevelEngine = new ITMLowLevelEngine_CPU(); 23 | break; 24 | case ITMLibSettings::DEVICE_CUDA: 25 | #ifndef COMPILE_WITHOUT_CUDA 26 | lowLevelEngine = new ITMLowLevelEngine_CUDA(); 27 | #endif 28 | break; 29 | case ITMLibSettings::DEVICE_METAL: 30 | #ifdef COMPILE_WITH_METAL 31 | lowLevelEngine = new ITMLowLevelEngine_CPU(); 32 | #endif 33 | break; 34 | } 35 | 36 | return lowLevelEngine; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /MainLib/Engines/LowLevel/ITMLowLevelEngineFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "Interface/ITMLowLevelEngine.h" 6 | #include "../../Utils/ITMLibSettings.h" 7 | 8 | namespace ITMLib { 9 | 10 | /** 11 | * \brief This struct provides functions that can be used to construct low-level engines. 12 | */ 13 | struct ITMLowLevelEngineFactory { 14 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 15 | 16 | /** 17 | * \brief Makes a low-level engine. 18 | * 19 | * \param deviceType The device on which the low-level engine should operate. 20 | */ 21 | static ITMLowLevelEngine *MakeLowLevelEngine(ITMLibSettings::DeviceType deviceType); 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /MainLib/Engines/LowLevel/Interface/ITMLowLevelEngine.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../../Utils/ITMImageTypes.h" 6 | 7 | namespace ITMLib 8 | { 9 | /// Interface to low level image processing engines. 10 | class ITMLowLevelEngine 11 | { 12 | public: 13 | virtual void CopyImage(ITMUChar4Image *image_out, const ITMUChar4Image *image_in) const = 0; 14 | virtual void CopyImage(ITMFloatImage *image_out, const ITMFloatImage *image_in) const = 0; 15 | virtual void CopyImage(ITMFloat4Image *image_out, const ITMFloat4Image *image_in) const = 0; 16 | 17 | virtual void ConvertColourToIntensity(ITMFloatImage *image_out, const ITMUChar4Image *image_in) const = 0; 18 | 19 | virtual void FilterIntensity(ITMFloatImage *image_out, const ITMFloatImage *image_in) const = 0; 20 | 21 | virtual void FilterSubsample(ITMUChar4Image *image_out, const ITMUChar4Image *image_in) const = 0; 22 | virtual void FilterSubsample(ITMFloatImage *image_out, const ITMFloatImage *image_in) const = 0; 23 | virtual void FilterSubsampleWithHoles(ITMFloatImage *image_out, const ITMFloatImage *image_in) const = 0; 24 | virtual void FilterSubsampleWithHoles(ITMFloat4Image *image_out, const ITMFloat4Image *image_in) const = 0; 25 | 26 | virtual void BilateralFilter5x5(ITMFloatImage *img, float depthUncertaintyCoef) const = 0; 27 | 28 | virtual void GradientX(ITMShort4Image *grad_out, const ITMUChar4Image *image_in) const = 0; 29 | virtual void GradientY(ITMShort4Image *grad_out, const ITMUChar4Image *image_in) const = 0; 30 | virtual void GradientXY(ITMFloat2Image *grad_out, const ITMFloatImage *image_in) const = 0; 31 | 32 | virtual int CountValidDepths(const ITMFloatImage *image_in) const = 0; 33 | 34 | ITMLowLevelEngine(void) { } 35 | virtual ~ITMLowLevelEngine(void) { } 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ######################### 2 | # Meshing LIBRARY # 3 | ######################### 4 | set(targetname MeshingEngine) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${VOXELCOUNTS} ) 15 | LIST(GET VOXELNAMES ${i} name) 16 | LIST(GET VOXELTYPES ${i} type) 17 | SET(FIELD_TYPE VOXELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 20 | message("targetname_suffix " ${targetname_suffix} ) 21 | 22 | ADD_LIBRARY(${targetname_suffix} OBJECT ${${targetname}_sources} ${${targetname}_headers}) 23 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 24 | ENDFOREACH() 25 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CPU/ITMMeshingEngine_CPU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAMsetStream 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMMeshingEngine.h" 6 | #include "../../../Objects/Scene/ITMPlainVoxelArray.h" 7 | 8 | namespace ITMLib 9 | { 10 | template 11 | class ITMMeshingEngine_CPU : public ITMMeshingEngine < TVoxel, TIndex > 12 | { 13 | public: 14 | using ITMMeshingEngine::isoValue_; 15 | void MeshScene(ITMMesh *mesh, const ITMScene *scene, bool checkVoxelState) { } 16 | void MeshSceneLabel(ITMMesh *mesh, const ITMScene *scene, bool checkVoxelState) {} 17 | void MeshScene(ITMMesh *mesh, const ORUtils::MemoryBlock *localVBA, const Vector3f &origin, const Vector3s &dims, float voxelSize){} 18 | void setStream(void *stream){}; 19 | void syncStream() {}; 20 | void reset() override {}; 21 | explicit ITMMeshingEngine_CPU(const float &isovalue=0.f):ITMMeshingEngine(isovalue) { } 22 | ~ITMMeshingEngine_CPU() = default; 23 | }; 24 | 25 | template 26 | class ITMMeshingEngine_CPU : public ITMMeshingEngine < TVoxel, ITMVoxelBlockHash > 27 | { 28 | public: 29 | using ITMMeshingEngine::isoValue_; 30 | void MeshScene(ITMMesh *mesh, const ITMScene *scene, bool checkVoxelState); 31 | void MeshSceneLabel(ITMMesh *mesh, const ITMScene *scene, bool checkVoxelState) {} 32 | void MeshScene(ITMMesh *mesh, const ORUtils::MemoryBlock *localVBA, const Vector3f &origin, const Vector3s &dims, float voxelSize){} 33 | void setStream(void *stream){}; 34 | void syncStream() {}; 35 | void reset() override {}; 36 | explicit ITMMeshingEngine_CPU(const float &isovalue=0.f):ITMMeshingEngine(isovalue) { } 37 | ~ITMMeshingEngine_CPU() = default; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CPU/ITMMeshingEngine_CPU.tpp" 4 | #include "MeshEngine.tpp" 5 | // Engines 6 | template class ITMLib::ITMMeshingEngine_CPU; 7 | template class SCFUSION::MeshEngine; 8 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CUDA/mattdean1/kernels.h: -------------------------------------------------------------------------------- 1 | 2 | __global__ void prescan_arbitrary(int *g_odata, int *g_idata, int n, int powerOfTwo); 3 | __global__ void prescan_arbitrary_unoptimized(int *g_odata, int *g_idata, int n, int powerOfTwo); 4 | 5 | __global__ void prescan_large(int *g_odata, int *g_idata, int n, int* sums); 6 | __global__ void prescan_large_unoptimized(int *output, int *input, int n, int *sums); 7 | 8 | __global__ void add(int *output, int length, int *n1); 9 | __global__ void add(int *output, int length, int *n1, int *n2); -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CUDA/mattdean1/scan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | namespace ParallelScan{ 4 | // long sequential_scan(int* output, int* input, int length); 5 | // float blockscan(int *output, int *input, int length, bool bcao); 6 | 7 | // float scan(int *output, int *input, int length, bool bcao, cudaStream_t stream = nullptr); 8 | // float scan(unsigned int *output, unsigned int *input, int length, bool bcao, cudaStream_t stream = nullptr); 9 | float scan_device(unsigned int *output, const unsigned int *input, int length, bool bcao, cudaStream_t stream = nullptr); 10 | 11 | // void scanLargeDeviceArray(int *output, int *input, int length, bool bcao); 12 | // void scanSmallDeviceArray(int *d_out, int *d_in, int length, bool bcao); 13 | // void scanLargeEvenDeviceArray(int *output, int *input, int length, bool bcao); 14 | } 15 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CUDA/mattdean1/utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | //#include 3 | #include 4 | 5 | #include "cuda_runtime.h" 6 | 7 | #include "utils.h" 8 | 9 | void _checkCudaError(const char *message, cudaError_t err, const char *caller) { 10 | if (err != cudaSuccess) { 11 | fprintf(stderr, "Error in: %s\n", caller); 12 | fprintf(stderr, message); 13 | fprintf(stderr, ": %s\n", cudaGetErrorString(err)); 14 | } 15 | } 16 | 17 | void printResult(const char* prefix, int result, long nanoseconds) { 18 | printf(" "); 19 | printf(prefix); 20 | printf(" : %i in %ld ms \n", result, nanoseconds / 1000); 21 | } 22 | 23 | void printResult(const char* prefix, int result, float milliseconds) { 24 | printf(" "); 25 | printf(prefix); 26 | printf(" : %i in %f ms \n", result, milliseconds); 27 | } 28 | 29 | 30 | // from https://stackoverflow.com/a/3638454 31 | bool isPowerOfTwo(int x) { 32 | return x && !(x & (x - 1)); 33 | } 34 | 35 | // from https://stackoverflow.com/a/12506181 36 | int nextPowerOfTwo(int x) { 37 | int power = 1; 38 | while (power < x) { 39 | power *= 2; 40 | } 41 | return power; 42 | } 43 | 44 | 45 | // from https://stackoverflow.com/a/36095407 46 | long get_nanos() { 47 | struct timespec ts; 48 | timespec_get(&ts, TIME_UTC); 49 | return (long)ts.tv_sec * 1000000000L + ts.tv_nsec; 50 | } -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CUDA/mattdean1/utils.h: -------------------------------------------------------------------------------- 1 | #include "cuda_runtime.h" 2 | 3 | void _checkCudaError(const char *message, cudaError_t err, const char *caller); 4 | void printResult(const char* prefix, int result, long nanoseconds); 5 | void printResult(const char* prefix, int result, float milliseconds); 6 | 7 | bool isPowerOfTwo(int x); 8 | int nextPowerOfTwo(int x); 9 | 10 | long get_nanos(); 11 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/CUDAInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/ITMMeshingEngine_CUDA.tcu" 4 | template class ITMLib::ITMMeshingEngine_CUDA; 5 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/ITMMeshingEngineFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "CPU/ITMMeshingEngine_CPU.h" 6 | #ifndef COMPILE_WITHOUT_CUDA 7 | #include "CUDA/ITMMeshingEngine_CUDA.h" 8 | #include "../../Utils/ITMLibSettings.h" 9 | 10 | #endif 11 | 12 | namespace ITMLib 13 | { 14 | 15 | /** 16 | * \brief This struct provides functions that can be used to construct meshing engines. 17 | */ 18 | struct ITMMeshingEngineFactory 19 | { 20 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 21 | 22 | /** 23 | * \brief Makes a meshing engine. 24 | * 25 | * \param deviceType The device on which the meshing engine should operate. 26 | */ 27 | template 28 | static ITMMeshingEngine *MakeMeshingEngine(ITMLibSettings::DeviceType deviceType, float isoValue = 0.f) 29 | { 30 | ITMMeshingEngine *meshingEngine = NULL; 31 | 32 | switch (deviceType) 33 | { 34 | case ITMLibSettings::DEVICE_CPU: 35 | meshingEngine = new ITMMeshingEngine_CPU (isoValue); 36 | break; 37 | case ITMLibSettings::DEVICE_CUDA: 38 | #ifndef COMPILE_WITHOUT_CUDA 39 | meshingEngine = new ITMMeshingEngine_CUDA (isoValue); 40 | #endif 41 | break; 42 | case ITMLibSettings::DEVICE_METAL: 43 | #ifdef COMPILE_WITH_METAL 44 | meshingEngine = new ITMMeshingEngine_CPU; 45 | #endif 46 | break; 47 | } 48 | 49 | return meshingEngine; 50 | } 51 | }; 52 | } -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/Interface/ITMMeshingEngine.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include "../../../Objects/Meshing/ITMMesh.h" 8 | #include "../../../Objects/Scene/ITMScene.h" 9 | #include "../../../Objects/Scene/ITMVoxelTypes.h" 10 | 11 | namespace ITMLib 12 | { 13 | template 14 | class ITMMeshingEngine 15 | { 16 | protected: 17 | std::unique_ptr> voxelVert_, voxelVertScan_, voxelOccupied_, voxelOccupiedScan_, compactedVoxelArray_; 18 | float isoValue_; 19 | const Vector4f *labelColorPtr_; 20 | public: 21 | void setIsoValue(float isoValue){this->isoValue_ = isoValue;} 22 | virtual void MeshScene(ITMMesh *mesh, const ITMScene *scene, bool checkVoxelState) = 0; 23 | virtual void MeshSceneLabel(ITMMesh *mesh, const ITMScene *scene, bool checkVoxelState) = 0; 24 | virtual void MeshScene(ITMMesh *mesh, const ORUtils::MemoryBlock *localVBA, const Vector3f &origin, const Vector3s &dims, float voxelSize) =0; 25 | virtual void setStream(void *stream) = 0; 26 | virtual void syncStream() = 0; 27 | void setLabelColorListPtr(const Vector4f *labelColorPtr) { labelColorPtr_ = labelColorPtr; }; 28 | virtual void reset() { 29 | if(voxelVert_)voxelVert_->Clear(); 30 | if(voxelVertScan_)voxelVertScan_->Clear(); 31 | if(voxelOccupied_)voxelOccupied_->Clear(); 32 | if(voxelOccupiedScan_)voxelOccupiedScan_->Clear(); 33 | if(compactedVoxelArray_)compactedVoxelArray_->Clear(); 34 | }; 35 | 36 | ITMMeshingEngine(const float &isoValue):isoValue_(isoValue), labelColorPtr_(NULL) { } 37 | virtual ~ITMMeshingEngine() { } 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /MainLib/Engines/Meshing/MeshEngine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../../ITMLibDefines.h" 5 | #include "../../Objects/Scene/ITMScene.h" 6 | #include "../../Objects/Meshing/ITMMesh.h" 7 | #include "Interface/ITMMeshingEngine.h" 8 | #include "../../Utils/ITMLibSettings.h" 9 | 10 | namespace SCFUSION { 11 | template 12 | class MeshEngine { 13 | public: 14 | MeshEngine(const ITMLib::ITMLibSettings *itmLibSettings); 15 | 16 | virtual bool computeMesh(ITMLib::ITMScene *itmScene, bool labelOnly, bool checkState); 17 | 18 | virtual void 19 | computeMesh(ORUtils::MemoryBlock *data, const Vector3f &origin, const Vector3s &dims, float voxelSize, 20 | float isoValue); 21 | 22 | void saveSceneToMesh(ITMLib::ITMScene *itmScene, const std::string &pth_to_directory, 23 | bool labelOnly=false, bool checkState=true); 24 | 25 | ITMLib::ITMMesh *getMesh(); 26 | 27 | void setLabelColorList(Vector4f *pointer) { 28 | itmMeshingEngine->setLabelColorListPtr(pointer); 29 | } 30 | 31 | void SyncMeshingEngine(){ itmMeshingEngine->syncStream(); } 32 | 33 | void reset(){ 34 | itmMeshingEngine->reset(); 35 | itmMesh->noTotalTriangles = 0; 36 | itmMesh->triangles->Clear(0); 37 | if(itmMesh->hasColor) itmMesh->colors->Clear(0); 38 | if(itmMesh->hasNormal) itmMesh->normals->Clear(0); 39 | } 40 | protected: 41 | std::unique_ptr > itmMeshingEngine; 42 | std::unique_ptr itmMesh; 43 | }; 44 | } -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################ 2 | # PointCloudEngine LIBRARY # 3 | ############################ 4 | set(targetname PointCloudEngine) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${VOXELCOUNTS} ) 15 | LIST(GET VOXELNAMES ${i} name) 16 | LIST(GET VOXELTYPES ${i} type) 17 | SET(FIELD_TYPE VOXELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 20 | ADD_LIBRARY(${targetname_suffix} OBJECT ${${targetname}_sources} ${${targetname}_headers}) 21 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 22 | ENDFOREACH() 23 | -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/CPU/PointCloudExtractionEngine_CPU.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Interface/PointCloudExtractionEngine.h" 3 | #include "../../../Utils/Exceptions.h" 4 | 5 | namespace SCFUSION { 6 | template 7 | class PointCloudExtractionEngine_CPU: public PointCloudExtractionEngine { 8 | explicit PointCloudExtractionEngine_CPU(){}; 9 | void setStream(void *stream) {} 10 | void syncStream() {}; 11 | void ExtractPointCloud(SCFUSION::PointCloud *pointcloud, const ITMLib::ITMScene *scene){ 12 | throw ERROR_NotImplemented(); 13 | }; 14 | }; 15 | 16 | template 17 | class PointCloudExtractionEngine_CPU : public PointCloudExtractionEngine { 18 | std::unique_ptr> voxelOccupied_, voxelOccupiedScan_, compactedVoxelArray_; 19 | cudaStream_t stream_; 20 | std::unique_ptr> visibleBlockGlobalPos; 21 | const size_t visibleBlockPos_size = SDF_LOCAL_BLOCK_NUM * SDF_BLOCK_SIZE3; 22 | public: 23 | explicit PointCloudExtractionEngine_CPU(){}; 24 | 25 | void ExtractPointCloud(SCFUSION::PointCloud *pointcloud, const ITMLib::ITMScene *scene){ 26 | throw ERROR_NotImplemented(); 27 | }; 28 | void setStream(void *stream) {stream_ = static_cast(stream);} 29 | void syncStream() {}; 30 | private: 31 | 32 | }; 33 | } -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/CPU/PointCloudExtractionEngine_CPU.tpp: -------------------------------------------------------------------------------- 1 | #include "PointCloudExtractionEngine_CPU.h" 2 | 3 | using namespace SCFUSION; -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CPU/PointCloudExtractionEngine_CPU.tpp" 4 | #include "PointCloudEngine.tpp" 5 | 6 | // Engines 7 | template class SCFUSION::PointCloudExtractionEngine_CPU; 8 | template class SCFUSION::PointCloudEngine; 9 | -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/CUDA/PointCloudExtractionEngine_CUDA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include "../Interface/PointCloudExtractionEngine.h" 5 | #include "../../../Objects/PointCloud/PointCloud.h" 6 | #include "../../../Objects/Scene/ITMVoxelTypes.h" 7 | 8 | namespace SCFUSION { 9 | template 10 | class PointCloudExtractionEngine_CUDA : public PointCloudExtractionEngine { 11 | public: 12 | void ExtractPointCloud(SCFUSION::PointCloud *pointcloud, const ITMLib::ITMScene *scene){}; 13 | void setStream(void *stream){} 14 | void syncStream() {}; 15 | }; 16 | 17 | template 18 | class PointCloudExtractionEngine_CUDA : public PointCloudExtractionEngine { 19 | std::unique_ptr> voxelOccupied_, voxelOccupiedScan_, compactedVoxelArray_; 20 | cudaStream_t stream_; 21 | std::unique_ptr> visibleBlockGlobalPos; 22 | const size_t visibleBlockPos_size = SDF_LOCAL_BLOCK_NUM * SDF_BLOCK_SIZE3; 23 | public: 24 | explicit PointCloudExtractionEngine_CUDA(); 25 | 26 | void ExtractPointCloud(SCFUSION::PointCloud *pointcloud, const ITMLib::ITMScene *scene); 27 | void setStream(void *stream) {stream_ = static_cast(stream);} 28 | void syncStream() {cudaStreamSynchronize(stream_);}; 29 | private: 30 | 31 | }; 32 | } -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/CUDAInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/PointCloudExtractionEngine_CUDA.tcu" 4 | // Engines 5 | template class SCFUSION::PointCloudExtractionEngine_CUDA; 6 | -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/Interface/PointCloudExtractionEngine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../../Objects/PointCloud/PointCloud.h" 4 | #include "../../../Objects/Scene/ITMVoxelBlockHash.h" 5 | #include "../../../Objects/Scene/ITMScene.h" 6 | 7 | namespace SCFUSION { 8 | template 9 | class PointCloudExtractionEngine { 10 | public: 11 | virtual void ExtractPointCloud(SCFUSION::PointCloud *pointcloud, const ITMLib::ITMScene *scene) = 0; 12 | virtual void setStream(void *stream){} 13 | virtual void syncStream() = 0; 14 | explicit PointCloudExtractionEngine() = default; 15 | virtual ~PointCloudExtractionEngine() = default; 16 | private: 17 | 18 | }; 19 | } -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/PointCloudEngine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../Utils/ITMLibSettings.h" 3 | #include "../../Objects/PointCloud/PointCloud.h" 4 | #include "Interface/PointCloudExtractionEngine.h" 5 | #include "../../ITMLibDefines.h" 6 | namespace SCFUSION { 7 | template 8 | class PointCloudEngine { 9 | public: 10 | PointCloudEngine(const ITMLib::ITMLibSettings *itmLibSettings); 11 | 12 | virtual void computePointCloud(ITMLib::ITMScene* itmScene); 13 | 14 | SCFUSION::PointCloud* getPointCloud(); 15 | 16 | // void setLabelColorList(Vector4f *pointer) { 17 | // pointCloudExtractionEngine->setLabelColorListPtr(pointer); 18 | // } 19 | 20 | void SyncPointExtractionEngine(){ pointCloudExtractionEngine->syncStream(); } 21 | 22 | void reset(){ 23 | pointcloud->noTotalPoints=0; 24 | pointcloud->points->Clear(0); 25 | pointcloud->colors->Clear(0); 26 | } 27 | protected: 28 | std::unique_ptr> pointCloudExtractionEngine; 29 | std::unique_ptr pointcloud; 30 | }; 31 | } -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/PointCloudEngine.tpp: -------------------------------------------------------------------------------- 1 | #include "PointCloudEngine.h" 2 | #include "PointCloudExtractionEngineFactory.h" 3 | 4 | using namespace SCFUSION; 5 | template 6 | PointCloudEngine::PointCloudEngine(const ITMLib::ITMLibSettings *itmSettings) { 7 | if(itmSettings->createPointExtractionEngine) 8 | pointcloud.reset(new SCFUSION::PointCloud(itmSettings->GetMemoryType())); 9 | 10 | if(itmSettings->createPointExtractionEngine) { 11 | pointCloudExtractionEngine.reset( 12 | PointCloudEngineFactory::MakeMeshingEngine(itmSettings->deviceType)); 13 | } 14 | } 15 | template 16 | SCFUSION::PointCloud* PointCloudEngine::getPointCloud() { 17 | return pointcloud.get(); 18 | } 19 | 20 | template 21 | void PointCloudEngine::computePointCloud(ITMLib::ITMScene* itmScene) { 22 | if(pointCloudExtractionEngine == nullptr) 23 | throw std::runtime_error("Did not enable point extraction!!\n"); 24 | pointCloudExtractionEngine->ExtractPointCloud(pointcloud.get(), itmScene); 25 | } -------------------------------------------------------------------------------- /MainLib/Engines/PointExtraction/PointCloudExtractionEngineFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | 6 | #include "../../Objects/Scene/ITMVoxelTypes.h" 7 | #include "../../Utils/ITMLibSettings.h" 8 | #include "CPU/PointCloudExtractionEngine_CPU.h" 9 | #ifndef COMPILE_WITHOUT_CUDA 10 | #include "CUDA/PointCloudExtractionEngine_CUDA.h" 11 | #endif 12 | 13 | namespace SCFUSION 14 | { 15 | 16 | /** 17 | * \brief This struct provides functions that can be used to construct meshing engines. 18 | */ 19 | struct PointCloudEngineFactory 20 | { 21 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 22 | 23 | /** 24 | * \brief Makes a meshing engine. 25 | * 26 | * \param deviceType The device on which the meshing engine should operate. 27 | */ 28 | template 29 | static PointCloudExtractionEngine *MakeMeshingEngine(ITMLib::ITMLibSettings::DeviceType deviceType) 30 | { 31 | PointCloudExtractionEngine *engine = NULL; 32 | 33 | switch (deviceType) 34 | { 35 | case ITMLib::ITMLibSettings::DEVICE_CPU: 36 | engine = new PointCloudExtractionEngine_CPU (); 37 | break; 38 | case ITMLib::ITMLibSettings::DEVICE_CUDA: 39 | #ifndef COMPILE_WITHOUT_CUDA 40 | engine = new PointCloudExtractionEngine_CUDA (); 41 | #endif 42 | break; 43 | case ITMLib::ITMLibSettings::DEVICE_METAL: 44 | #ifdef COMPILE_WITH_METAL 45 | engine = new ITMMeshingEngine_CPU; 46 | #endif 47 | break; 48 | } 49 | 50 | return engine; 51 | } 52 | }; 53 | } -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/CPU/ITMSurfelSceneReconstructionEngine_CPU.h: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMSurfelSceneReconstructionEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | /** 10 | * \brief An instance of an instantiation of this class template can be used to make a surfel-based reconstruction of a 3D scene using the CPU. 11 | */ 12 | template 13 | class ITMSurfelSceneReconstructionEngine_CPU : public ITMSurfelSceneReconstructionEngine 14 | { 15 | //#################### CONSTRUCTORS #################### 16 | public: 17 | /** 18 | * \brief Constructs a CPU-based surfel scene reconstruction engine. 19 | * 20 | * \param depthImageSize The size of the depth images that are being fused into the scene. 21 | */ 22 | explicit ITMSurfelSceneReconstructionEngine_CPU(const Vector2i& depthImageSize); 23 | 24 | //#################### PRIVATE MEMBER FUNCTIONS #################### 25 | private: 26 | /** Override */ 27 | virtual void AddNewSurfels(ITMSurfelScene *scene, const ITMView *view, const ITMTrackingState *trackingState) const; 28 | 29 | /** Override */ 30 | virtual void FindCorrespondingSurfels(const ITMSurfelScene *scene, const ITMView *view, const ITMTrackingState *trackingState, 31 | const ITMSurfelRenderState *renderState) const; 32 | 33 | /** Override */ 34 | virtual void FuseMatchedPoints(ITMSurfelScene *scene, const ITMView *view, const ITMTrackingState *trackingState) const; 35 | 36 | /** Override */ 37 | virtual void MarkBadSurfels(ITMSurfelScene *scene) const; 38 | 39 | /** Override */ 40 | virtual void MergeSimilarSurfels(ITMSurfelScene *scene, const ITMSurfelRenderState *renderState) const; 41 | 42 | /** Override */ 43 | virtual void PreprocessDepthMap(const ITMView *view, const ITMSurfelSceneParams& sceneParams) const; 44 | 45 | /** Override */ 46 | virtual void RemoveMarkedSurfels(ITMSurfelScene *scene) const; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/CPUSurfelInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CPU/ITMSurfelSceneReconstructionEngine_CPU.tpp" 4 | #include "Interface/ITMSurfelSceneReconstructionEngine.tpp" 5 | #include "ITMSurfelSceneReconstructionEngineFactory.tpp" 6 | // Engines 7 | template class ITMLib::ITMSurfelSceneReconstructionEngine; 8 | template class ITMLib::ITMSurfelSceneReconstructionEngine_CPU; 9 | template struct ITMLib::ITMSurfelSceneReconstructionEngineFactory; -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/CPUVoxelInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CPU/ITMSceneReconstructionEngine_CPU.tpp" 4 | // Engines 5 | template class ITMLib::ITMSceneReconstructionEngine_CPU; -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/CUDA/ITMSurfelSceneReconstructionEngine_CUDA.h: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMSurfelSceneReconstructionEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | /** 10 | * \brief An instance of an instantiation of this class template can be used to make a surfel-based reconstruction of a 3D scene using CUDA. 11 | */ 12 | template 13 | class ITMSurfelSceneReconstructionEngine_CUDA : public ITMSurfelSceneReconstructionEngine 14 | { 15 | //#################### CONSTRUCTORS #################### 16 | public: 17 | /** 18 | * \brief Constructs a CUDA-based surfel scene reconstruction engine. 19 | * 20 | * \param depthImageSize The size of the depth images that are being fused into the scene. 21 | */ 22 | explicit ITMSurfelSceneReconstructionEngine_CUDA(const Vector2i& depthImageSize); 23 | 24 | //#################### PROTECTED MEMBER FUNCTIONS #################### 25 | protected: 26 | /** Override */ 27 | virtual void AddNewSurfels(ITMSurfelScene *scene, const ITMView *view, const ITMTrackingState *trackingState) const; 28 | 29 | /** Override */ 30 | virtual void FindCorrespondingSurfels(const ITMSurfelScene *scene, const ITMView *view, const ITMTrackingState *trackingState, 31 | const ITMSurfelRenderState *renderState) const; 32 | 33 | /** Override */ 34 | virtual void FuseMatchedPoints(ITMSurfelScene *scene, const ITMView *view, const ITMTrackingState *trackingState) const; 35 | 36 | /** Override */ 37 | virtual void MarkBadSurfels(ITMSurfelScene *scene) const; 38 | 39 | /** Override */ 40 | virtual void MergeSimilarSurfels(ITMSurfelScene *scene, const ITMSurfelRenderState *renderState) const; 41 | 42 | /** Override */ 43 | virtual void PreprocessDepthMap(const ITMView *view, const ITMSurfelSceneParams& sceneParams) const; 44 | 45 | /** Override */ 46 | virtual void RemoveMarkedSurfels(ITMSurfelScene *scene) const; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/CUDASurfelInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/ITMSurfelSceneReconstructionEngine_CUDA.tcu" 4 | 5 | // Engines 6 | template class ITMLib::ITMSurfelSceneReconstructionEngine_CUDA; 7 | -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/CUDAVoxelInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/ITMSceneReconstructionEngine_CUDA.tcu" 4 | 5 | // Engines 6 | template class ITMLib::ITMSceneReconstructionEngine_CUDA; 7 | -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/ITMSceneReconstructionEngineFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "CPU/ITMSceneReconstructionEngine_CPU.h" 6 | #ifndef COMPILE_WITHOUT_CUDA 7 | #include "CUDA/ITMSceneReconstructionEngine_CUDA.h" 8 | #include "../../Utils/ITMLibSettings.h" 9 | 10 | #endif 11 | #ifdef COMPILE_WITH_METAL 12 | #include "Metal/ITMSceneReconstructionEngine_Metal.h" 13 | #endif 14 | 15 | namespace ITMLib 16 | { 17 | 18 | /** 19 | * \brief This struct provides functions that can be used to construct scene reconstruction engines. 20 | */ 21 | struct ITMSceneReconstructionEngineFactory 22 | { 23 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 24 | 25 | /** 26 | * \brief Makes a scene reconstruction engine. 27 | * 28 | * \param deviceType The device on which the scene reconstruction engine should operate. 29 | */ 30 | template 31 | static ITMSceneReconstructionEngine *MakeSceneReconstructionEngine(ITMLibSettings::DeviceType deviceType) 32 | { 33 | ITMSceneReconstructionEngine *sceneRecoEngine = NULL; 34 | 35 | switch(deviceType) 36 | { 37 | case ITMLibSettings::DEVICE_CPU: 38 | sceneRecoEngine = new ITMSceneReconstructionEngine_CPU; 39 | break; 40 | case ITMLibSettings::DEVICE_CUDA: 41 | #ifndef COMPILE_WITHOUT_CUDA 42 | sceneRecoEngine = new ITMSceneReconstructionEngine_CUDA; 43 | #endif 44 | break; 45 | case ITMLibSettings::DEVICE_METAL: 46 | #ifdef COMPILE_WITH_METAL 47 | sceneRecoEngine = new ITMSceneReconstructionEngine_Metal; 48 | #endif 49 | break; 50 | } 51 | 52 | return sceneRecoEngine; 53 | } 54 | }; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/ITMSurfelSceneReconstructionEngineFactory.h: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #pragma once 4 | 5 | #include "Interface/ITMSurfelSceneReconstructionEngine.h" 6 | #include "../../Utils/ITMLibSettings.h" 7 | 8 | namespace ITMLib 9 | { 10 | /** 11 | * \brief An instantiation of this struct can be used to construct surfel scene reconstruction engines. 12 | */ 13 | template 14 | struct ITMSurfelSceneReconstructionEngineFactory 15 | { 16 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 17 | 18 | /** 19 | * \brief Makes a surfel scene reconstruction engine. 20 | * 21 | * \param depthImageSize The size of the depth images that will be fused into the scene. 22 | * \param deviceType The device on which the surfel scene reconstruction engine should operate. 23 | * \return The surfel scene reconstruction engine. 24 | */ 25 | static ITMSurfelSceneReconstructionEngine *make_surfel_scene_reconstruction_engine(const Vector2i& depthImageSize, ITMLib::ITMLibSettings::DeviceType deviceType); 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/ITMSurfelSceneReconstructionEngineFactory.tpp: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #include "ITMSurfelSceneReconstructionEngineFactory.h" 4 | 5 | #include "CPU/ITMSurfelSceneReconstructionEngine_CPU.h" 6 | 7 | #ifndef COMPILE_WITHOUT_CUDA 8 | #include "CUDA/ITMSurfelSceneReconstructionEngine_CUDA.h" 9 | #endif 10 | 11 | namespace ITMLib 12 | { 13 | 14 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 15 | 16 | template 17 | ITMSurfelSceneReconstructionEngine * 18 | ITMSurfelSceneReconstructionEngineFactory::make_surfel_scene_reconstruction_engine(const Vector2i& depthImageSize, ITMLibSettings::DeviceType deviceType) 19 | { 20 | ITMSurfelSceneReconstructionEngine *reconstructionEngine = NULL; 21 | 22 | if(deviceType == ITMLibSettings::DEVICE_CUDA) 23 | { 24 | #ifndef COMPILE_WITHOUT_CUDA 25 | reconstructionEngine = new ITMSurfelSceneReconstructionEngine_CUDA(depthImageSize); 26 | #else 27 | throw std::runtime_error("Error: CUDA support not currently available. Reconfigure in CMake with the WITH_CUDA option set to on."); 28 | #endif 29 | } 30 | else 31 | { 32 | reconstructionEngine = new ITMSurfelSceneReconstructionEngine_CPU(depthImageSize); 33 | } 34 | 35 | return reconstructionEngine; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /MainLib/Engines/Reconstruction/Metal/ITMSceneReconstructionEngine_Metal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Isis Innovation Limited and the authors of InfiniTAM 2 | #pragma once 3 | 4 | #ifndef __METALC__ 5 | 6 | #include "../CPU/ITMSceneReconstructionEngine_CPU.h" 7 | 8 | namespace ITMLib 9 | { 10 | template 11 | class ITMSceneReconstructionEngine_Metal : public ITMSceneReconstructionEngine_CPU 12 | {}; 13 | 14 | template 15 | class ITMSceneReconstructionEngine_Metal : public ITMSceneReconstructionEngine_CPU 16 | { 17 | private: 18 | void BuildAllocAndVisibleType(ITMScene *scene, const ITMView *view, 19 | const ITMTrackingState *trackingState, const ITMRenderState *renderState); 20 | public: 21 | void IntegrateIntoScene(ITMScene *scene, const ITMView *view, const ITMTrackingState *trackingState, 22 | const ITMRenderState *renderState); 23 | 24 | void AllocateSceneFromDepth(ITMScene *scene, const ITMView *view, 25 | const ITMTrackingState *trackingState, const ITMRenderState *renderState, 26 | bool onlyUpdateVisibleList = false, bool resetVisibleList = false); 27 | 28 | ITMSceneReconstructionEngine_Metal(void); 29 | }; 30 | 31 | template 32 | class ITMSceneReconstructionEngine_Metal : public ITMSceneReconstructionEngine_CPU 33 | { }; 34 | } 35 | 36 | #endif 37 | 38 | #if (defined __OBJC__) || (defined __METALC__) 39 | 40 | struct IntegrateIntoScene_VH_Params 41 | { 42 | Vector2i rgbImgSize, depthImgSize; 43 | Matrix4f M_d, M_rgb; 44 | Vector4f projParams_d, projParams_rgb; 45 | Vector4f others; 46 | }; 47 | 48 | struct BuildAllocVisibleType_VH_Params 49 | { 50 | Matrix4f invM_d; 51 | Vector4f invProjParams_d; 52 | Vector4f others; 53 | Vector2i depthImgSize; 54 | }; 55 | 56 | #endif -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################# 2 | # SceneCompletionEngine LIBRARY # 3 | ################################# 4 | set(targetnamebase SceneCompletionEngine) 5 | file(GLOB_RECURSE ${targetnamebase}_headers *.h) 6 | file(GLOB_RECURSE ${targetnamebase}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${VOXELCOUNTS} ) 15 | LIST(GET VOXELNAMES ${i} name) 16 | LIST(GET VOXELTYPES ${i} type) 17 | SET(FIELD_TYPE VOXELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname ${targetnamebase}${NAME_SUFFIX}) 20 | ADD_LIBRARY(${targetname} OBJECT ${${targetnamebase}_sources} ${${targetnamebase}_headers}) 21 | if(TENSORFLOW_FOUND) 22 | INCLUDE(${PROJECT_SOURCE_DIR}/cmake/LinkTensorflow.cmake) 23 | endif() 24 | TARGET_COMPILE_DEFINITIONS(${targetname} PUBLIC VOXELTYPE=${type}) 25 | SET_TARGET_PROPERTIES(${targetname} PROPERTIES CXX_STANDARD 14) 26 | ENDFOREACH() 27 | -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/CUDA/SceneCompletionEngine_CUDA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Interface/SceneCompletionEngine.h" 4 | #include "../../Reconstruction/Interface/ITMSceneReconstructionEngine.h" 5 | 6 | namespace SCFUSION { 7 | template 8 | class SceneCompletionEngine_CUDA : public SceneCompletionEngine{}; 9 | 10 | template 11 | class SceneCompletionEngine_CUDA : public SceneCompletionEngine { 12 | private: 13 | cudaStream_t stream_; 14 | public: 15 | void ResetSCBuffer(SCBuffer *scBuffer); 16 | 17 | float CriteriaCheck(SCBuffer *scBuffer, const ITMLib::ITMScene *scene); 18 | 19 | void Extraction(SCBuffer *scBuffer, const ITMLib::ITMScene *scene); 20 | 21 | void Fusion(ITMLib::ITMScene *scene, const SCBuffer *scBuffer); 22 | 23 | /// Extract label and confidence 24 | void ExtractLabelAndConfidnece(SCBuffer *scBuffer, const ITMLib::ITMScene *scene); 25 | 26 | /// Fuse label and confidence 27 | void FusionLabelAndConfidence(ITMLib::ITMScene *scene, const SCBuffer *scBuffer); 28 | 29 | void setStream(void *stream) { stream_ = static_cast(stream); } 30 | void syncStream() {cudaStreamSynchronize(stream_);} 31 | 32 | SceneCompletionEngine_CUDA(SceneCompletionMethod sceneCompletionMethod); 33 | ~SceneCompletionEngine_CUDA(); 34 | }; 35 | } -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/CUDAInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/SceneCompletionEngine_CUDA.tcu" 4 | 5 | // Engines 6 | template class SCFUSION::SceneCompletionEngine_CUDA; 7 | -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/FusionPolicies.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace SCFUSION{ 4 | namespace Policy { 5 | enum FuseTwo { 6 | FuseTwo_OCCUPIED, // Fuse completion result entirely into global map 7 | FuseTwo_ALL_CONFIDENCE, // treat softmax as confidence value and multiply it with COMPLETION_WEIGHT 8 | FuseTwo_UNKNOWN, // Fuse only on unknown area (not observed by camera) 9 | FuseTwo_UNKNOWN_CONFIDENCE, 10 | FuseTwo_ALL_OCCUPANCY, // Unlike above, using 1 as a observation. use the softmax value instead. 11 | FuseTwo_UNKNOWN_OCCUPANCY, 12 | FuseTwo_ALL_UNWEIGHT, // This takes only depth fusion information as input. This will force integrate policy in fusetwo to Integrate_DIRECT 13 | FuseTwo_UNKNOWN_UNWEIGHT, 14 | }; 15 | }; 16 | 17 | 18 | enum SceneCompletionMethod { 19 | SceneCompletionMethod_ForkNet, SceneCompletionMethod_SceneInpainting 20 | }; 21 | } -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/Interface/ForkNet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef COMPILE_WITH_TENSORFLOW 3 | #include "../../../../TFCpp/include/TFCpp/TFCppTools.h" 4 | #include "SceneCompletionEngine.h" 5 | namespace SCFUSION { 6 | 7 | class ForkNet : public NetworkBackEnd { 8 | public: 9 | ForkNet(std::string path_pb, std::string inputTensorName, std::string outputTensorName, std::vector inputDims, std::vector outputDims, float gpu_fraction); 10 | ForkNet(std::string pth_to_meda, std::string pth_to_ckpt, std::string inputTensorName, std::string outputTensorName, std::vector inputDims, std::vector outputDims, float gpu_fraction); 11 | ~ForkNet(); 12 | 13 | void process(float * data, size_t size); 14 | void process(float * data, float * confidense, size_t size); 15 | 16 | void compute(float *data_in, unsigned int size); 17 | void getResult(float *data_out, float *confidense_out, size_t size); 18 | // void getResult(float *data_out, LogOddLabels *confidense_out, size_t size); 19 | void getResult(float *data_out, size_t size); 20 | protected: 21 | std::string inputTensorName_, outputTensorName_; 22 | std::vector inputDims_, outputDims_; 23 | std::unique_ptr tfcpp_; 24 | size_t outputSize_, inputSize_; 25 | // float *data_buffer_, *conf_buffer_; 26 | void init(); 27 | }; 28 | } 29 | 30 | 31 | #endif -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/Interface/SceneCompletionEngine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../../Objects/Scene/ITMVoxelTypes.h" 3 | #include "../../../Objects/Scene/ITMVoxelBlockHash.h" 4 | #include "../../../Objects/Scene/ITMScene.h" 5 | #include "../../../Objects/SceneCompletion/SceneCompletionBuffer.h" 6 | #include 7 | #include 8 | //#include "SceneCompletion.h" 9 | 10 | namespace SCFUSION{ 11 | 12 | template 13 | class SceneCompletionEngine { 14 | protected: 15 | SceneCompletionMethod sceneCompletionMethod_; 16 | public: 17 | SceneCompletionEngine(SceneCompletionMethod sceneCompletionMethod):sceneCompletionMethod_(sceneCompletionMethod){}; 18 | virtual ~SceneCompletionEngine()= default; 19 | 20 | /// Check should do completion or not 21 | virtual float CriteriaCheck(SCBuffer *scBuffer, const ITMLib::ITMScene *scene) = 0; 22 | 23 | /// Extract sub-map 24 | virtual void Extraction(SCBuffer *scBuffer, const ITMLib::ITMScene *scene) = 0; 25 | 26 | /// Fuse sub-map 27 | virtual void Fusion(ITMLib::ITMScene *scene, const SCBuffer *scBuffer) = 0; 28 | 29 | /// Extract label and confidence 30 | virtual void ExtractLabelAndConfidnece(SCBuffer *scBuffer, const ITMLib::ITMScene *scene) = 0; 31 | 32 | /// Fuse label and confidence 33 | virtual void FusionLabelAndConfidence(ITMLib::ITMScene *scene, const SCBuffer *scBuffer) = 0; 34 | 35 | virtual void ResetSCBuffer(SCBuffer *scBuffer) = 0; 36 | 37 | virtual void setStream(void *stream)=0; 38 | virtual void syncStream() = 0; 39 | }; 40 | 41 | class NetworkBackEnd { 42 | public: 43 | NetworkBackEnd()=default; 44 | virtual ~NetworkBackEnd()=default; 45 | }; 46 | } -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/Interface/SceneInpainting.cpp: -------------------------------------------------------------------------------- 1 | #ifdef COMPILE_WITH_PYTORCH 2 | #include "SceneInpainting.h" 3 | #include 4 | 5 | namespace SCFUSION { 6 | 7 | SceneInpainting::SceneInpainting(const std::string &path_pb, const std::vector &inputDims, const std::vector &inputStride, int device) { 8 | pytorchcpp_.reset(new torch::PytorchCpp(path_pb,device,true,true)); 9 | for(auto d : inputDims) inputDims_.push_back(d); 10 | for(auto d : inputStride) inputStride_.push_back(d); 11 | } 12 | SceneInpainting::SceneInpainting(const std::string &path_pb, const std::vector &inputDims, const std::vector &inputStride, int device) { 13 | pytorchcpp_.reset(new torch::PytorchCpp(path_pb,device,true,true)); 14 | inputDims_ = inputDims; 15 | inputStride_ = inputStride; 16 | } 17 | 18 | void SceneInpainting::compute(float * data, bool * mask){ 19 | TICK("[SceneInpainting][compute]1.resetInput"); 20 | pytorchcpp_->resetInputs(); 21 | TOCK("[SceneInpainting][compute]1.resetInput"); 22 | TICK("[SceneInpainting][compute]2.addInputs"); 23 | pytorchcpp_->addInput(data,inputDims_); 24 | pytorchcpp_->addInput(mask,inputDims_); 25 | TOCK("[SceneInpainting][compute]2.addInputs"); 26 | TICK("[SceneInpainting][compute]3.process"); 27 | pytorchcpp_->process(); 28 | TOCK("[SceneInpainting][compute]3.process"); 29 | } 30 | 31 | void SceneInpainting::getResult(float *data_out, size_t size) { 32 | pytorchcpp_->copyOutput(data_out,size); 33 | } 34 | void SceneInpainting::getResult(float *data_out, float *confidense_out, size_t size) { 35 | pytorchcpp_->copyOutput(data_out, confidense_out, size); 36 | } 37 | } 38 | 39 | #endif -------------------------------------------------------------------------------- /MainLib/Engines/SceneCompletion/Interface/SceneInpainting.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef COMPILE_WITH_PYTORCH 3 | #include "../../../../PytorchCpp/include/PytorchCpp/PytorchCpp.h" 4 | //#include "../../../../Utilities/include/Utilities/LogUtil.hpp" 5 | #include "SceneCompletionEngine.h" 6 | namespace SCFUSION { 7 | 8 | class SceneInpainting : public NetworkBackEnd { 9 | public: 10 | /** 11 | * 12 | * @param path_pb 13 | * @param inputDims 14 | * @param inputStride 15 | * @param device -1 for auto detection 16 | */ 17 | SceneInpainting(const std::string &path_pb, const std::vector &inputDims, const std::vector &inputStride, int device); 18 | 19 | /** 20 | * 21 | * @param path_pb 22 | * @param inputDims 23 | * @param inputStride 24 | * @param device -1 for auto detection 25 | */ 26 | SceneInpainting(const std::string &path_pb, const std::vector &inputDims, const std::vector &inputStride, int device); 27 | 28 | ~SceneInpainting() = default; 29 | 30 | void compute(float * data, bool * mask); 31 | void getResult(float *data_out, float *confidense_out, size_t size); 32 | void getResult(float *data_out, size_t size); 33 | 34 | protected: 35 | std::vector inputDims_, inputStride_; 36 | std::unique_ptr pytorchcpp_; 37 | }; 38 | } 39 | #endif -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################ 2 | # SwappingEngine LIBRARY # 3 | ############################ 4 | set(targetname SwappingEngine) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | 14 | FOREACH(i RANGE ${VOXELCOUNTS} ) 15 | LIST(GET VOXELNAMES ${i} name) 16 | LIST(GET VOXELTYPES ${i} type) 17 | SET(FIELD_TYPE VOXELTYPE=${type}) 18 | SET(NAME_SUFFIX _${name}) 19 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 20 | ADD_LIBRARY(${targetname_suffix} OBJECT ${${targetname}_sources} ${${targetname}_headers}) 21 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 22 | ENDFOREACH() 23 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/CPU/ITMSwappingEngine_CPU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMSwappingEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | template 10 | class ITMSwappingEngine_CPU : public ITMSwappingEngine < TVoxel, TIndex > 11 | { 12 | public: 13 | void IntegrateGlobalIntoLocal(ITMScene *scene, ITMRenderState *renderState) {} 14 | void SaveToGlobalMemory(ITMScene *scene, ITMRenderState *renderState) {} 15 | void CleanLocalMemory(ITMScene *scene, ITMRenderState *renderState) {} 16 | }; 17 | 18 | template 19 | class ITMSwappingEngine_CPU : public ITMSwappingEngine < TVoxel, ITMVoxelBlockHash > 20 | { 21 | private: 22 | int LoadFromGlobalMemory(ITMScene *scene); 23 | 24 | public: 25 | // This class is currently just for debugging purposes -- swaps CPU memory to CPU memory. 26 | // Potentially this could stream into the host memory from somwhere else (disk, database, etc.). 27 | 28 | void IntegrateGlobalIntoLocal(ITMScene *scene, ITMRenderState *renderState); 29 | void SaveToGlobalMemory(ITMScene *scene, ITMRenderState *renderState); 30 | void CleanLocalMemory(ITMScene *scene, ITMRenderState *renderState); 31 | 32 | ITMSwappingEngine_CPU(void); 33 | ~ITMSwappingEngine_CPU(void); 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/CPUInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CPU/ITMSwappingEngine_CPU.tpp" 4 | 5 | // Engines 6 | template class ITMLib::ITMSwappingEngine_CPU; -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/CUDA/ITMSwappingEngine_CUDA.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMSwappingEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | template 10 | class ITMSwappingEngine_CUDA : public ITMSwappingEngine < TVoxel, TIndex > 11 | { 12 | public: 13 | void IntegrateGlobalIntoLocal(ITMScene *scene, ITMRenderState *renderState) {} 14 | void SaveToGlobalMemory(ITMScene *scene, ITMRenderState *renderState) {} 15 | void CleanLocalMemory(ITMScene *scene, ITMRenderState *renderState) {} 16 | }; 17 | 18 | template 19 | class ITMSwappingEngine_CUDA : public ITMSwappingEngine < TVoxel, ITMVoxelBlockHash > 20 | { 21 | private: 22 | int *noNeededEntries_device, *noAllocatedVoxelEntries_device; 23 | int *entriesToClean_device; 24 | 25 | int LoadFromGlobalMemory(ITMScene *scene); 26 | 27 | public: 28 | void IntegrateGlobalIntoLocal(ITMScene *scene, ITMRenderState *renderState); 29 | void SaveToGlobalMemory(ITMScene *scene, ITMRenderState *renderState); 30 | void CleanLocalMemory(ITMScene *scene, ITMRenderState *renderState); 31 | 32 | ITMSwappingEngine_CUDA(void); 33 | ~ITMSwappingEngine_CUDA(void); 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/CUDAInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/ITMSwappingEngine_CUDA.tcu" 4 | // Engines 5 | template class ITMLib::ITMSwappingEngine_CUDA; 6 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/ITMSwappingEngineFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | #include "../../Utils/ITMLibSettings.h" 5 | #include "CPU/ITMSwappingEngine_CPU.h" 6 | #ifndef COMPILE_WITHOUT_CUDA 7 | #include "CUDA/ITMSwappingEngine_CUDA.h" 8 | #endif 9 | #ifdef COMPILE_WITH_METAL 10 | #include "Metal/ITMSwappingEngine_Metal.h" 11 | #endif 12 | 13 | namespace ITMLib 14 | { 15 | 16 | /** 17 | * \brief This struct provides functions that can be used to construct swapping engines. 18 | */ 19 | struct ITMSwappingEngineFactory 20 | { 21 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 22 | 23 | /** 24 | * \brief Makes a swapping engine. 25 | * 26 | * \param deviceType The device on which the swapping engine should operate. 27 | */ 28 | template 29 | static ITMSwappingEngine *MakeSwappingEngine(ITMLibSettings::DeviceType deviceType) 30 | { 31 | ITMSwappingEngine *swappingEngine = NULL; 32 | 33 | switch(deviceType) 34 | { 35 | case ITMLibSettings::DEVICE_CPU: 36 | swappingEngine = new ITMSwappingEngine_CPU; 37 | break; 38 | case ITMLibSettings::DEVICE_CUDA: 39 | #ifndef COMPILE_WITHOUT_CUDA 40 | swappingEngine = new ITMSwappingEngine_CUDA; 41 | #endif 42 | break; 43 | case ITMLibSettings::DEVICE_METAL: 44 | #ifdef COMPILE_WITH_METAL 45 | swappingEngine = new ITMSwappingEngine_CPU; 46 | #endif 47 | break; 48 | } 49 | 50 | return swappingEngine; 51 | } 52 | }; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/Interface/ITMSwappingEngine.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../../Objects/RenderStates/ITMRenderState.h" 6 | #include "../../../Objects/Scene/ITMScene.h" 7 | #include "../../../Objects/Views/ITMView.h" 8 | 9 | namespace ITMLib 10 | { 11 | /** \brief 12 | Interface to engines that swap data in and out of the 13 | fairly limited GPU memory to some large scale storage 14 | space. 15 | */ 16 | template 17 | class ITMSwappingEngine 18 | { 19 | public: 20 | virtual void IntegrateGlobalIntoLocal(ITMScene *scene, ITMRenderState *renderState) = 0; 21 | virtual void SaveToGlobalMemory(ITMScene *scene, ITMRenderState *renderState) = 0; 22 | virtual void CleanLocalMemory(ITMScene *scene, ITMRenderState *renderState) = 0; 23 | 24 | virtual ~ITMSwappingEngine(void) { } 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/Metal/ITMSwappingEngine.metal: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Isis Innovation Limited and the authors of InfiniTAM 2 | 3 | #include 4 | 5 | using namespace metal; 6 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/Metal/ITMSwappingEngine_Metal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Isis Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMSwappingEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | template 10 | class ITMSwappingEngine_Metal : public ITMSwappingEngine 11 | { 12 | public: 13 | void IntegrateGlobalIntoLocal(ITMScene *scene, ITMView *view) {} 14 | void SaveToGlobalMemory(ITMScene *scene, ITMView *view) {} 15 | }; 16 | 17 | template 18 | class ITMSwappingEngine_Metal : public ITMSwappingEngine 19 | { 20 | protected: 21 | int DownloadFromGlobalMemory(ITMScene *scene, ITMView *view); 22 | 23 | public: 24 | // This class is currently just for debugging purposes -- swaps Metal memory to Metal memory. 25 | // Potentially this could stream into the host memory from somwhere else (disk, database, etc.). 26 | 27 | void IntegrateGlobalIntoLocal(ITMScene *scene, ITMView *view); 28 | void SaveToGlobalMemory(ITMScene *scene, ITMView *view); 29 | 30 | ITMSwappingEngine_Metal(void); 31 | ~ITMSwappingEngine_Metal(void); 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/Metal/ITMSwappingEngine_Metal.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Isis Innovation Limited and the authors of InfiniTAM 2 | #ifdef COMPILE_WITH_METAL 3 | 4 | #include "ITMSwappingEngine_Metal.h" 5 | 6 | //using namespace ITMLib::Engine; 7 | // 8 | //template 9 | //ITMSwappingEngine_Metal::ITMSwappingEngine_Metal(void) 10 | //{ 11 | //} 12 | // 13 | //template 14 | //ITMSwappingEngine_Metal::~ITMSwappingEngine_Metal(void) 15 | //{ 16 | //} 17 | // 18 | //template 19 | //int ITMSwappingEngine_Metal::DownloadFromGlobalMemory(ITMScene *scene, ITMView *view) 20 | //{ 21 | // return 0; 22 | //} 23 | // 24 | //template 25 | //void ITMSwappingEngine_Metal::IntegrateGlobalIntoLocal(ITMScene *scene, ITMView *view) 26 | //{ 27 | // 28 | //} 29 | // 30 | //template 31 | //void ITMSwappingEngine_Metal::SaveToGlobalMemory(ITMScene *scene, ITMView *view) 32 | //{ 33 | // 34 | //} 35 | // 36 | //template class ITMLib::Engine::ITMSwappingEngine_Metal; 37 | 38 | #endif -------------------------------------------------------------------------------- /MainLib/Engines/Swapping/Shared/ITMSwappingEngine_Shared.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../../Utils/ITMMath.h" 6 | 7 | template 8 | _CPU_AND_GPU_CODE_ inline void combineVoxelDepthInformation(const CONSTPTR(TVoxel) & src, DEVICEPTR(TVoxel) & dst, int maxW) 9 | { 10 | int newW = dst.w_depth; 11 | int oldW = src.w_depth; 12 | float newF = TVoxel::valueToFloat(dst.sdf); 13 | float oldF = TVoxel::valueToFloat(src.sdf); 14 | 15 | if (oldW == 0) return; 16 | 17 | newF = oldW * oldF + newW * newF; 18 | newW = oldW + newW; 19 | newF /= newW; 20 | newW = MIN(newW, maxW); 21 | 22 | dst.w_depth = newW; 23 | dst.sdf = TVoxel::floatToValue(newF); 24 | } 25 | 26 | template 27 | _CPU_AND_GPU_CODE_ inline void combineVoxelColorInformation(const CONSTPTR(TVoxel) & src, DEVICEPTR(TVoxel) & dst, int maxW) 28 | { 29 | int newW = dst.w_color; 30 | int oldW = src.w_color; 31 | Vector3f newC = dst.clr.toFloat() / 255.0f; 32 | Vector3f oldC = src.clr.toFloat() / 255.0f; 33 | 34 | if (oldW == 0) return; 35 | 36 | newC = oldC * (float)oldW + newC * (float)newW; 37 | newW = oldW + newW; 38 | newC /= (float)newW; 39 | newW = MIN(newW, maxW); 40 | 41 | dst.clr = TO_UCHAR3(newC * 255.0f); 42 | dst.w_color = (uchar)newW; 43 | } 44 | 45 | 46 | template struct CombineVoxelInformation; 47 | 48 | template 49 | struct CombineVoxelInformation { 50 | _CPU_AND_GPU_CODE_ static void compute(const CONSTPTR(TVoxel) & src, DEVICEPTR(TVoxel) & dst, int maxW) 51 | { 52 | combineVoxelDepthInformation(src, dst, maxW); 53 | } 54 | }; 55 | 56 | template 57 | struct CombineVoxelInformation { 58 | _CPU_AND_GPU_CODE_ static void compute(const CONSTPTR(TVoxel) & src, DEVICEPTR(TVoxel) & dst, int maxW) 59 | { 60 | combineVoxelDepthInformation(src, dst, maxW); 61 | combineVoxelColorInformation(src, dst, maxW); 62 | } 63 | }; 64 | 65 | -------------------------------------------------------------------------------- /MainLib/Engines/ViewBuilding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################ 2 | # ViewBuildingEngine LIBRARY # 3 | ############################ 4 | set(targetname ViewBuildingEngine) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | ADD_LIBRARY(${targetname} OBJECT ${${targetname}_sources} ${${targetname}_headers}) -------------------------------------------------------------------------------- /MainLib/Engines/ViewBuilding/ITMViewBuilderFactory.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #include "ITMViewBuilderFactory.h" 4 | 5 | #include "CPU/ITMViewBuilder_CPU.h" 6 | #ifndef COMPILE_WITHOUT_CUDA 7 | #include "CUDA/ITMViewBuilder_CUDA.h" 8 | #endif 9 | 10 | namespace ITMLib 11 | { 12 | 13 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 14 | 15 | ITMViewBuilder *ITMViewBuilderFactory::MakeViewBuilder(const ITMRGBDCalib& calib, ITMLibSettings::DeviceType deviceType) 16 | { 17 | ITMViewBuilder *viewBuilder = NULL; 18 | 19 | switch(deviceType) 20 | { 21 | case ITMLibSettings::DEVICE_CPU: 22 | viewBuilder = new ITMViewBuilder_CPU(calib); 23 | break; 24 | case ITMLibSettings::DEVICE_CUDA: 25 | #ifndef COMPILE_WITHOUT_CUDA 26 | viewBuilder = new ITMViewBuilder_CUDA(calib); 27 | #endif 28 | break; 29 | case ITMLibSettings::DEVICE_METAL: 30 | #ifdef COMPILE_WITH_METAL 31 | viewBuilder = new ITMViewBuilder_CPU(calib, label ); 32 | #endif 33 | break; 34 | } 35 | 36 | return viewBuilder; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /MainLib/Engines/ViewBuilding/ITMViewBuilderFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "Interface/ITMViewBuilder.h" 6 | #include "../../Utils/ITMLibSettings.h" 7 | 8 | namespace ITMLib 9 | { 10 | 11 | /** 12 | * \brief This struct provides functions that can be used to construct view builders. 13 | */ 14 | struct ITMViewBuilderFactory 15 | { 16 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 17 | 18 | /** 19 | * \brief Makes a view builder. 20 | * 21 | * \param calib The joint RGBD calibration parameters. 22 | * \param deviceType The device on which the view builder should operate. 23 | * \param label Enable labeling (segmentation) 24 | */ 25 | static ITMViewBuilder *MakeViewBuilder(const ITMRGBDCalib& calib, ITMLibSettings::DeviceType deviceType); 26 | }; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/CPU/ITMMultiVisualisationEngine_CPU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMMultiVisualisationEngine.h" 6 | 7 | namespace ITMLib 8 | { 9 | template 10 | class ITMMultiVisualisationEngine_CPU : public ITMMultiVisualisationEngine 11 | { 12 | public: 13 | ITMMultiVisualisationEngine_CPU(void) {} 14 | ~ITMMultiVisualisationEngine_CPU(void) {} 15 | 16 | ITMRenderState* CreateRenderState(const ITMScene *scene, const Vector2i & imgSize) const; 17 | 18 | void PrepareRenderState(const ITMVoxelMapGraphManager & sceneManager, ITMRenderState *state); 19 | 20 | void CreateExpectedDepths(const ORUtils::SE3Pose *pose, const ITMIntrinsics *intrinsics, ITMRenderState *renderState) const; 21 | 22 | void RenderImage(const ORUtils::SE3Pose *pose, const ITMIntrinsics *intrinsics, ITMRenderState *renderState, ITMUChar4Image *outputImage, IITMVisualisationEngine::RenderImageType type) const; 23 | }; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/CPUSurfelInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CPU/ITMSurfelVisualisationEngine_CPU.tpp" 4 | #include "CPU/ITMVisualisationEngine_CPU.tpp" 5 | #include "Interface/ITMSurfelVisualisationEngine.tpp" 6 | #include "ITMSurfelVisualisationEngineFactory.tpp" 7 | // Engines 8 | //template class ITMLib::ITMVisualisationEngine_CPU; 9 | template class ITMLib::ITMSurfelVisualisationEngine; 10 | template class ITMLib::ITMSurfelVisualisationEngine_CPU; 11 | template struct ITMLib::ITMSurfelVisualisationEngineFactory; -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/CPUVoxelInstantiations.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CPU/ITMVisualisationEngine_CPU.tpp" 4 | // Engines 5 | template class ITMLib::ITMVisualisationEngine_CPU; -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/CUDA/ITMMultiVisualisationEngine_CUDA.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMMultiVisualisationEngine.h" 6 | 7 | struct RenderingBlock; 8 | 9 | namespace ITMLib { 10 | 11 | template 12 | class ITMMultiVisualisationEngine_CUDA : public ITMMultiVisualisationEngine 13 | { 14 | private: 15 | RenderingBlock *renderingBlockList_device; 16 | uint *noTotalBlocks_device; 17 | 18 | public: 19 | ITMMultiVisualisationEngine_CUDA(void); 20 | ~ITMMultiVisualisationEngine_CUDA(void); 21 | 22 | ITMRenderState* CreateRenderState(const ITMScene *scene, const Vector2i & imgSize) const; 23 | 24 | void PrepareRenderState(const ITMVoxelMapGraphManager & sceneManager, ITMRenderState *state); 25 | 26 | void CreateExpectedDepths(const ORUtils::SE3Pose *pose, const ITMIntrinsics *intrinsics, ITMRenderState *renderState) const; 27 | 28 | void RenderImage(const ORUtils::SE3Pose *pose, const ITMIntrinsics *intrinsics, ITMRenderState *renderState, ITMUChar4Image *outputImage, IITMVisualisationEngine::RenderImageType type) const; 29 | }; 30 | } -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/CUDASurfelInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/ITMSurfelVisualisationEngine_CUDA.tcu" 4 | #include "CUDA/ITMVisualisationEngine_CUDA.tcu" 5 | 6 | // Engines 7 | //template class ITMLib::ITMVisualisationEngine_CUDA; 8 | template class ITMLib::ITMSurfelVisualisationEngine_CUDA; -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/CUDAVoxelInstantiations.cu: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #include "../../ITMLibDefines.h" 3 | #include "CUDA/ITMVisualisationEngine_CUDA.tcu" 4 | // Engines 5 | template class ITMLib::ITMVisualisationEngine_CUDA; -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/ITMMultiVisualisationEngineFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "CPU/ITMMultiVisualisationEngine_CPU.h" 6 | #ifndef COMPILE_WITHOUT_CUDA 7 | #include "CUDA/ITMMultiVisualisationEngine_CUDA.h" 8 | #endif 9 | #ifdef COMPILE_WITH_METAL 10 | //#include "Metal/ITMMultiVisualisationEngine_Metal.h" 11 | #endif 12 | 13 | namespace ITMLib 14 | { 15 | 16 | /** 17 | * \brief This struct provides functions that can be used to construct visualisation engines. 18 | */ 19 | struct ITMMultiVisualisationEngineFactory 20 | { 21 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 22 | 23 | /** 24 | * \brief Makes a visualisation engine. 25 | * 26 | * \param deviceType The device on which the visualisation engine should operate. 27 | */ 28 | template 29 | static ITMMultiVisualisationEngine *MakeVisualisationEngine(ITMLibSettings::DeviceType deviceType) 30 | { 31 | ITMMultiVisualisationEngine *visualisationEngine = NULL; 32 | 33 | switch (deviceType) 34 | { 35 | case ITMLibSettings::DEVICE_CPU: 36 | visualisationEngine = new ITMMultiVisualisationEngine_CPU; 37 | break; 38 | case ITMLibSettings::DEVICE_CUDA: 39 | #ifndef COMPILE_WITHOUT_CUDA 40 | visualisationEngine = new ITMMultiVisualisationEngine_CUDA; 41 | #endif 42 | break; 43 | case ITMLibSettings::DEVICE_METAL: 44 | #ifdef COMPILE_WITH_METAL 45 | visualisationEngine = new ITMMultiVisualisationEngine_CPU; 46 | #endif 47 | break; 48 | } 49 | 50 | return visualisationEngine; 51 | } 52 | }; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/ITMSurfelVisualisationEngineFactory.h: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #pragma once 4 | 5 | #include "Interface/ITMSurfelVisualisationEngine.h" 6 | #include "../../Utils/ITMLibSettings.h" 7 | 8 | namespace ITMLib 9 | { 10 | /** 11 | * \brief An instantiation of this struct can be used to construct surfel visualisation engines. 12 | */ 13 | template 14 | struct ITMSurfelVisualisationEngineFactory 15 | { 16 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 17 | 18 | /** 19 | * \brief Makes a surfel visualisation engine. 20 | * 21 | * \param deviceType The device on which the surfel visualisation engine should operate. 22 | * \return The surfel visualisation engine. 23 | */ 24 | static ITMSurfelVisualisationEngine *make_surfel_visualisation_engine(ITMLib::ITMLibSettings::DeviceType deviceType); 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/ITMSurfelVisualisationEngineFactory.tpp: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #include "ITMSurfelVisualisationEngineFactory.h" 4 | 5 | #include "CPU/ITMSurfelVisualisationEngine_CPU.h" 6 | 7 | #ifndef COMPILE_WITHOUT_CUDA 8 | #include "CUDA/ITMSurfelVisualisationEngine_CUDA.h" 9 | #endif 10 | 11 | namespace ITMLib 12 | { 13 | 14 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 15 | 16 | template 17 | ITMSurfelVisualisationEngine * 18 | ITMSurfelVisualisationEngineFactory::make_surfel_visualisation_engine(ITMLibSettings::DeviceType deviceType) 19 | { 20 | ITMSurfelVisualisationEngine *visualisationEngine = NULL; 21 | 22 | if(deviceType == ITMLibSettings::DEVICE_CUDA) 23 | { 24 | #ifndef COMPILE_WITHOUT_CUDA 25 | visualisationEngine = new ITMSurfelVisualisationEngine_CUDA; 26 | #else 27 | throw std::runtime_error("Error: CUDA support not currently available. Reconfigure in CMake with the WITH_CUDA option set to on."); 28 | #endif 29 | } 30 | else 31 | { 32 | visualisationEngine = new ITMSurfelVisualisationEngine_CPU; 33 | } 34 | 35 | return visualisationEngine; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/ITMVisualisationEngineFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "CPU/ITMVisualisationEngine_CPU.h" 6 | #ifndef COMPILE_WITHOUT_CUDA 7 | #include "CUDA/ITMVisualisationEngine_CUDA.h" 8 | #endif 9 | #ifdef COMPILE_WITH_METAL 10 | #include "Metal/ITMVisualisationEngine_Metal.h" 11 | #endif 12 | 13 | namespace ITMLib 14 | { 15 | 16 | /** 17 | * \brief This struct provides functions that can be used to construct visualisation engines. 18 | */ 19 | struct ITMVisualisationEngineFactory 20 | { 21 | //#################### PUBLIC STATIC MEMBER FUNCTIONS #################### 22 | 23 | /** 24 | * \brief Makes a visualisation engine. 25 | * 26 | * \param deviceType The device on which the visualisation engine should operate. 27 | */ 28 | template 29 | static ITMVisualisationEngine *MakeVisualisationEngine(ITMLibSettings::DeviceType deviceType) 30 | { 31 | ITMVisualisationEngine *visualisationEngine = NULL; 32 | 33 | switch(deviceType) 34 | { 35 | case ITMLibSettings::DEVICE_CPU: 36 | visualisationEngine = new ITMVisualisationEngine_CPU; 37 | break; 38 | case ITMLibSettings::DEVICE_CUDA: 39 | #ifndef COMPILE_WITHOUT_CUDA 40 | visualisationEngine = new ITMVisualisationEngine_CUDA; 41 | #endif 42 | break; 43 | case ITMLibSettings::DEVICE_METAL: 44 | #ifdef COMPILE_WITH_METAL 45 | visualisationEngine = new ITMVisualisationEngine_Metal; 46 | #endif 47 | break; 48 | } 49 | 50 | return visualisationEngine; 51 | } 52 | }; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/Interface/ITMMultiVisualisationEngine.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../MultiScene/ITMMapGraphManager.h" 6 | #include "../Interface/ITMVisualisationEngine.h" 7 | 8 | namespace ITMLib { 9 | 10 | template 11 | class ITMMultiVisualisationEngine 12 | { 13 | public: 14 | virtual ~ITMMultiVisualisationEngine(void) {} 15 | 16 | virtual ITMRenderState* CreateRenderState(const ITMScene *scene, const Vector2i & imgSize) const = 0; 17 | 18 | virtual void PrepareRenderState(const ITMVoxelMapGraphManager & sceneManager, ITMRenderState *state) = 0; 19 | 20 | //skip "FindVisibleBlocks" 21 | 22 | virtual void CreateExpectedDepths(const ORUtils::SE3Pose *pose, const ITMIntrinsics *intrinsics, ITMRenderState *renderState) const = 0; 23 | virtual void RenderImage(const ORUtils::SE3Pose *pose, const ITMIntrinsics *intrinsics, ITMRenderState *renderState, 24 | ITMUChar4Image *outputImage, IITMVisualisationEngine::RenderImageType type, IITMVisualisationEngine::RenderMode renderMode) const = 0; 25 | }; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/Metal/ITMVisualisationEngine_Metal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Isis Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #ifndef __METALC__ 6 | 7 | #include "../CPU/ITMVisualisationEngine_CPU.h" 8 | 9 | namespace ITMLib 10 | { 11 | template 12 | class ITMVisualisationEngine_Metal : public ITMVisualisationEngine_CPU < TVoxel, TIndex > 13 | { }; 14 | 15 | template 16 | class ITMVisualisationEngine_Metal : public ITMVisualisationEngine_CPU < TVoxel, ITMVoxelBlockHash > 17 | { 18 | public: 19 | void CreateICPMaps(const ITMScene *scene, const ITMView *view, ITMTrackingState *trackingState, ITMRenderState *renderState) const; 20 | void RenderImage(const ITMScene *scene, const ORUtils::SE3Pose *pose, const ITMIntrinsics *intrinsics, const ITMRenderState *renderState, 21 | ITMUChar4Image *outputImage, IITMVisualisationEngine::RenderImageType type = IITMVisualisationEngine::RENDER_SHADED_GREYSCALE, 22 | IITMVisualisationEngine::RenderRaycastSelection raycastType = IITMVisualisationEngine::RENDER_FROM_NEW_RAYCAST) const; 23 | 24 | ITMVisualisationEngine_Metal(); 25 | }; 26 | } 27 | 28 | #endif 29 | 30 | #if (defined __OBJC__) || (defined __METALC__) 31 | 32 | struct CreateICPMaps_Params 33 | { 34 | Matrix4f invM; 35 | Matrix4f M; 36 | Vector4f projParams; 37 | Vector4f invProjParams; 38 | Vector4f lightSource; 39 | Vector4i imgSize; 40 | Vector2f voxelSizes; 41 | }; 42 | 43 | #endif -------------------------------------------------------------------------------- /MainLib/Engines/Visualisation/Shared/ITMSurfelVisualisationEngine_Settings.h: -------------------------------------------------------------------------------- 1 | // InfiniTAM: Surffuse. Copyright (c) Torr Vision Group and the authors of InfiniTAM, 2016. 2 | 3 | #pragma once 4 | 5 | namespace ITMLib 6 | { 7 | 8 | /** 9 | * \brief The different types of lighting that can be used for surfel visualisation. 10 | * 11 | * FIXME: This is very similar to the LightingType enum in spaint - they should be combined one day. 12 | */ 13 | enum SurfelLightingType 14 | { 15 | SLT_FLAT, 16 | SLT_LAMBERTIAN, 17 | SLT_PHONG 18 | }; 19 | 20 | /** 21 | * \brief Whether or not to render unstable surfels. 22 | */ 23 | enum UnstableSurfelRenderingMode 24 | { 25 | /** Do not render unstable surfels. */ 26 | USR_DONOTRENDER, 27 | 28 | /** Render unstable surfels only if there is no stable surfel along the same ray. */ 29 | USR_FAUTEDEMIEUX, 30 | 31 | /** Render unstable surfels even if there is a stable surfel along the same ray. */ 32 | USR_RENDER, 33 | }; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /MainLib/ITMLibDefines.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "Objects/Scene/ITMPlainVoxelArray.h" 6 | #include "Objects/Scene/SCPlainVoxelArray.h" 7 | #include "Objects/Scene/ITMSurfelTypes.h" 8 | #include "Objects/Scene/ITMVoxelBlockHash.h" 9 | #include "Objects/Scene/ITMVoxelTypes.h" 10 | 11 | #include "Objects/Scene/IntegratePolicies.h" 12 | #include "Engines/SceneCompletion/FusionPolicies.h" 13 | 14 | /** This chooses the information stored at each surfel. At the moment, valid 15 | options are ITMSurfel_grey and ITMSurfel_rgb. 16 | */ 17 | #ifdef SURFELTYPE 18 | //typedef ITMLib::ITMSurfel_rgb ITMSurfelT; 19 | typedef SURFELTYPE ITMSurfelT; 20 | #endif 21 | 22 | /** This chooses the information stored at each voxel. At the moment, valid 23 | options are ITMVoxel_s, ITMVoxel_f, ITMVoxel_s_rgb and ITMVoxel_f_rgb. 24 | */ 25 | //typedef ITMVoxel_s ITMVoxel; 26 | //typedef ITMVoxel_s_label ITMVoxel; 27 | //typedef ITMVoxel_f_conf ITMVoxel; 28 | //typedef ITMVoxel_f_rgb ITMVoxel; 29 | 30 | //typedef OFu_Voxel_f_label ITMVoxel; 31 | //typedef TSDF_Voxel_f_label ITMVoxel; 32 | #ifdef VOXELTYPE 33 | typedef VOXELTYPE ITMVoxel; 34 | #endif 35 | 36 | /** This chooses the way the voxels are addressed and indexed. At the moment, 37 | valid options are ITMVoxelBlockHash and ITMPlainVoxelArray. 38 | */ 39 | typedef ITMLib::ITMVoxelBlockHash ITMVoxelIndex; 40 | //typedef ITMLib::ITMPlainVoxelArray ITMVoxelIndex; 41 | 42 | 43 | 44 | 45 | /// Below is to test warp policies along with ITMVoxel 46 | struct Policy_Direct_FuseAll 47 | { 48 | static const CONSTPTR(bool) hasSCFusionPolicy = true; 49 | static const SCFUSION::Policy::FuseTwo fusePolicy = SCFUSION::Policy::FuseTwo::FuseTwo_OCCUPIED; 50 | static const SCFUSION::Policy::Integrate integratePolicy = SCFUSION::Policy::Integrate_DIRECT; 51 | }; 52 | typedef Policy_Direct_FuseAll MappingPolicy; 53 | 54 | 55 | 56 | 57 | //template 58 | //struct Voxel_traits{ 59 | // static const MapPolicy Policy; 60 | // static const VoxelType Voxel; 61 | //}; 62 | //typedef Voxel_traits SCVoxelType; 63 | 64 | 65 | -------------------------------------------------------------------------------- /MainLib/MainEngine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SLAM_base) 2 | ADD_SUBDIRECTORY(SCFusion) 3 | -------------------------------------------------------------------------------- /MainLib/MainEngine/SCFusion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ### -- 3rd party 3 | SET(CUDA_NVCC_FLAGS) 4 | INCLUDE(${PROJECT_SOURCE_DIR}/cmake/UseCUDA.cmake) 5 | ####################################### SCFusion ############################################### 6 | set(targetname SCFUSION) 7 | 8 | file(GLOB headers *.hpp *.h) 9 | file(GLOB cuda src/*.cu) 10 | 11 | SET(${targetname}_sources 12 | SLAM.cpp 13 | ${cuda} 14 | ${glad} 15 | ) 16 | SET(${targetname}_headers 17 | ${headers} 18 | ) 19 | 20 | FOREACH(i RANGE ${VOXELCOUNTS} ) 21 | LIST(GET VOXELNAMES ${i} name) 22 | LIST(GET VOXELTYPES ${i} type) 23 | SET(FIELD_TYPE VOXELTYPE=${type}) 24 | SET(NAME_SUFFIX _${name}) 25 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 26 | ADD_LIBRARY(${targetname_suffix} 27 | ${${targetname}_sources} ${${targetname}_headers} 28 | ) 29 | 30 | TARGET_LINK_LIBRARIES(${targetname_suffix} 31 | PUBLIC MeshingEngine${NAME_SUFFIX} 32 | PUBLIC PointCloudEngine${NAME_SUFFIX} 33 | PUBLIC BasicSLAM${NAME_SUFFIX} 34 | PUBLIC SceneCompletion${NAME_SUFFIX} 35 | ) 36 | if(WITH_PYTORCH) 37 | target_link_libraries(${targetname_suffix} PRIVATE PytorchCppTools) 38 | endif() 39 | if(WITH_TENSORFLOW) 40 | target_link_libraries(${targetname_suffix} PUBLIC TFCppTools) 41 | endif() 42 | target_include_directories(${targetname_suffix} PUBLIC ../) 43 | SET_TARGET_PROPERTIES(${targetname_suffix} PROPERTIES CXX_STANDARD 14) 44 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 45 | ENDFOREACH() -------------------------------------------------------------------------------- /MainLib/MainEngine/SLAM_base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ### -- 3rd party 3 | INCLUDE(${PROJECT_SOURCE_DIR}/cmake/UseCUDA.cmake) 4 | ########################################################################################### 5 | set(targetname SLAMBase) 6 | 7 | file(GLOB srcs *.cpp *.tpp) 8 | file(GLOB headers *.hpp *.h) 9 | file(GLOB cuda src/*.cu) 10 | 11 | SET(${targetname}_sources 12 | ${srcs} 13 | ${cuda} 14 | ${glad} 15 | ) 16 | SET(${targetname}_headers 17 | ${headers} 18 | ) 19 | 20 | FOREACH(i RANGE ${VOXELCOUNTS} ) 21 | LIST(GET VOXELNAMES ${i} name) 22 | LIST(GET VOXELTYPES ${i} type) 23 | SET(FIELD_TYPE VOXELTYPE=${type}) 24 | SET(NAME_SUFFIX _${name}) 25 | SET(targetname_suffix ${targetname}${NAME_SUFFIX}) 26 | ADD_LIBRARY(${targetname_suffix} 27 | ${${targetname}_sources} ${${targetname}_headers} 28 | ) 29 | 30 | TARGET_LINK_LIBRARIES(${targetname_suffix} 31 | PUBLIC MeshingEngine${NAME_SUFFIX} 32 | PUBLIC PointCloudEngine${NAME_SUFFIX} 33 | PUBLIC BasicSLAM${NAME_SUFFIX} 34 | ) 35 | target_include_directories(${targetname_suffix} PUBLIC ../) 36 | TARGET_COMPILE_DEFINITIONS(${targetname_suffix} PUBLIC VOXELTYPE=${type}) 37 | ENDFOREACH() -------------------------------------------------------------------------------- /MainLib/Objects/Camera/ITMCalibIO.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "ITMRGBDCalib.h" 8 | 9 | namespace ITMLib 10 | { 11 | bool readIntrinsics(std::istream & src, ITMIntrinsics & dest); 12 | bool readIntrinsics(const char *fileName, ITMIntrinsics & dest); 13 | bool readExtrinsics(std::istream & src, ITMExtrinsics & dest); 14 | bool readExtrinsics(const char *fileName, ITMExtrinsics & dest); 15 | bool readDisparityCalib(std::istream & src, ITMDisparityCalib & dest); 16 | bool readDisparityCalib(const char *fileName, ITMDisparityCalib & dest); 17 | bool readDistortionCalib(std::istream & src, ITMDistortionCalib &dest); 18 | bool readDistortionCalib(const char *fileName, ITMDistortionCalib &dest); 19 | bool readRGBDCalib(std::istream & src, ITMRGBDCalib & dest); 20 | bool readRGBDCalib(const char *fileName, ITMRGBDCalib & dest); 21 | bool readRGBDCalib(const char *rgbIntrinsicsFile, const char *depthIntrinsicsFile, const char *disparityCalibFile, const char *extrinsicsFile, const char * distortionCalibFile, ITMRGBDCalib & dest); 22 | void writeIntrinsics(std::ostream & dest, const ITMIntrinsics & src); 23 | void writeExtrinsics(std::ostream & dest, const ITMExtrinsics & src); 24 | void writeDisparityCalib(std::ostream & dest, const ITMDisparityCalib & src); 25 | void writeRGBDCalib(std::ostream & dest, const ITMRGBDCalib & src); 26 | void writeRGBDCalib(const char *fileName, const ITMRGBDCalib & src); 27 | } 28 | -------------------------------------------------------------------------------- /MainLib/Objects/Camera/ITMDisparityCalib.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../Utils/ITMMath.h" 6 | 7 | namespace ITMLib 8 | { 9 | /** \brief 10 | Represents the calibration information to compute a depth 11 | image from the disparity image typically received from a 12 | Kinect. 13 | */ 14 | class ITMDisparityCalib 15 | { 16 | //#################### ENUMERATIONS #################### 17 | public: 18 | /** Type of transformation required to get from raw values to depths. */ 19 | enum TrafoType 20 | { 21 | /// Raw values are transformed according to \f$\frac{8c_2f_x}{c_1 - d}\f$ 22 | TRAFO_KINECT, 23 | /// Raw values are transformed according to \f$c_1 d + c_2\f$ 24 | TRAFO_AFFINE 25 | }; 26 | 27 | //#################### PRIVATE VARIABLES #################### 28 | private: 29 | TrafoType type; 30 | 31 | /** These are the actual parameters. */ 32 | Vector2f params; 33 | 34 | //#################### CONSTRUCTORS #################### 35 | public: 36 | ITMDisparityCalib(void) 37 | { 38 | SetStandard(); 39 | } 40 | 41 | //#################### PUBLIC MEMBER FUNCTIONS #################### 42 | public: 43 | const Vector2f& GetParams() const 44 | { 45 | return params; 46 | } 47 | 48 | TrafoType GetType() const 49 | { 50 | return type; 51 | } 52 | 53 | /** Setup from given arguments. */ 54 | void SetFrom(float a, float b, TrafoType _type) 55 | { 56 | if(a != 0.0f || b != 0.0f) 57 | { 58 | params.x = a; 59 | params.y = b; 60 | type = _type; 61 | } 62 | else SetStandard(); 63 | } 64 | 65 | /** Setup from standard arguments. */ 66 | void SetStandard() 67 | { 68 | // standard calibration parameters - converts mm to metres by dividing by 1000 69 | SetFrom(1.0f / 1000.0f, 0.0f, TRAFO_AFFINE); 70 | } 71 | }; 72 | } 73 | -------------------------------------------------------------------------------- /MainLib/Objects/Camera/ITMDistortionCalib.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../Utils/ITMMath.h" 6 | #include 7 | 8 | namespace ITMLib 9 | { 10 | /** \brief 11 | Represents the calibration information to compute a depth 12 | image from the disparity image typically received from a 13 | Kinect. 14 | */ 15 | class ITMDistortionCalib 16 | { 17 | //#################### ENUMERATIONS #################### 18 | public: 19 | 20 | 21 | //#################### PRIVATE VARIABLES #################### 22 | private: 23 | size_t num; 24 | 25 | /** These are the actual parameters. */ 26 | Vector8f params; 27 | 28 | //#################### CONSTRUCTORS #################### 29 | public: 30 | ITMDistortionCalib(void) 31 | { 32 | SetStandard(); 33 | } 34 | 35 | //#################### PUBLIC MEMBER FUNCTIONS #################### 36 | public: 37 | const Vector8f& GetParams() const 38 | { 39 | return params; 40 | } 41 | // Get the number of distortion calibration parameters 42 | size_t GetNum() const 43 | { 44 | return num; 45 | } 46 | 47 | void SetFrom(std::vector val) 48 | { 49 | if(val.size() > 8) { 50 | throw "size cannot excess 8\n"; 51 | } 52 | for(size_t i=0; icalib = src; 31 | this->calib_inv.setIdentity(); 32 | for (int r = 0; r < 3; ++r) for (int c = 0; c < 3; ++c) this->calib_inv.m[r+4*c] = this->calib.m[c+4*r]; 33 | for (int r = 0; r < 3; ++r) { 34 | float & dest = this->calib_inv.m[r+4*3]; 35 | dest = 0.0f; 36 | for (int c = 0; c < 3; ++c) dest -= this->calib.m[c+4*r] * this->calib.m[c+4*3]; 37 | } 38 | } 39 | 40 | ITMExtrinsics() 41 | { 42 | Matrix4f m; 43 | m.setZeros(); 44 | m.m00 = m.m11 = m.m22 = m.m33 = 1.0; 45 | SetFrom(m); 46 | } 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /MainLib/Objects/Camera/ITMRGBDCalib.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMIntrinsics.h" 6 | #include "ITMExtrinsics.h" 7 | #include "ITMDisparityCalib.h" 8 | #include "ITMDistortionCalib.h" 9 | 10 | namespace ITMLib 11 | { 12 | /** \brief 13 | Represents the joint RGBD calibration parameters 14 | */ 15 | class ITMRGBDCalib 16 | { 17 | public: 18 | /// Intrinsic parameters of the RGB camera. 19 | ITMIntrinsics intrinsics_rgb; 20 | 21 | /// Intrinsic parameters of the depth camera. 22 | ITMIntrinsics intrinsics_d; 23 | 24 | /** @brief 25 | Extrinsic calibration between RGB and depth 26 | cameras. 27 | 28 | This transformation takes points from the RGB 29 | camera coordinate system to the depth camera 30 | coordinate system. 31 | */ 32 | ITMExtrinsics trafo_rgb_to_depth; 33 | 34 | /// Calibration information to compute depth from disparity images. 35 | ITMDisparityCalib disparityCalib; 36 | 37 | /// Distortion information to un-distort the input image 38 | ITMDistortionCalib distortionCalib_rgb; 39 | ITMDistortionCalib distortionCalib_d; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /MainLib/Objects/Misc/ITMIMUMeasurement.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../Utils/ITMMath.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMIMUMeasurement 10 | { 11 | public: 12 | Matrix3f R; 13 | 14 | ITMIMUMeasurement() 15 | { 16 | this->R.setIdentity(); 17 | } 18 | 19 | ITMIMUMeasurement(const Matrix3f & R) 20 | { 21 | this->R = R; 22 | } 23 | 24 | void SetFrom(const ITMIMUMeasurement *measurement) 25 | { 26 | this->R = measurement->R; 27 | } 28 | 29 | ~ITMIMUMeasurement(void) { } 30 | 31 | // Suppress the default copy constructor and assignment operator 32 | ITMIMUMeasurement(const ITMIMUMeasurement&); 33 | ITMIMUMeasurement& operator=(const ITMIMUMeasurement&); 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /MainLib/Objects/Misc/ITMPointCloud.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../Utils/ITMMath.h" 6 | #include 7 | 8 | namespace ITMLib 9 | { 10 | class ITMPointCloud 11 | { 12 | public: 13 | uint noTotalPoints; 14 | 15 | ORUtils::Image *locations, *colours; 16 | 17 | explicit ITMPointCloud(Vector2i imgSize, MemoryDeviceType memoryType) 18 | { 19 | this->noTotalPoints = 0; 20 | 21 | locations = new ORUtils::Image(imgSize, memoryType); 22 | colours = new ORUtils::Image(imgSize, memoryType); 23 | } 24 | 25 | void UpdateHostFromDevice() 26 | { 27 | this->locations->UpdateHostFromDevice(); 28 | this->colours->UpdateHostFromDevice(); 29 | } 30 | 31 | void UpdateDeviceFromHost() 32 | { 33 | this->locations->UpdateDeviceFromHost(); 34 | this->colours->UpdateDeviceFromHost(); 35 | } 36 | 37 | ~ITMPointCloud() 38 | { 39 | delete locations; 40 | delete colours; 41 | } 42 | 43 | // Suppress the default copy constructor and assignment operator 44 | ITMPointCloud(const ITMPointCloud&); 45 | ITMPointCloud& operator=(const ITMPointCloud&); 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /MainLib/Objects/RenderStates/ITMRenderStateFactory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMRenderState_VH.h" 6 | #include "../../Utils/ITMSceneParams.h" 7 | 8 | namespace ITMLib 9 | { 10 | template 11 | struct ITMRenderStateFactory 12 | { 13 | /** Creates a render state, containing rendering info for the scene. */ 14 | static ITMRenderState *CreateRenderState(const Vector2i& imgSize, const ITMSceneParams *sceneParams, MemoryDeviceType memoryType) 15 | { 16 | return new ITMRenderState(imgSize, sceneParams->viewFrustum_min, sceneParams->viewFrustum_max, memoryType); 17 | } 18 | }; 19 | 20 | template <> 21 | struct ITMRenderStateFactory 22 | { 23 | /** Creates a render state, containing rendering info for the scene. */ 24 | static ITMRenderState *CreateRenderState(const Vector2i& imgSize, const ITMSceneParams *sceneParams, MemoryDeviceType memoryType) 25 | { 26 | return new ITMRenderState_VH(ITMVoxelBlockHash::noTotalEntries, imgSize, sceneParams->viewFrustum_min, sceneParams->viewFrustum_max, memoryType); 27 | } 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /MainLib/Objects/Scene/IntegratePolicies.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //#define LOGODD_MAX 12.787536f //34.7609869 3 | //#define LOGODD_MAX 34.7609869 4 | #define LOGODD_MAX 1000 5 | #define LOGODD_MIN -LOGODD_MAX 6 | #define LOGODD_OCU 1.2787536f //3.47609869 7 | //#define LOGODD_OCU 3.47609869 8 | #define LOGODD_ETY -LOGODD_OCU 9 | 10 | #define LOGODD_RATIO 0.80f 11 | #define LOGODD_BIAS 0.15f 12 | //#define LOGODD_SURFACE 2.9f // at around 0.95 probability. 13 | //#define LOGODD_SURFACE 0.5f // test 14 | //#define LOGODD_SURFACE 1.25f // test 15 | #define LOGODD_SURFACE 1e-3 // test 16 | 17 | #define measureW 2 18 | #define predictscW 1 19 | #define MaxLabelW 10.f 20 | 21 | namespace SCFUSION{ 22 | namespace Policy { 23 | enum Integrate { 24 | Integrate_WEIGHTED, Integrate_DIRECT 25 | }; 26 | }; 27 | } -------------------------------------------------------------------------------- /MainLib/Objects/Scene/VoxelIndexInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | namespace ITMLib { 6 | class VoxelIndex { 7 | public: 8 | explicit VoxelIndex(MemoryDeviceType memoryType) : memoryType(memoryType) {} 9 | 10 | virtual int getNumAllocatedVoxelBlocks() = 0; 11 | 12 | virtual int getVoxelBlockSize() = 0; 13 | 14 | virtual void SaveToDirectory(const std::string &outputDirectory) const = 0; 15 | 16 | virtual void LoadFromDirectory(const std::string &outputDirectory) = 0; 17 | 18 | protected: 19 | MemoryDeviceType memoryType{}; 20 | }; 21 | } -------------------------------------------------------------------------------- /MainLib/Objects/Tracking/ITMDepthHierarchyLevel.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "TrackerIterationType.h" 6 | #include "../../Utils/ITMMath.h" 7 | #include 8 | 9 | namespace ITMLib 10 | { 11 | class ITMDepthHierarchyLevel 12 | { 13 | public: 14 | int levelId; 15 | 16 | TrackerIterationType iterationType; 17 | 18 | ORUtils::Image *depth; 19 | 20 | Vector4f intrinsics; 21 | bool manageData; 22 | 23 | ITMDepthHierarchyLevel(Vector2i imgSize, int levelId, TrackerIterationType iterationType, 24 | MemoryDeviceType memoryType, bool skipAllocation = false) 25 | { 26 | this->manageData = !skipAllocation; 27 | this->levelId = levelId; 28 | this->iterationType = iterationType; 29 | 30 | if (!skipAllocation) 31 | { 32 | this->depth = new ORUtils::Image(imgSize, memoryType); 33 | } 34 | } 35 | 36 | void UpdateHostFromDevice() 37 | { 38 | this->depth->UpdateHostFromDevice(); 39 | } 40 | 41 | void UpdateDeviceFromHost() 42 | { 43 | this->depth->UpdateDeviceFromHost(); 44 | } 45 | 46 | ~ITMDepthHierarchyLevel(void) 47 | { 48 | if (manageData) 49 | { 50 | delete depth; 51 | } 52 | } 53 | 54 | // Suppress the default copy constructor and assignment operator 55 | ITMDepthHierarchyLevel(const ITMDepthHierarchyLevel&); 56 | ITMDepthHierarchyLevel& operator=(const ITMDepthHierarchyLevel&); 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /MainLib/Objects/Tracking/ITMImageHierarchy.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "TrackerIterationType.h" 6 | #include "../../Utils/ITMMath.h" 7 | #include 8 | 9 | namespace ITMLib 10 | { 11 | template class ITMImageHierarchy 12 | { 13 | private: 14 | int noLevels; 15 | T **levels; 16 | 17 | public: 18 | ITMImageHierarchy(Vector2i imgSize, TrackerIterationType *trackingRegime, int noHierarchyLevels, 19 | MemoryDeviceType memoryType, bool skipAllocationForLevel0 = false) 20 | { 21 | this->noLevels = noHierarchyLevels; 22 | 23 | levels = new T*[noHierarchyLevels]; 24 | 25 | for (int i = noHierarchyLevels - 1; i >= 0; i--) 26 | levels[i] = new T(imgSize, i, trackingRegime[i], memoryType, (i == 0) && skipAllocationForLevel0); 27 | } 28 | 29 | void UpdateHostFromDevice() 30 | { for (int i = 0; i < noLevels; i++) this->levels[i]->UpdateHostFromDevice(); } 31 | 32 | void UpdateDeviceFromHost() 33 | { for (int i = 0; i < noLevels; i++) this->levels[i]->UpdateDeviceFromHost(); } 34 | 35 | int GetNoLevels() const { return noLevels; } 36 | 37 | T * GetLevel(int level) const 38 | { 39 | return level >= 0 && level < noLevels ? levels[level] : NULL; 40 | } 41 | 42 | ~ITMImageHierarchy(void) 43 | { 44 | for (int i = 0; i < noLevels; i++) delete levels[i]; 45 | delete [] levels; 46 | } 47 | 48 | // Suppress the default copy constructor and assignment operator 49 | ITMImageHierarchy(const ITMImageHierarchy&); 50 | ITMImageHierarchy& operator=(const ITMImageHierarchy&); 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /MainLib/Objects/Tracking/ITMRGBHierarchyLevel.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "TrackerIterationType.h" 6 | #include "../../Utils/ITMMath.h" 7 | #include "../../../ORUtils/Image.h" 8 | 9 | namespace ITMLib 10 | { 11 | class ITMRGBHierarchyLevel 12 | { 13 | public: 14 | int levelId; 15 | 16 | TrackerIterationType iterationType; 17 | 18 | ORUtils::Image *rgb_current; 19 | 20 | ORUtils::Image *rgb_prev; 21 | ORUtils::Image *gX, *gY; 22 | Vector4f intrinsics; 23 | 24 | bool manageData; 25 | 26 | ITMRGBHierarchyLevel(Vector2i imgSize, int levelId, TrackerIterationType iterationType, 27 | MemoryDeviceType memoryType, bool skipAllocation = false) 28 | { 29 | this->manageData = !skipAllocation; 30 | this->levelId = levelId; 31 | this->iterationType = iterationType; 32 | 33 | if (!skipAllocation) 34 | { 35 | this->rgb_current = new ORUtils::Image(imgSize, memoryType); 36 | this->rgb_prev = new ORUtils::Image(imgSize, memoryType); 37 | } 38 | 39 | this->gX = new ORUtils::Image(imgSize, memoryType); 40 | this->gY = new ORUtils::Image(imgSize, memoryType); 41 | } 42 | 43 | void UpdateHostFromDevice() 44 | { 45 | this->rgb_current->UpdateHostFromDevice(); 46 | this->rgb_prev->UpdateHostFromDevice(); 47 | this->gX->UpdateHostFromDevice(); 48 | this->gY->UpdateHostFromDevice(); 49 | } 50 | 51 | void UpdateDeviceFromHost() 52 | { 53 | this->rgb_current->UpdateDeviceFromHost(); 54 | this->rgb_prev->UpdateDeviceFromHost(); 55 | this->gX->UpdateDeviceFromHost(); 56 | this->gY->UpdateDeviceFromHost(); 57 | } 58 | 59 | ~ITMRGBHierarchyLevel(void) 60 | { 61 | if (manageData) 62 | { 63 | delete rgb_current; 64 | delete rgb_prev; 65 | } 66 | 67 | delete gX; 68 | delete gY; 69 | } 70 | 71 | // Suppress the default copy constructor and assignment operator 72 | ITMRGBHierarchyLevel(const ITMRGBHierarchyLevel&); 73 | ITMRGBHierarchyLevel& operator=(const ITMRGBHierarchyLevel&); 74 | }; 75 | } 76 | -------------------------------------------------------------------------------- /MainLib/Objects/Tracking/ITMSceneHierarchyLevel.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "TrackerIterationType.h" 6 | #include "../../Utils/ITMMath.h" 7 | #include 8 | 9 | namespace ITMLib 10 | { 11 | class ITMSceneHierarchyLevel 12 | { 13 | public: 14 | int levelId; 15 | 16 | TrackerIterationType iterationType; 17 | 18 | ORUtils::Image *pointsMap; 19 | ORUtils::Image *normalsMap; 20 | Vector4f intrinsics; 21 | 22 | bool manageData; 23 | 24 | ITMSceneHierarchyLevel(Vector2i imgSize, int levelId, TrackerIterationType iterationType, MemoryDeviceType memoryType, bool skipAllocation = false) 25 | { 26 | this->manageData = !skipAllocation; 27 | this->levelId = levelId; 28 | this->iterationType = iterationType; 29 | 30 | if (!skipAllocation) { 31 | this->pointsMap = new ORUtils::Image(imgSize, memoryType); 32 | this->normalsMap = new ORUtils::Image(imgSize, memoryType); 33 | } 34 | } 35 | 36 | void UpdateHostFromDevice() 37 | { 38 | this->pointsMap->UpdateHostFromDevice(); 39 | this->normalsMap->UpdateHostFromDevice(); 40 | } 41 | 42 | void UpdateDeviceFromHost() 43 | { 44 | this->pointsMap->UpdateDeviceFromHost(); 45 | this->normalsMap->UpdateDeviceFromHost(); 46 | } 47 | 48 | ~ITMSceneHierarchyLevel(void) 49 | { 50 | if (manageData) { 51 | delete pointsMap; 52 | delete normalsMap; 53 | } 54 | } 55 | 56 | // Suppress the default copy constructor and assignment operator 57 | ITMSceneHierarchyLevel(const ITMSceneHierarchyLevel&); 58 | ITMSceneHierarchyLevel& operator=(const ITMSceneHierarchyLevel&); 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /MainLib/Objects/Tracking/ITMTemplatedHierarchyLevel.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "TrackerIterationType.h" 6 | #include "../../Utils/ITMMath.h" 7 | #include 8 | 9 | namespace ITMLib 10 | { 11 | template 12 | class ITMTemplatedHierarchyLevel 13 | { 14 | public: 15 | int levelId; 16 | 17 | TrackerIterationType iterationType; 18 | 19 | ImageType *data; 20 | 21 | Vector4f intrinsics; 22 | bool manageData; 23 | 24 | ITMTemplatedHierarchyLevel(Vector2i imgSize, int levelId, TrackerIterationType iterationType, 25 | MemoryDeviceType memoryType, bool skipAllocation = false) 26 | { 27 | this->manageData = !skipAllocation; 28 | this->levelId = levelId; 29 | this->iterationType = iterationType; 30 | 31 | if (!skipAllocation) this->data = new ImageType(imgSize, memoryType); 32 | } 33 | 34 | void UpdateHostFromDevice() 35 | { 36 | this->data->UpdateHostFromDevice(); 37 | } 38 | 39 | void UpdateDeviceFromHost() 40 | { 41 | this->data->UpdateDeviceFromHost(); 42 | } 43 | 44 | ~ITMTemplatedHierarchyLevel(void) 45 | { 46 | if (manageData) delete data; 47 | } 48 | 49 | // Suppress the default copy constructor and assignment operator 50 | ITMTemplatedHierarchyLevel(const ITMTemplatedHierarchyLevel&); 51 | ITMTemplatedHierarchyLevel& operator=(const ITMTemplatedHierarchyLevel&); 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /MainLib/Objects/Tracking/ITMViewHierarchyLevel.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "TrackerIterationType.h" 6 | #include "../../Utils/ITMMath.h" 7 | #include 8 | 9 | namespace ITMLib 10 | { 11 | class ITMViewHierarchyLevel 12 | { 13 | public: 14 | int levelId; 15 | 16 | TrackerIterationType iterationType; 17 | 18 | ORUtils::Image *rgb; ORUtils::Image *depth; 19 | ORUtils::Image *gradientX_rgb, *gradientY_rgb; 20 | Vector4f intrinsics; 21 | 22 | bool manageData; 23 | 24 | ITMViewHierarchyLevel(Vector2i imgSize, int levelId, TrackerIterationType iterationType, MemoryDeviceType memoryType, bool skipAllocation) 25 | { 26 | this->manageData = !skipAllocation; 27 | this->levelId = levelId; 28 | this->iterationType = iterationType; 29 | 30 | if (!skipAllocation) { 31 | this->rgb = new ORUtils::Image(imgSize, memoryType); 32 | this->depth = new ORUtils::Image(imgSize, memoryType); 33 | this->gradientX_rgb = new ORUtils::Image(imgSize, memoryType); 34 | this->gradientY_rgb = new ORUtils::Image(imgSize, memoryType); 35 | } 36 | } 37 | 38 | void UpdateHostFromDevice() 39 | { 40 | this->rgb->UpdateHostFromDevice(); 41 | this->depth->UpdateHostFromDevice(); 42 | this->gradientX_rgb->UpdateHostFromDevice(); 43 | this->gradientY_rgb->UpdateHostFromDevice(); 44 | } 45 | 46 | void UpdateDeviceFromHost() 47 | { 48 | this->rgb->UpdateDeviceFromHost(); 49 | this->depth->UpdateDeviceFromHost(); 50 | this->gradientX_rgb->UpdateDeviceFromHost(); 51 | this->gradientY_rgb->UpdateDeviceFromHost(); 52 | } 53 | 54 | ~ITMViewHierarchyLevel(void) 55 | { 56 | if (manageData) { 57 | delete rgb; 58 | delete depth; 59 | delete gradientX_rgb; delete gradientY_rgb; 60 | } 61 | } 62 | 63 | // Suppress the default copy constructor and assignment operator 64 | ITMViewHierarchyLevel(const ITMViewHierarchyLevel&); 65 | ITMViewHierarchyLevel& operator=(const ITMViewHierarchyLevel&); 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /MainLib/Objects/Tracking/TrackerIterationType.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | namespace ITMLib 6 | { 7 | /// The tracker iteration type used to define the tracking iteration regime 8 | enum TrackerIterationType 9 | { 10 | TRACKER_ITERATION_ROTATION, 11 | TRACKER_ITERATION_TRANSLATION, 12 | TRACKER_ITERATION_BOTH, 13 | TRACKER_ITERATION_NONE 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /MainLib/Objects/Views/ITMViewIMU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMView.h" 6 | #include "../Misc/ITMIMUMeasurement.h" 7 | 8 | namespace ITMLib 9 | { 10 | /** \brief 11 | Represents a single "view", i.e. RGB and depth images along 12 | with all intrinsic and relative calibration information 13 | */ 14 | class ITMViewIMU : public ITMView 15 | { 16 | public: 17 | ITMIMUMeasurement *imu; 18 | 19 | ITMViewIMU(const ITMRGBDCalib& calibration, Vector2i imgSize_rgb, Vector2i imgSize_d, bool useGPU) 20 | : ITMView(calibration, imgSize_rgb, imgSize_d, useGPU) 21 | { 22 | imu = new ITMIMUMeasurement(); 23 | } 24 | 25 | ~ITMViewIMU(void) { delete imu; } 26 | 27 | // Suppress the default copy constructor and assignment operator 28 | ITMViewIMU(const ITMViewIMU&); 29 | ITMViewIMU& operator=(const ITMViewIMU&); 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /MainLib/Trackers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ########################## 2 | # LowLevelEngine LIBRARY # 3 | ########################## 4 | set(targetname TrackingEngine) 5 | file(GLOB_RECURSE ${targetname}_headers *.h) 6 | file(GLOB_RECURSE ${targetname}_sources 7 | *.c 8 | *.cpp 9 | *.cu 10 | *.tpp 11 | *.tcu) 12 | 13 | ADD_LIBRARY(${targetname} OBJECT ${${targetname}_sources} ${${targetname}_headers}) 14 | TARGET_LINK_LIBRARIES(${targetname} 15 | PUBLIC ITMObjects 16 | PUBLIC ITMUtils 17 | ) 18 | -------------------------------------------------------------------------------- /MainLib/Trackers/CPU/ITMColorTracker_CPU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMColorTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMColorTracker_CPU : public ITMColorTracker 10 | { 11 | public: 12 | int F_oneLevel(float *f, ORUtils::SE3Pose *pose); 13 | void G_oneLevel(float *gradient, float *hessian, ORUtils::SE3Pose *pose) const; 14 | 15 | ITMColorTracker_CPU(Vector2i imgSize, TrackerIterationType *trackingRegime, int noHierarchyLevels, 16 | const ITMLowLevelEngine *lowLevelEngine); 17 | ~ITMColorTracker_CPU(void); 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /MainLib/Trackers/CPU/ITMDepthTracker_CPU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMDepthTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMDepthTracker_CPU : public ITMDepthTracker 10 | { 11 | protected: 12 | int ComputeGandH(float &f, float *nabla, float *hessian, Matrix4f approxInvPose); 13 | 14 | public: 15 | ITMDepthTracker_CPU(Vector2i imgSize, TrackerIterationType *trackingRegime, int noHierarchyLevels, 16 | float terminationThreshold, float failureDetectorThreshold, const ITMLowLevelEngine *lowLevelEngine); 17 | ~ITMDepthTracker_CPU(void); 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /MainLib/Trackers/CPU/ITMExtendedTracker_CPU.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMExtendedTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMExtendedTracker_CPU : public ITMExtendedTracker 10 | { 11 | protected: 12 | int ComputeGandH_Depth(float &f, float *nabla, float *hessian, Matrix4f approxInvPose); 13 | int ComputeGandH_RGB(float &f, float *nabla, float *hessian, Matrix4f approxInvPose); 14 | void ProjectCurrentIntensityFrame(ITMFloat4Image *points_out, 15 | ITMFloatImage *intensity_out, 16 | const ITMFloatImage *intensity_in, 17 | const ITMFloatImage *depth_in, 18 | const Vector4f &intrinsics_depth, 19 | const Vector4f &intrinsics_rgb, 20 | const Matrix4f &scenePose); 21 | 22 | public: 23 | ITMExtendedTracker_CPU(Vector2i imgSize_d, 24 | Vector2i imgSize_rgb, 25 | bool useDepth, 26 | bool useColour, 27 | float colourWeight, 28 | TrackerIterationType *trackingRegime, 29 | int noHierarchyLevels, 30 | float terminationThreshold, 31 | float failureDetectorThreshold, 32 | float viewFrustum_min, 33 | float viewFrustum_max, 34 | float minColourGradient, 35 | float tukeyCutOff, 36 | int framesToSkip, 37 | int framesToWeight, 38 | const ITMLowLevelEngine *lowLevelEngine); 39 | ~ITMExtendedTracker_CPU(void); 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /MainLib/Trackers/CUDA/ITMColorTracker_CUDA.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMColorTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMColorTracker_CUDA : public ITMColorTracker 10 | { 11 | private: 12 | Vector2f *f_device; float *g_device, *h_device; 13 | Vector2f *f_host; float *g_host, *h_host; 14 | 15 | public: 16 | int F_oneLevel(float *f, ORUtils::SE3Pose *pose); 17 | void G_oneLevel(float *gradient, float *hessian, ORUtils::SE3Pose *pose) const; 18 | 19 | ITMColorTracker_CUDA(Vector2i imgSize, TrackerIterationType *trackingRegime, int noHierarchyLevels, 20 | const ITMLowLevelEngine *lowLevelEngine); 21 | ~ITMColorTracker_CUDA(void); 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /MainLib/Trackers/CUDA/ITMDepthTracker_CUDA.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMDepthTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMDepthTracker_CUDA : public ITMDepthTracker 10 | { 11 | public: 12 | struct AccuCell; 13 | 14 | private: 15 | AccuCell *accu_host; 16 | AccuCell *accu_device; 17 | 18 | protected: 19 | int ComputeGandH(float &f, float *nabla, float *hessian, Matrix4f approxInvPose); 20 | 21 | public: 22 | ITMDepthTracker_CUDA(Vector2i imgSize, TrackerIterationType *trackingRegime, int noHierarchyLevels, 23 | float terminationThreshold, float failureDetectorThreshold, const ITMLowLevelEngine *lowLevelEngine); 24 | ~ITMDepthTracker_CUDA(void); 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /MainLib/Trackers/CUDA/ITMExtendedTracker_CUDA.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../Interface/ITMExtendedTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | class ITMExtendedTracker_CUDA : public ITMExtendedTracker 10 | { 11 | public: 12 | struct AccuCell; 13 | 14 | private: 15 | AccuCell *accu_host; 16 | AccuCell *accu_device; 17 | 18 | protected: 19 | int ComputeGandH_Depth(float &f, float *nabla, float *hessian, Matrix4f approxInvPose); 20 | int ComputeGandH_RGB(float &f, float *nabla, float *hessian, Matrix4f approxInvPose); 21 | void ProjectCurrentIntensityFrame(ITMFloat4Image *points_out, 22 | ITMFloatImage *intensity_out, 23 | const ITMFloatImage *intensity_in, 24 | const ITMFloatImage *depth_in, 25 | const Vector4f &intrinsics_depth, 26 | const Vector4f &intrinsics_rgb, 27 | const Matrix4f &scenePose); 28 | 29 | public: 30 | ITMExtendedTracker_CUDA(Vector2i imgSize_d, 31 | Vector2i imgSize_rgb, 32 | bool useDepth, 33 | bool useColour, 34 | float colourWeight, 35 | TrackerIterationType *trackingRegime, 36 | int noHierarchyLevels, 37 | float terminationThreshold, 38 | float failureDetectorThreshold, 39 | float viewFrustum_min, 40 | float viewFrustum_max, 41 | float minColourGradient, 42 | float tukeyCutOff, 43 | int framesToSkip, 44 | int framesToWeight, 45 | const ITMLowLevelEngine *lowLevelEngine); 46 | ~ITMExtendedTracker_CUDA(void); 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /MainLib/Trackers/Interface/ITMFileBasedTracker.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #include "ITMFileBasedTracker.h" 4 | 5 | #include 6 | #include 7 | 8 | namespace ITMLib { 9 | 10 | ITMFileBasedTracker::ITMFileBasedTracker(const std::string &poseMask_, size_t initialFrameNo_) : 11 | poseMask(poseMask_), 12 | frameCount(initialFrameNo_) 13 | {} 14 | 15 | bool ITMFileBasedTracker::CanKeepTracking() const 16 | { 17 | std::ifstream poseFile(GetCurrentFilename().c_str()); 18 | return poseFile.is_open(); 19 | } 20 | 21 | void ITMFileBasedTracker::TrackCamera(ITMTrackingState *trackingState, const ITMView *view) 22 | { 23 | trackingState->trackerResult = ITMTrackingState::TRACKING_FAILED; 24 | 25 | // Try to open the file 26 | std::ifstream poseFile(GetCurrentFilename().c_str()); 27 | 28 | // Always increment frameCount, this allows skipping missing files that could correspond 29 | // to frames where tracking failed during capture. 30 | ++frameCount; 31 | 32 | // File not found, signal tracking failure. 33 | if (!poseFile) 34 | { 35 | return; 36 | } 37 | 38 | Matrix4f invPose; 39 | 40 | // Matrix is column-major 41 | poseFile >> invPose.m00 >> invPose.m10 >> invPose.m20 >> invPose.m30 42 | >> invPose.m01 >> invPose.m11 >> invPose.m21 >> invPose.m31 43 | >> invPose.m02 >> invPose.m12 >> invPose.m22 >> invPose.m32 44 | >> invPose.m03 >> invPose.m13 >> invPose.m23 >> invPose.m33; 45 | 46 | if (poseFile) 47 | { 48 | // No read errors, tracking is assumed good 49 | trackingState->trackerResult = ITMTrackingState::TRACKING_GOOD; 50 | trackingState->pose_d->SetInvM(invPose); 51 | } 52 | } 53 | 54 | std::string ITMFileBasedTracker::GetCurrentFilename() const 55 | { 56 | // Fill the mask 57 | static const int BUF_SIZE = 2048; // Same as InputSource 58 | char framePoseFilename[BUF_SIZE]; 59 | sprintf(framePoseFilename, poseMask.c_str(), frameCount); 60 | return framePoseFilename; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /MainLib/Trackers/Interface/ITMFileBasedTracker.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | /** 10 | * \brief Tracker that reads precomputed poses from text files. 11 | */ 12 | class ITMFileBasedTracker : public ITMTracker 13 | { 14 | private: 15 | std::string poseMask; 16 | size_t frameCount; 17 | 18 | public: 19 | bool CanKeepTracking() const; 20 | void TrackCamera(ITMTrackingState *trackingState, const ITMView *view); 21 | 22 | bool requiresColourRendering() const { return false; } 23 | bool requiresDepthReliability() const { return false; } 24 | bool requiresPointCloudRendering() const { return false; } 25 | 26 | explicit ITMFileBasedTracker(const std::string &poseMask, size_t initialFrameNo = 0); 27 | 28 | private: 29 | std::string GetCurrentFilename() const; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /MainLib/Trackers/Interface/ITMForceFailTracker.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #include "ITMForceFailTracker.h" 4 | 5 | namespace ITMLib 6 | { 7 | 8 | //#################### PUBLIC MEMBER FUNCTIONS #################### 9 | 10 | void ITMForceFailTracker::TrackCamera(ITMTrackingState *trackingState, const ITMView *view) 11 | { 12 | trackingState->trackerResult = ITMTrackingState::TRACKING_FAILED; 13 | } 14 | 15 | bool ITMForceFailTracker::requiresColourRendering() const 16 | { 17 | return false; 18 | } 19 | 20 | bool ITMForceFailTracker::requiresDepthReliability() const 21 | { 22 | return false; 23 | } 24 | 25 | bool ITMForceFailTracker::requiresPointCloudRendering() const 26 | { 27 | return false; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /MainLib/Trackers/Interface/ITMForceFailTracker.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMTracker.h" 6 | 7 | namespace ITMLib 8 | { 9 | /** 10 | * \brief An instance of this class can be used to force tracking failure, 11 | * e.g. when testing a relocaliser. 12 | */ 13 | class ITMForceFailTracker : public ITMTracker 14 | { 15 | //#################### PUBLIC MEMBER FUNCTIONS #################### 16 | public: 17 | /** Override */ 18 | virtual void TrackCamera(ITMTrackingState *trackingState, const ITMView *view); 19 | 20 | /** Override */ 21 | virtual bool requiresColourRendering() const; 22 | 23 | /** Override */ 24 | virtual bool requiresDepthReliability() const; 25 | 26 | /** Override */ 27 | virtual bool requiresPointCloudRendering() const; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /MainLib/Trackers/Interface/ITMIMUTracker.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #include "ITMIMUTracker.h" 4 | 5 | #include "../../Objects/Views/ITMViewIMU.h" 6 | using namespace ITMLib; 7 | 8 | ITMIMUTracker::ITMIMUTracker(ITMIMUCalibrator *calibrator) 9 | { 10 | this->calibrator = calibrator; 11 | } 12 | 13 | ITMIMUTracker::~ITMIMUTracker(void) 14 | { 15 | } 16 | 17 | void ITMIMUTracker::TrackCamera(ITMTrackingState *trackingState, const ITMView *view) 18 | { 19 | calibrator->RegisterMeasurement(((ITMViewIMU*)view)->imu->R); 20 | 21 | trackingState->pose_d->SetR(calibrator->GetDifferentialRotationChange() * trackingState->pose_d->GetR()); 22 | } 23 | -------------------------------------------------------------------------------- /MainLib/Trackers/Interface/ITMIMUTracker.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMTracker.h" 6 | #include "../../Engines/LowLevel/Interface/ITMLowLevelEngine.h" 7 | #include "../../Objects/Misc/ITMIMUCalibrator.h" 8 | #include "../../Objects/Misc/ITMIMUMeasurement.h" 9 | 10 | namespace ITMLib 11 | { 12 | class ITMIMUTracker : public ITMTracker 13 | { 14 | private: 15 | ITMIMUCalibrator *calibrator; 16 | 17 | public: 18 | void TrackCamera(ITMTrackingState *trackingState, const ITMView *view); 19 | bool requiresColourRendering() const { return false; } 20 | bool requiresDepthReliability() const { return false; } 21 | bool requiresPointCloudRendering() const { return false; } 22 | 23 | ITMIMUTracker(ITMIMUCalibrator *calibrator); 24 | virtual ~ITMIMUTracker(void); 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /MainLib/Trackers/Interface/ITMTracker.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "../../Objects/Tracking/ITMTrackingState.h" 6 | #include "../../Objects/Views/ITMView.h" 7 | 8 | namespace ITMLib 9 | { 10 | /** \brief 11 | Basic interface to any sort of trackers that will align an 12 | incoming view with an existing scene. 13 | */ 14 | class ITMTracker 15 | { 16 | public: 17 | /** Gets whether the tracker can keep tracking or not. 18 | Can be used to signal e.g. the end of a sequence 19 | of file-based poses, or the failure of an IMU. 20 | */ 21 | virtual bool CanKeepTracking() const { return true; } 22 | 23 | /** Localize a View in the given scene. The result is 24 | currently stored as an attribute in trackingState. 25 | */ 26 | virtual void TrackCamera(ITMTrackingState *trackingState, const ITMView *view) = 0; 27 | 28 | /** Updates the initial pose of the depth camera in the scene. 29 | This can be used to make the scene up vector correspond 30 | to the real world's up direction. 31 | */ 32 | virtual void UpdateInitialPose(ITMTrackingState *trackingState) {} 33 | 34 | virtual bool requiresColourRendering() const = 0; 35 | virtual bool requiresDepthReliability() const = 0; 36 | virtual bool requiresPointCloudRendering() const = 0; 37 | 38 | virtual ~ITMTracker(void) {} 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /MainLib/Utils/Exceptions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | namespace SCFUSION { 6 | class ERROR_NotImplemented : public std::logic_error { 7 | public: 8 | explicit ERROR_NotImplemented(const std::string &functionName = "") : std::logic_error(functionName + " Function not yet implemented") {}; 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /MainLib/Utils/ITMImageTypes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMMath.h" 6 | #include 7 | 8 | typedef ORUtils::Image ITMBoolImage; 9 | typedef ORUtils::Image ITMFloatImage; 10 | typedef ORUtils::Image ITMFloat2Image; 11 | typedef ORUtils::Image ITMFloat3Image; 12 | typedef ORUtils::Image ITMFloat4Image; 13 | typedef ORUtils::Image ITMIntImage; 14 | typedef ORUtils::Image ITMInt2Image; 15 | typedef ORUtils::Image ITMInt3Image; 16 | typedef ORUtils::Image ITMInt4Image; 17 | typedef ORUtils::Image ITMShortImage; 18 | typedef ORUtils::Image ITMShort2Image; 19 | typedef ORUtils::Image ITMShort3Image; 20 | typedef ORUtils::Image ITMShort4Image; 21 | typedef ORUtils::Image ITMUCharImage; 22 | typedef ORUtils::Image ITMUChar4Image; 23 | typedef ORUtils::Image ITMUChar3Image; 24 | typedef ORUtils::Image ITMUIntImage; 25 | typedef ORUtils::Image ITMUShortImage; -------------------------------------------------------------------------------- /MainLib/Utils/ITMLibSettings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMSceneParams.h" 6 | #include "ITMSurfelSceneParams.h" 7 | #include "SceneCompletionParams.h" 8 | #include 9 | 10 | 11 | 12 | namespace ITMLib 13 | { 14 | class ITMLibSettings 15 | { 16 | public: 17 | /// The device used to run the DeviceAgnostic code 18 | typedef enum { 19 | DEVICE_CPU, 20 | DEVICE_CUDA, 21 | DEVICE_METAL 22 | } DeviceType; 23 | 24 | typedef enum 25 | { 26 | FAILUREMODE_RELOCALISE, 27 | FAILUREMODE_IGNORE, 28 | FAILUREMODE_STOP_INTEGRATION 29 | } FailureMode; 30 | 31 | typedef enum 32 | { 33 | SWAPPINGMODE_DISABLED, 34 | SWAPPINGMODE_ENABLED, 35 | SWAPPINGMODE_DELETE 36 | } SwappingMode; 37 | 38 | typedef enum 39 | { 40 | LIBMODE_BASIC, 41 | LIBMODE_BASIC_SURFELS, 42 | LIBMODE_LOOPCLOSURE 43 | } LibMode; 44 | 45 | /// Select the type of device to use 46 | DeviceType deviceType; 47 | /// Use Scene Complete 48 | bool useSC; 49 | /// Skip Input Frame. Image counter % useSkipFrame == 0? fuse : skip 50 | int useSkipFrame; 51 | 52 | bool useApproximateRaycast; 53 | 54 | bool useBilateralFilter; 55 | 56 | /// For ITMColorTracker: skip every other point in energy function evaluation. 57 | bool skipPoints; 58 | 59 | bool createMeshingEngine; 60 | 61 | bool createPointExtractionEngine; 62 | 63 | FailureMode behaviourOnFailure; 64 | SwappingMode swappingMode; 65 | LibMode libMode; 66 | 67 | std::string trackerConfig; 68 | 69 | std::string labelColorPath; 70 | 71 | /// Further, scene specific parameters such as voxel size 72 | ITMSceneParams sceneParams; 73 | ITMSurfelSceneParams surfelSceneParams; 74 | SCFUSION::SceneCompletionParams scParams; 75 | 76 | ITMLibSettings(); 77 | virtual ~ITMLibSettings() {} 78 | 79 | // Suppress the default copy constructor and assignment operator 80 | ITMLibSettings(const ITMLibSettings&); 81 | ITMLibSettings& operator=(const ITMLibSettings&); 82 | 83 | MemoryDeviceType GetMemoryType() const; 84 | 85 | 86 | }; 87 | } 88 | -------------------------------------------------------------------------------- /MainLib/Utils/ITMMemoryBlockTypes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | 5 | #include "ITMMath.h" 6 | #include "../../ORUtils/MemoryBlock.h" 7 | 8 | typedef ORUtils::MemoryBlock ITMBoolMemoryBlock; 9 | typedef ORUtils::MemoryBlock ITMFloatMemoryBlock; 10 | typedef ORUtils::MemoryBlock ITMFloat2MemoryBlock; 11 | typedef ORUtils::MemoryBlock ITMFloat3MemoryBlock; 12 | typedef ORUtils::MemoryBlock ITMFloat4MemoryBlock; 13 | typedef ORUtils::MemoryBlock ITMIntMemoryBlock; 14 | typedef ORUtils::MemoryBlock ITMInt2MemoryBlock; 15 | typedef ORUtils::MemoryBlock ITMInt3MemoryBlock; 16 | typedef ORUtils::MemoryBlock ITMInt4MemoryBlock; 17 | typedef ORUtils::MemoryBlock ITMShortMemoryBlock; 18 | typedef ORUtils::MemoryBlock ITMShort2MemoryBlock; 19 | typedef ORUtils::MemoryBlock ITMShort3MemoryBlock; 20 | typedef ORUtils::MemoryBlock ITMShort4MemoryBlock; 21 | typedef ORUtils::MemoryBlock ITMUCharMemoryBlock; 22 | typedef ORUtils::MemoryBlock ITMUChar4MemoryBlock; 23 | typedef ORUtils::MemoryBlock ITMUIntMemoryBlock; 24 | typedef ORUtils::MemoryBlock ITMUShortMemoryBlock; 25 | -------------------------------------------------------------------------------- /MainLib/Utils/ITMProjectionUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | 3 | #pragma once 4 | #ifndef __METALC__ 5 | #include 6 | #endif 7 | 8 | #include "ITMMath.h" 9 | #include 10 | 11 | template _CPU_AND_GPU_CODE_ inline Vector2f project(const THREADPTR(ORUtils::Vector3) &point_3d, const THREADPTR(Vector4f) &intrinsics) 12 | { 13 | return Vector2f(intrinsics.x * (float)point_3d.x / (float)point_3d.z + intrinsics.z, 14 | intrinsics.y * (float)point_3d.y / (float)point_3d.z + intrinsics.w); 15 | } 16 | 17 | template _CPU_AND_GPU_CODE_ inline Vector3f unproject(const THREADPTR(ORUtils::Vector2) &point_2d, const THREADPTR(float) depth, const THREADPTR(Vector4f) &intrinsics) 18 | { 19 | return Vector3f(depth * (((float)point_2d.x - intrinsics.z) / intrinsics.x), 20 | depth * (((float)point_2d.y - intrinsics.w) / intrinsics.y), 21 | depth); 22 | } 23 | 24 | template _CPU_AND_GPU_CODE_ inline Vector3f unproject(const THREADPTR(T) x, const THREADPTR(T) y, const THREADPTR(float) depth, const THREADPTR(Vector4f) &intrinsics) 25 | { 26 | return Vector3f(depth * (((float)x - intrinsics.z) / intrinsics.x), 27 | depth * (((float)y - intrinsics.w) / intrinsics.y), 28 | depth); 29 | } 30 | -------------------------------------------------------------------------------- /MainLib/Utils/LibSettingsIO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ITMLibSettings.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //#include "../../Utilities/include/Utilities/Exception.hpp" 11 | 12 | namespace SCFUSION{ 13 | namespace IO { 14 | class LibSettingsIO : public FileIO { 15 | ITMLib::ITMLibSettings *libSettings; 16 | public: 17 | explicit LibSettingsIO(ITMLib::ITMLibSettings *libSettings_) : libSettings(libSettings_) {} 18 | 19 | void saveParams(const std::string &path); 20 | 21 | void saveParams(std::fstream *file); 22 | 23 | void loadParams(const std::string &path); 24 | }; 25 | 26 | template <> void FileIO::assignValue(SCFUSION::Policy::Integrate *policy, const std::vector &map); 27 | 28 | template <> void FileIO::assignValue(SCFUSION::Policy::FuseTwo *policy, const std::vector &map); 29 | 30 | template <> void FileIO::assignValue(ITMLib::ITMLibSettings::DeviceType *type, const std::vector &map); 31 | 32 | template <> void FileIO::assignValue(ITMLib::ITMLibSettings::FailureMode *mode, const std::vector &map); 33 | 34 | template <> void FileIO::assignValue(ITMLib::ITMLibSettings::SwappingMode *mode, const std::vector &map); 35 | 36 | template <> void FileIO::assignValue(ITMLib::ITMLibSettings::LibMode *mode, const std::vector &map); 37 | 38 | template <> void FileIO::assignValue(SCFUSION::SceneCompletionMethod *method, const std::vector &map); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /MeshVoxelizer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(targetname MeshVoxelizer) 2 | 3 | INCLUDE(UseCUDA) 4 | #FIND_PACKAGE(GLM REQUIRED) 5 | file(GLOB_RECURSE headers *.h *.hpp *.tpp) 6 | file(GLOB_RECURSE sources *.cpp *.c *.cc *.cu) 7 | INCLUDE(${PROJECT_SOURCE_DIR}/cmake/SetCUDALibTarget.cmake) 8 | -------------------------------------------------------------------------------- /MeshVoxelizer/PlatformIndependence.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Oxford University Innovation Limited and the authors of InfiniTAM 2 | #pragma once 3 | 4 | #if !defined(__METALC__) 5 | #include 6 | #include 7 | #endif 8 | 9 | #if defined(__CUDACC__) && defined(__CUDA_ARCH__) 10 | #define _CPU_AND_GPU_CODE_ __device__ // for CUDA device code 11 | #else 12 | #define _CPU_AND_GPU_CODE_ 13 | #endif 14 | 15 | #if defined(__CUDACC__) 16 | #define _CPU_AND_GPU_CODE_TEMPLATE_ __device__ // for CUDA device code 17 | #else 18 | #define _CPU_AND_GPU_CODE_TEMPLATE_ 19 | #endif 20 | 21 | #if defined(__CUDACC__) && defined(__CUDA_ARCH__) 22 | #define _CPU_AND_GPU_CONSTANT_ __constant__ // for CUDA device code 23 | #else 24 | #define _CPU_AND_GPU_CONSTANT_ 25 | #endif 26 | 27 | #if defined(__METALC__) // for METAL device code 28 | #define THREADPTR(x) thread x 29 | #define DEVICEPTR(x) device x 30 | #define THREADGRPPTR(x) threadgroup x 31 | #define CONSTPTR(x) constant x 32 | #else 33 | #define THREADPTR(x) x 34 | #define DEVICEPTR(x) x 35 | #define THREADGROUPPTR(x) x 36 | #define CONSTPTR(x) x 37 | #endif 38 | 39 | #ifdef ANDROID 40 | #define DIEWITHEXCEPTION(x) { fprintf(stderr, "%s\n", x); exit(-1); } 41 | #else 42 | #define DIEWITHEXCEPTION(x) throw std::runtime_error(x) 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /PytorchCpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(targetname PytorchCppTools) 2 | 3 | ############################################################################### 4 | SET(sources 5 | PytorchCpp.cpp 6 | ) 7 | SET(headers 8 | include/PytorchCpp/PytorchCpp.h 9 | ) 10 | 11 | 12 | INCLUDE(SetLibTarget) 13 | INCLUDE(LinkPytorch) 14 | set_target_properties(${targetname} PROPERTIES LINKER_LANGUAGE CXX) 15 | set_target_properties(${targetname} PROPERTIES CXX_STANDARD 14) 16 | target_include_directories(${targetname} PUBLIC ./include ) -------------------------------------------------------------------------------- /PytorchCpp/PytorchCpp.cpp: -------------------------------------------------------------------------------- 1 | #include "include/PytorchCpp/PytorchCpp.h" 2 | 3 | using namespace torch; 4 | 5 | -------------------------------------------------------------------------------- /SLAMWrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(targetname SLAM_Wrapper) 2 | INCLUDE(../cmake/UseCUDA.cmake) 3 | file(GLOB_RECURSE headers *.h *.tpp) 4 | file(GLOB_RECURSE sources *.cu) 5 | 6 | INCLUDE(SetCUDALibTarget) 7 | target_include_directories(${targetname} PUBLIC ./include) 8 | TARGET_LINK_LIBRARIES(${targetname} PUBLIC ImageLoader) 9 | 10 | 11 | IF(WITH_GUI) 12 | TARGET_LINK_LIBRARIES(${targetname} PUBLIC GUI3D) 13 | ENDIF(WITH_GUI) 14 | -------------------------------------------------------------------------------- /cmake/CUDACheckCompute.cmake: -------------------------------------------------------------------------------- 1 | ############################# 2 | #Sourced from: 3 | #https://raw.githubusercontent.com/jwetzl/CudaLBFGS/master/CheckComputeCapability.cmake 4 | ############################# 5 | # Check for GPUs present and their compute capability 6 | # based on http://stackoverflow.com/questions/2285185/easiest-way-to-test-for-existence-of-cuda-capable-gpu-from-cmake/2297877#2297877 (Christopher Bruns) 7 | 8 | if(CUDA_FOUND) 9 | message(STATUS "${CMAKE_MODULE_PATH}/cuda_compute_capability.cpp") 10 | try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR 11 | ${CMAKE_BINARY_DIR} 12 | ${CMAKE_MODULE_PATH}/cuda_compute_capability.cpp 13 | CMAKE_FLAGS 14 | -DINCLUDE_DIRECTORIES:STRING=${CUDA_TOOLKIT_INCLUDE} 15 | -DLINK_LIBRARIES:STRING=${CUDA_CUDART_LIBRARY} 16 | COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR 17 | RUN_OUTPUT_VARIABLE RUN_OUTPUT_VAR) 18 | message(STATUS "Compile: ${RUN_OUTPUT_VAR}") 19 | if (COMPILE_RESULT_VAR) 20 | message(STATUS "compiled -> " ${RUN_RESULT_VAR}) 21 | else() 22 | message(STATUS "didn't compile") 23 | endif() 24 | # COMPILE_RESULT_VAR is TRUE when compile succeeds 25 | # RUN_RESULT_VAR is zero when a GPU is found 26 | if(COMPILE_RESULT_VAR AND NOT RUN_RESULT_VAR) 27 | message(STATUS "worked") 28 | set(CUDA_HAVE_GPU TRUE CACHE BOOL "Whether a CUDA-capable GPU is present") 29 | set(CUDA_COMPUTE_CAPABILITY ${RUN_OUTPUT_VAR} CACHE STRING "Compute capabilities of CUDA-capable GPUs present (separated by semicolons)") 30 | mark_as_advanced(CUDA_COMPUTE_CAPABILITY) 31 | else() 32 | message(STATUS "didn't work") 33 | set(CUDA_HAVE_GPU FALSE CACHE BOOL "Whether a CUDA-capable GPU is present") 34 | endif() 35 | endif() 36 | -------------------------------------------------------------------------------- /cmake/FindFreeType2.cmake: -------------------------------------------------------------------------------- 1 | # Use FreeType2 2 | ### 3 | # FreeType2_FOUND 4 | # FreeType2_INCLUDE_DIRS 5 | # FreeType2_LIBRARIES 6 | 7 | SET(NAME FreeType2) 8 | SET(URL "https://github.com/aseprite/freetype2.git") 9 | SET(${NAME}_INSTALL_DIR ${CMAKE_BINARY_DIR}/external/${NAME}) 10 | SET(${NAME}_DOWNLOADED 0) 11 | IF(NOT ${NAME}_DOWNLOADED) 12 | find_package(Git) 13 | include(FindPythonInterp) 14 | file(MAKE_DIRECTORY ${${NAME}_INSTALL_DIR}) 15 | execute_process( 16 | COMMAND ${GIT_EXECUTABLE} clone ${URL} ${NAME} 17 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external 18 | ) 19 | 20 | file(MAKE_DIRECTORY ${${NAME}_INSTALL_DIR}/build) 21 | execute_process( 22 | COMMAND cmake -DCMAKE_INSTALL_PREFIX=${${NAME}_INSTALL_DIR}/bin .. 23 | WORKING_DIRECTORY ${${NAME}_INSTALL_DIR}/build 24 | ) 25 | execute_process( 26 | COMMAND make install 27 | WORKING_DIRECTORY ${${NAME}_INSTALL_DIR}/build 28 | ) 29 | SET(${NAME}_DOWNLOADED 1 CACHE STRING " ") 30 | SET(${NAME}_FOUND 1 CACHE STRING " ") 31 | #SET(${NAME}_INCLUDE_DIR ${${NAME}_INSTALL_DIR}/build/include CACHE STRING " ") 32 | ENDIF() 33 | 34 | FIND_PACKAGE(freetype REQUIRED PATHS ${${NAME}_INSTALL_DIR}/bin/lib/cmake NO_DEFAULT_PATH) 35 | 36 | #FIND_PATH(${NAME}_INCLUDE_DIRS ft2build.h DOC "path to ${NAME} directory" 37 | # PATHS ${${NAME}_INSTALL_DIR}/bin/include/freetype2) 38 | #FIND_LIBRARY(${NAME}_LIBRARIES DOC "abs path to ${NAME} library." 39 | # NAMES libfreetype.a libfreetype.so 40 | # HINTS ${${NAME}_INSTALL_DIR}/bin/lib 41 | # PATHS ${${NAME}_INSTALL_DIR}/bin/lib) 42 | # 43 | #IF(${NAME}_LIBRARIES AND ${NAME}_INCLUDE_DIRS) 44 | # SET(${NAME}_FOUND 1 CACHE STRING " ") 45 | #ELSE() 46 | # SET(${NAME}_FOUND 0 CACHE STRING " ") 47 | #ENDIF() -------------------------------------------------------------------------------- /cmake/FindGLM.cmake: -------------------------------------------------------------------------------- 1 | # Find glm 2 | # Use glm as an external project 3 | # 4 | ### 5 | # glm_FOUND 6 | # glm_INCLUDE_DIRS 7 | #set(glm_FOUND 0) 8 | IF(NOT glm_FOUND) 9 | find_package(Git) 10 | #include(FindPythonInterp) 11 | 12 | SET(NAME glm) 13 | SET(URL "https://github.com/g-truc/glm.git") 14 | 15 | SET(${NAME}_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/external) 16 | file(MAKE_DIRECTORY ${${NAME}_INSTALL_PREFIX}) 17 | execute_process( 18 | COMMAND ${GIT_EXECUTABLE} clone ${URL} ${NAME} 19 | WORKING_DIRECTORY ${${NAME}_INSTALL_PREFIX} 20 | ) 21 | 22 | SET(glm_INCLUDE_DIRS ${glm_INSTALL_PREFIX}/${NAME} CACHE STRING "glm include directory") 23 | SET(glm_FOUND 1 CACHE STRING "Set to 1 if NanoGUI is found, 0 otherwise") 24 | ENDIF() -------------------------------------------------------------------------------- /cmake/FindPackageMessage.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | #[=======================================================================[.rst: 5 | FindPackageMessage 6 | ------------------ 7 | 8 | .. code-block:: cmake 9 | 10 | find_package_message( "message for user" "find result details") 11 | 12 | This function is intended to be used in FindXXX.cmake modules files. 13 | It will print a message once for each unique find result. This is 14 | useful for telling the user where a package was found. The first 15 | argument specifies the name (XXX) of the package. The second argument 16 | specifies the message to display. The third argument lists details 17 | about the find result so that if they change the message will be 18 | displayed again. The macro also obeys the QUIET argument to the 19 | find_package command. 20 | 21 | Example: 22 | 23 | .. code-block:: cmake 24 | 25 | if(X11_FOUND) 26 | find_package_message(X11 "Found X11: ${X11_X11_LIB}" 27 | "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") 28 | else() 29 | ... 30 | endif() 31 | #]=======================================================================] 32 | 33 | function(find_package_message pkg msg details) 34 | # Avoid printing a message repeatedly for the same find result. 35 | if(NOT ${pkg}_FIND_QUIETLY) 36 | string(REPLACE "\n" "" details "${details}") 37 | set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) 38 | if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") 39 | # The message has not yet been printed. 40 | message(STATUS "${msg}") 41 | 42 | # Save the find details in the cache to avoid printing the same 43 | # message again. 44 | set("${DETAILS_VAR}" "${details}" 45 | CACHE INTERNAL "Details about finding ${pkg}") 46 | endif() 47 | endif() 48 | endfunction() 49 | -------------------------------------------------------------------------------- /cmake/Findgl3w.cmake: -------------------------------------------------------------------------------- 1 | # Find gl3w 2 | # Use gl3w as an external project 3 | # 4 | ### 5 | # gl3w_FOUND 6 | # gl3w_SOURCE return the source file location 7 | # gl3w_INCLUDE_DIRS 8 | 9 | IF(NOT gl3w_FOUND) 10 | find_package(Git) 11 | include(FindPythonInterp) 12 | 13 | SET(NAME gl3w) 14 | SET(URL "https://github.com/skaslev/gl3w.git") 15 | 16 | SET(${NAME}_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/external/${NAME}-prefix) 17 | SET(${NAME}_INSTALL_DIR ${CMAKE_BINARY_DIR}/external/${NAME}-install) 18 | file(MAKE_DIRECTORY ${${NAME}_INSTALL_DIR}) 19 | file(MAKE_DIRECTORY ${${NAME}_INSTALL_PREFIX}) 20 | execute_process( 21 | COMMAND ${GIT_EXECUTABLE} clone ${URL} ${NAME} 22 | WORKING_DIRECTORY ${${NAME}_INSTALL_PREFIX} 23 | ) 24 | execute_process( 25 | COMMAND ${PYTHON_EXECUTABLE} gl3w_gen.py --root=${${NAME}_INSTALL_DIR} 26 | WORKING_DIRECTORY ${${NAME}_INSTALL_PREFIX}/${NAME} 27 | ) 28 | 29 | SET(gl3w_INCLUDE_DIRS ${gl3w_INSTALL_DIR}/include CACHE STRING "gl3w source file") 30 | SET(gl3w_SOURCE ${gl3w_INSTALL_DIR}/src/gl3w.c CACHE STRING "gl3w source file") 31 | SET(gl3w_FOUND 1 CACHE STRING "Set to 1 if NanoGUI is found, 0 otherwise") 32 | ENDIF() -------------------------------------------------------------------------------- /cmake/Flags.cmake: -------------------------------------------------------------------------------- 1 | ############### 2 | # Flags.cmake # 3 | ############### 4 | 5 | # If on Mac OS X: 6 | IF(${CMAKE_SYSTEM} MATCHES "Darwin") 7 | # Make sure that C++11 warnings are disabled. 8 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-extensions") 9 | 10 | # Make sure that the template depth is sufficient. 11 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=512") 12 | 13 | IF(${CMAKE_SYSTEM} MATCHES "Darwin-13.") 14 | # If on Mac OS X 10.9 (Mavericks), use the libstdc++ implementation of the C++ Standard Library and prevent C++11 code from being compiled. 15 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") 16 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++") 17 | ADD_DEFINITIONS(-DNO_CPP11) 18 | ELSE() 19 | # Otherwise, use the libc++ implementation of the C++ Standard Library, and enable C++11 support. 20 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11") 21 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -std=c++11") 22 | ENDIF() 23 | ENDIF() 24 | 25 | # If on Linux, make sure that C++11 support is enabled. 26 | IF(${CMAKE_SYSTEM} MATCHES "Linux") 27 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread") 28 | ENDIF() 29 | 30 | # If on Windows and using Visual Studio: 31 | IF(MSVC_IDE) 32 | # Disable the annoying warnings about using secure CRT functions (they're Microsoft-specific, so we can't use them portably). 33 | ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) 34 | 35 | # Prevent the definitions of min and max when including windows.h. 36 | ADD_DEFINITIONS(-DNOMINMAX) 37 | 38 | # Make sure that the maths constants are defined. 39 | ADD_DEFINITIONS(-D_USE_MATH_DEFINES) 40 | 41 | # Define a macro needed when using Boost.ASIO. 42 | ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501) 43 | ENDIF() 44 | -------------------------------------------------------------------------------- /cmake/LinkEigen3.cmake: -------------------------------------------------------------------------------- 1 | #################### 2 | # LinkEigen3.cmake # 3 | #################### 4 | 5 | if(EIGEN3_INCLUDE_DIR) 6 | target_include_directories(${targetname} PUBLIC ${EIGEN3_INCLUDE_DIR}) 7 | TARGET_COMPILE_DEFINITIONS(${targetname} PUBLIC COMPILE_WITH_EIGEN) 8 | endif(EIGEN3_INCLUDE_DIR) -------------------------------------------------------------------------------- /cmake/LinkFreetype.cmake: -------------------------------------------------------------------------------- 1 | ################### 2 | # LinkFreetype.cmake # 3 | ################### 4 | if(FREETYPE_INCLUDE_DIRS) 5 | TARGET_INCLUDE_DIRECTORIES(${targetname} PUBLIC ${FREETYPE_INCLUDE_DIRS}) 6 | TARGET_LINK_LIBRARIES(${targetname} PUBLIC ${FREETYPE_LIBRARIES}) 7 | # message("FREETYPE_INCLUDE_DIRS: " ${FREETYPE_INCLUDE_DIRS}) 8 | # message("FREETYPE_LIBRARIES: " ${FREETYPE_LIBRARIES}) 9 | else() 10 | MESSAGE(WARNING "CANNOT LINK TO FREETYPE SINCE IT WAS NOT FOUND!") 11 | endif(FREETYPE_INCLUDE_DIRS) 12 | 13 | 14 | -------------------------------------------------------------------------------- /cmake/LinkGTest.cmake: -------------------------------------------------------------------------------- 1 | 2 | IF(GTEST_INCLUDE_DIR) 3 | TARGET_INCLUDE_DIRECTORIES(${targetname} PUBLIC ${GTEST_INCLUDE_DIR}) 4 | TARGET_LINK_LIBRARIES(${targetname} PUBLIC ${GTEST_LIBRARY} PUBLIC ${GTEST_MAIN_LIBRARY} PUBLIC pthread) 5 | ELSEIF(GTEST_INCLUDE_DIR) 6 | MESSAGE(WARNING "Trying to link GTest but the variables were not set. Did you forget to use UseGTest.cmake?") 7 | ENDIF(GTEST_INCLUDE_DIR) -------------------------------------------------------------------------------- /cmake/LinkOpenCV.cmake: -------------------------------------------------------------------------------- 1 | #################### 2 | # LinkOpenGL.cmake # 3 | #################### 4 | IF(OpenCV_FOUND) 5 | TARGET_LINK_LIBRARIES(${targetname} PUBLIC ${OpenCV_LIBS}) 6 | TARGET_INCLUDE_DIRECTORIES(${targetname} PUBLIC ${OpenCV_INCLUDE_DIRS}) 7 | TARGET_LINK_DIRECTORIES(${targetname} PUBLIC ${OpenCV_LIB_DIRS}) 8 | TARGET_COMPILE_DEFINITIONS(${targetname} PUBLIC COMPILE_WITH_OPENCV) 9 | ENDIF() -------------------------------------------------------------------------------- /cmake/LinkPCL.cmake: -------------------------------------------------------------------------------- 1 | ################# 2 | # LinkPCL.cmake # 3 | ################# 4 | if(PCL_INCLUDE_DIRS) 5 | TARGET_LINK_LIBRARIES(${targetname} PUBLIC ${PCL_LIBRARIES}) 6 | TARGET_INCLUDE_DIRECTORIES(${targetname} PUBLIC ${PCL_INCLUDE_DIRS}) 7 | TARGET_LINK_DIRECTORIES(${targetname} PUBLIC ${PCL_LIBRARY_DIRS}) 8 | TARGET_COMPILE_DEFINITIONS(${targetname} PUBLIC COMPILE_WITH_PCL) 9 | elseif(PCL_INCLUDE_DIRS) 10 | message(WARNING "Cannot link PCL since it was not found.") 11 | endif(PCL_INCLUDE_DIRS) -------------------------------------------------------------------------------- /cmake/LinkPytorch.cmake: -------------------------------------------------------------------------------- 1 | ##################### 2 | # LinkPytorch.cmake # 3 | ##################### 4 | IF(WITH_PYTORCH) 5 | if(TORCH_LIBRARIES) 6 | target_link_libraries(${targetname} PRIVATE "${TORCH_LIBRARIES}") 7 | target_compile_definitions(${targetname} PUBLIC COMPILE_WITH_PYTORCH) 8 | set_property(TARGET ${targetname} PROPERTY CXX_STANDARD 14)# pytorch needs at least c++14 9 | message(STATUS "link to Pytorch") 10 | else(TORCH_LIBRARIES) 11 | message(WARNING "Cannot link to Pytorch since it was not found.") 12 | endif(TORCH_LIBRARIES) 13 | ELSE() 14 | MESSAGE(FATAL_ERROR "Did not find Pytorch!") 15 | ENDIF(WITH_PYTORCH) -------------------------------------------------------------------------------- /cmake/SetAppTarget.cmake: -------------------------------------------------------------------------------- 1 | ###################### 2 | # SetAppTarget.cmake # 3 | ###################### 4 | 5 | INCLUDE(${CMAKE_CURRENT_LIST_DIR}/Flags.cmake) 6 | 7 | ADD_EXECUTABLE(${targetname} ${sources} ${headers} ${templates}) 8 | 9 | IF(MSVC_IDE) 10 | SET_TARGET_PROPERTIES(${targetname} PROPERTIES LINK_FLAGS_DEBUG "/DEBUG") 11 | ENDIF() 12 | -------------------------------------------------------------------------------- /cmake/SetCUDAAppTarget.cmake: -------------------------------------------------------------------------------- 1 | ########################## 2 | # SetCUDAAppTarget.cmake # 3 | ########################## 4 | 5 | INCLUDE(${CMAKE_CURRENT_LIST_DIR}/Flags.cmake) 6 | 7 | IF(WITH_CUDA) 8 | CUDA_ADD_EXECUTABLE(${targetname} ${sources} ${headers} ${templates}) 9 | ELSE() 10 | ADD_EXECUTABLE(${targetname} ${sources} ${headers} ${templates}) 11 | ENDIF() 12 | 13 | IF(MSVC_IDE) 14 | SET_TARGET_PROPERTIES(${targetname} PROPERTIES LINK_FLAGS_DEBUG "/DEBUG") 15 | ENDIF() 16 | -------------------------------------------------------------------------------- /cmake/SetCUDALibTarget.cmake: -------------------------------------------------------------------------------- 1 | ########################## 2 | # SetCUDALibTarget.cmake # 3 | ########################## 4 | 5 | INCLUDE(${CMAKE_CURRENT_LIST_DIR}/Flags.cmake) 6 | 7 | OPTION(BUILD_STATIC "Build static library?" ON) 8 | SET(LIBRARY_TYPE) 9 | IF(BUILD_STATIC) 10 | SET(LIBRARY_TYPE STATIC) 11 | ELSE() 12 | SET(LIBRARY_TYPE SHARED) 13 | ENDIF() 14 | 15 | IF(WITH_CUDA) 16 | CUDA_ADD_LIBRARY(${targetname} ${LIBRARY_TYPE} ${sources} ${headers} ${templates}) 17 | ELSE() 18 | ADD_LIBRARY(${targetname} ${LIBRARY_TYPE} ${sources} ${headers} ${templates}) 19 | ENDIF() 20 | -------------------------------------------------------------------------------- /cmake/SetLibTarget.cmake: -------------------------------------------------------------------------------- 1 | ###################### 2 | # SetLibTarget.cmake # 3 | ###################### 4 | 5 | INCLUDE(${PROJECT_SOURCE_DIR}/cmake/Flags.cmake) 6 | 7 | OPTION(BUILD_STATIC "Build static library?" ON) 8 | SET(LIBRARY_TYPE) 9 | IF(BUILD_STATIC) 10 | SET(LIBRARY_TYPE STATIC) 11 | ELSE() 12 | SET(LIBRARY_TYPE SHARED) 13 | ENDIF() 14 | 15 | ADD_LIBRARY(${targetname} ${LIBRARY_TYPE} ${sources} ${headers} ${templates}) 16 | -------------------------------------------------------------------------------- /cmake/UseCxxTools.cmake: -------------------------------------------------------------------------------- 1 | include(${PROJECT_SOURCE_DIR}/cmake/cmake_macro_addExternalProject/macro.cmake) 2 | 3 | addExternalProjectGit ( 4 | cxxtools 5 | https://github.com/ShunChengWu/CxxTools.git 6 | cxxtools_DIR 7 | ) 8 | 9 | include(${cxxtools_DIR}/cmake/CxxToolsTargets.cmake) 10 | link_directories(${cxxtools_DIR}/lib) -------------------------------------------------------------------------------- /cmake/UseEigen3.cmake: -------------------------------------------------------------------------------- 1 | ################### 2 | # UseEigen3.cmake # 3 | ################### 4 | 5 | OPTION(WITH_EIGEN "Build with libEIGEN support?" ON) 6 | 7 | IF(WITH_EIGEN) 8 | if(NOT EIGEN3_INCLUDE_DIR) 9 | find_package(Eigen3 REQUIRED) 10 | endif(NOT EIGEN3_INCLUDE_DIR) 11 | 12 | if(EIGEN3_INCLUDE_DIR) 13 | include_directories(${EIGEN_INCLUDE_DIRS}) 14 | endif(EIGEN3_INCLUDE_DIR) 15 | 16 | ADD_DEFINITIONS(-DCOMPILE_WITH_EIGEN) 17 | ENDIF() 18 | 19 | 20 | -------------------------------------------------------------------------------- /cmake/UseFreetype.cmake: -------------------------------------------------------------------------------- 1 | ################### 2 | # UseFreetype.cmake # 3 | ################### 4 | if(NOT Freetype_INCLUDE_DIR) 5 | find_package(Freetype REQUIRED) 6 | ADD_DEFINITIONS(-DCOMPILE_WITH_FREETYPE) 7 | endif(NOT Freetype_INCLUDE_DIR) 8 | 9 | 10 | -------------------------------------------------------------------------------- /cmake/UseOpenCV.cmake: -------------------------------------------------------------------------------- 1 | ################### 2 | # UseOpenCV.cmake # 3 | ################### 4 | 5 | OPTION(WITH_OpenCV "Build with OpenCV support?" ON) 6 | 7 | IF(WITH_OpenCV) 8 | find_package(OpenCV) 9 | INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) 10 | link_directories(${OpenCV_LIB_DIRS}) 11 | ADD_DEFINITIONS(-DCOMPILE_WITH_OPENCV) 12 | ELSE() 13 | ADD_DEFINITIONS(-DCOMPILE_WITHOUT_OPENCV) 14 | ENDIF() 15 | -------------------------------------------------------------------------------- /cmake/UseOpenMP.cmake: -------------------------------------------------------------------------------- 1 | ################### 2 | # UseOpenMP.cmake # 3 | ################### 4 | 5 | OPTION(WITH_OPENMP "Enable OpenMP support?" OFF) 6 | 7 | IF(WITH_OPENMP) 8 | FIND_PACKAGE(OpenMP) 9 | IF(OPENMP_FOUND) 10 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 11 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 12 | ENDIF() 13 | ADD_DEFINITIONS(-DWITH_OPENMP) 14 | ENDIF() 15 | -------------------------------------------------------------------------------- /cmake/UsePytorch.cmake: -------------------------------------------------------------------------------- 1 | #################### 2 | # UsePytorch.cmake # 3 | #################### 4 | SET(CMAKE_PREFIX_PATH_SAVE ${CMAKE_PREFIX_PATH}) 5 | set(CMAKE_PREFIX_PATH ${PYTORCH_PATH} ${CMAKE_PREFIX_PATH}) 6 | FIND_PACKAGE(Torch QUIET) 7 | 8 | OPTION(WITH_PYTORCH "Build with Pytorch support? Need to pass PYTORCH_PATH to pytorchcpp folder" ${TORCH_FOUND}) 9 | 10 | IF(WITH_PYTORCH) 11 | FIND_PACKAGE(Torch REQUIRED) 12 | include_directories(${TORCH_INCLUDE_DIRS}) 13 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") 14 | ADD_DEFINITIONS(-DCOMPILE_WITH_PYTORCH) 15 | MESSAGE(STATUS "With Pytorch") 16 | ENDIF(WITH_PYTORCH) 17 | 18 | SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH_SAVE}) 19 | -------------------------------------------------------------------------------- /cmake/cmake_macro_addExternalProject/ExternalProject.cmake.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.11) 2 | 3 | project(@PROJECT_NAME@_external NONE) 4 | 5 | include(ExternalProject) 6 | ExternalProject_Add( 7 | @PROJECT_NAME@ 8 | GIT_REPOSITORY @PROJECT_URL@ 9 | PREFIX "@PROJECT_BINARY_DIR@/@PROJECT_NAME@/build" 10 | INSTALL_DIR "@CMAKE_BINARY_DIR@/@PROJECT_NAME@" 11 | # CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=@CMAKE_BINARY_DIR@/@PROJECT_NAME@" 12 | CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" 13 | BUILD_COMMAND ${MAKE} 14 | TEST_COMMAND "" 15 | UPDATE_DISCONNECTED 1 16 | STEP_TARGETS update 17 | ) 18 | -------------------------------------------------------------------------------- /cmake/cuda_compute_capability.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Florian Rathgeber, florian.rathgeber@gmail.com 3 | * 4 | * This code is licensed under the MIT License. See the FindCUDA.cmake script 5 | * for the text of the license. 6 | * 7 | * Based on code by Christopher Bruns published on Stack Overflow (CC-BY): 8 | * http://stackoverflow.com/questions/2285185 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | int main() { 19 | int deviceCount; 20 | std::set computeCapabilities; 21 | 22 | if (cudaGetDeviceCount(&deviceCount) != cudaSuccess) 23 | { 24 | printf("Couldn't get device count: %s\n", cudaGetErrorString(cudaGetLastError())); 25 | return 1; 26 | } 27 | /* machines with no GPUs can still report one emulation device */ 28 | for (int device = 0; device < deviceCount; ++device) 29 | { 30 | cudaDeviceProp currentProperties; 31 | cudaGetDeviceProperties(¤tProperties, device); 32 | if (currentProperties.major != 9999) {/* 9999 means emulation only */ 33 | std::stringstream ss; 34 | ss << currentProperties.major; 35 | if(currentProperties.major == 2 && currentProperties.minor == 1) 36 | { 37 | ss << 0; // There is no compute_21 architecture. 38 | } 39 | else 40 | { 41 | ss << currentProperties.minor; 42 | } 43 | 44 | computeCapabilities.insert(ss.str()); 45 | } 46 | } 47 | 48 | /* don't just return the number of gpus, because other runtime cuda 49 | errors can also yield non-zero return values */ 50 | for(std::set::const_iterator it = computeCapabilities.begin(); it != computeCapabilities.end(); ++it) 51 | { 52 | // Add a semicolon if we have already printed some output. 53 | if(it != computeCapabilities.begin()) std::cout << ';'; 54 | std::cout << *it; 55 | } 56 | 57 | return computeCapabilities.size() == 0; /* 0 devices -> failure */ 58 | } 59 | -------------------------------------------------------------------------------- /scripts/RUN_FLIP_SCANNET_MESH.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script rotate ScanNet *_vh_clean_2.labels.ply to align with the world coordinate system we used in our method 3 | 4 | # DEFINE PATHS # 5 | exe_rotate_mesh='../build/App/rotation/exe_rotate_mesh' #'/path/to/exe_rotate_mesh' 6 | scannetfolder='/media/sc/space1/dataset/scannet/scans' # /path/to/scannet/scans 7 | 8 | #### 9 | angle_x=-0.5 10 | angle_y=-0.5 11 | angle_z=0 12 | 13 | echo "Processing..." 14 | for d in $scannetfolder/*/ ; do 15 | # check whether *.sens file exist 16 | for name in $d*vh_clean_2.labels.ply ; do 17 | if [ -f "$name" ]; then 18 | filename=$(basename -- "$name") 19 | extension="${filename##*.}" 20 | filename="${filename%.*}" 21 | # echo "name: " $name 22 | # echo "filename: " $filename 23 | # echo "extension: " $extension 24 | #echo "[BASH] --------Run Data Poseprocessing Pipieline--------" 25 | # Check ground truth binary file exist. If not, generate 26 | outFliped=$d/$filename"_flip2."$extension 27 | $exe_rotate_mesh --pth_in $name --angle_x $angle_x --angle_y $angle_y --angle_z $angle_z 28 | exit 29 | fi 30 | done 31 | done 32 | echo "Done." 33 | 34 | 35 | --------------------------------------------------------------------------------