├── BasicAPI.cpp ├── BasicAPI.h ├── CHISEL ├── build │ ├── CMakeCache.txt │ ├── CMakeFiles │ │ ├── 3.5.1 │ │ │ ├── CMakeCCompiler.cmake │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ ├── CMakeSystem.cmake │ │ │ ├── CompilerIdC │ │ │ │ ├── CMakeCCompilerId.c │ │ │ │ └── a.out │ │ │ └── CompilerIdCXX │ │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ │ └── a.out │ │ ├── CMakeDirectoryInformation.cmake │ │ ├── CMakeError.log │ │ ├── CMakeOutput.log │ │ ├── Makefile.cmake │ │ ├── Makefile2 │ │ ├── TargetDirectories.txt │ │ ├── chisel.dir │ │ │ ├── CXX.includecache │ │ │ ├── DependInfo.cmake │ │ │ ├── build.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.internal │ │ │ ├── depend.make │ │ │ ├── flags.make │ │ │ ├── link.txt │ │ │ ├── open_chisel │ │ │ │ ├── Chisel.cpp.o │ │ │ │ ├── Chunk.cpp.o │ │ │ │ ├── ChunkManager.cpp.o │ │ │ │ ├── ColorVoxel.cpp.o │ │ │ │ ├── DistVoxel.cpp.o │ │ │ │ ├── ProjectionIntegrator.cpp.o │ │ │ │ ├── camera │ │ │ │ │ ├── Intrinsics.cpp.o │ │ │ │ │ └── PinholeCamera.cpp.o │ │ │ │ ├── geometry │ │ │ │ │ ├── AABB.cpp.o │ │ │ │ │ ├── Frustum.cpp.o │ │ │ │ │ ├── Plane.cpp.o │ │ │ │ │ └── Raycast.cpp.o │ │ │ │ ├── io │ │ │ │ │ └── PLY.cpp.o │ │ │ │ ├── marching_cubes │ │ │ │ │ └── MarchingCubes.cpp.o │ │ │ │ └── mesh │ │ │ │ │ └── Mesh.cpp.o │ │ │ └── progress.make │ │ ├── cmake.check_cache │ │ ├── feature_tests.bin │ │ ├── feature_tests.c │ │ ├── feature_tests.cxx │ │ └── progress.marks │ ├── Makefile │ ├── cmake_install.cmake │ └── libchisel.so └── src │ ├── CMakeLists.txt │ ├── CudaComputeTargetFlags.cmake │ ├── FindSuiteSparse.cmake │ ├── chisel.found │ └── open_chisel │ ├── AlignmentAllocator.h │ ├── AllignedAllocator.h │ ├── Chisel.cpp │ ├── Chisel.h │ ├── Chunk.cpp │ ├── Chunk.h │ ├── ChunkManager.cpp │ ├── ChunkManager.h │ ├── ColorVoxel.cpp │ ├── ColorVoxel.h │ ├── DistVoxel.cpp │ ├── DistVoxel.h │ ├── FixedPointFloat.h │ ├── ProjectionIntegrator.cpp │ ├── ProjectionIntegrator.h │ ├── Stopwatch.h │ ├── camera │ ├── ColorImage.h │ ├── DepthImage.h │ ├── Intrinsics.cpp │ ├── Intrinsics.h │ ├── PinholeCamera.cpp │ └── PinholeCamera.h │ ├── geometry │ ├── AABB.cpp │ ├── AABB.h │ ├── Frustum.cpp │ ├── Frustum.h │ ├── Geometry.h │ ├── Interpolate.h │ ├── Plane.cpp │ ├── Plane.h │ ├── Raycast.cpp │ └── Raycast.h │ ├── io │ ├── PLY.cpp │ └── PLY.h │ ├── marching_cubes │ ├── MarchingCubes.cpp │ └── MarchingCubes.h │ ├── mesh │ ├── Mesh.cpp │ └── Mesh.h │ ├── threading │ └── Threading.h │ ├── truncation │ ├── ConstantTruncator.h │ ├── QuadraticTruncator.h │ └── Truncator.h │ └── weighting │ ├── ConstantWeighter.h │ └── Weighter.h ├── CMakeLists.txt ├── FindChisel.cmake ├── FindLibRealSense.cmake ├── FindOpenNI2.cmake ├── FindRealSense.cmake ├── FindSophus.cmake ├── GCFusion.config ├── GCFusion.creator ├── GCFusion.files ├── GCFusion.includes ├── GCFusion ├── MapMaintain.hpp ├── MobileFusion.cpp ├── MobileFusion.h └── MobileGUI.hpp ├── GCSLAM ├── GCSLAM.cpp ├── GCSLAM.h ├── MILD │ ├── BayesianFilter.hpp │ ├── lightweight_vector.hpp │ ├── loop_closure_detector.hpp │ ├── mild.hpp │ └── sparse_match.hpp ├── MultiViewGeometry.cpp ├── MultiViewGeometry.h ├── ORBSLAM │ ├── ORBextractor.cpp │ └── ORBextractor.h └── frame.h ├── LICENSE ├── README.md ├── Shaders ├── Defines.h ├── Parse.cpp ├── Parse.h ├── Shaders.h ├── Uniform.h ├── Vertex.cpp ├── Vertex.h ├── color.glsl ├── combo_splat.frag ├── copy_unstable.geom ├── copy_unstable.vert ├── data.frag ├── data.geom ├── data.vert ├── depth_bilateral.frag ├── depth_metric.frag ├── depth_norm.frag ├── depth_splat.frag ├── draw_feedback.frag ├── draw_feedback.vert ├── draw_feedback_Phong.frag ├── draw_feedback_Phong.vert ├── draw_feedback_VoxelHashing.frag ├── draw_feedback_VoxelHashing.vert ├── draw_global_surface.frag ├── draw_global_surface.geom ├── draw_global_surface.vert ├── draw_global_surface_phong.frag ├── draw_tsdf_feedback.frag ├── draw_tsdf_feedback.vert ├── empty.vert ├── fill_normal.frag ├── fill_rgb.frag ├── fill_vertex.frag ├── fxaa.frag ├── geometry.glsl ├── index_map.frag ├── index_map.vert ├── init_unstable.vert ├── quad.geom ├── resize.frag ├── sample.geom ├── sample.vert ├── splat.vert ├── surfels.glsl ├── update.vert ├── vertex_feedback.geom ├── vertex_feedback.vert └── visualise_textures.frag ├── Tools ├── CameraInterface.h ├── JPEGLoader.h ├── LiveLogReader.cpp ├── LiveLogReader.h ├── LogReader.h ├── OpenNI2Interface.cpp ├── OpenNI2Interface.h ├── RawLogReader.cpp ├── RawLogReader.h ├── RealSenseInterface.cpp ├── RealSenseInterface.h └── ThreadMutexObject.h ├── evaluation.m ├── main.cpp ├── main_sim.cppqwe ├── param ├── calib_icl.txt ├── calib_tum.txt ├── calib_xtion.txt └── settings.yaml ├── prepare.sh ├── settings.yaml └── third_party_library ├── OpenNI-Linux-x64-2.2.0.33.tar.bz2 ├── Pangolin-master.zip ├── Sophus.tar.gz ├── librealsense-master.zip └── opencv-3.3.0.zip /CHISEL/build/CMakeFiles/3.5.1/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/usr/bin/cc") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "GNU") 4 | set(CMAKE_C_COMPILER_VERSION "5.4.0") 5 | set(CMAKE_C_COMPILER_WRAPPER "") 6 | set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11") 7 | set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros;c_static_assert") 8 | set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes") 9 | set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros") 10 | set(CMAKE_C11_COMPILE_FEATURES "c_static_assert") 11 | 12 | set(CMAKE_C_PLATFORM_ID "Linux") 13 | set(CMAKE_C_SIMULATE_ID "") 14 | set(CMAKE_C_SIMULATE_VERSION "") 15 | 16 | set(CMAKE_AR "/usr/bin/ar") 17 | set(CMAKE_RANLIB "/usr/bin/ranlib") 18 | set(CMAKE_LINKER "/usr/bin/ld") 19 | set(CMAKE_COMPILER_IS_GNUCC 1) 20 | set(CMAKE_C_COMPILER_LOADED 1) 21 | set(CMAKE_C_COMPILER_WORKS TRUE) 22 | set(CMAKE_C_ABI_COMPILED TRUE) 23 | set(CMAKE_COMPILER_IS_MINGW ) 24 | set(CMAKE_COMPILER_IS_CYGWIN ) 25 | if(CMAKE_COMPILER_IS_CYGWIN) 26 | set(CYGWIN 1) 27 | set(UNIX 1) 28 | endif() 29 | 30 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 31 | 32 | if(CMAKE_COMPILER_IS_MINGW) 33 | set(MINGW 1) 34 | endif() 35 | set(CMAKE_C_COMPILER_ID_RUN 1) 36 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) 37 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 38 | set(CMAKE_C_LINKER_PREFERENCE 10) 39 | 40 | # Save compiler ABI information. 41 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 42 | set(CMAKE_C_COMPILER_ABI "ELF") 43 | set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 44 | 45 | if(CMAKE_C_SIZEOF_DATA_PTR) 46 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 47 | endif() 48 | 49 | if(CMAKE_C_COMPILER_ABI) 50 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 51 | endif() 52 | 53 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 54 | set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 55 | endif() 56 | 57 | set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "") 58 | if(CMAKE_C_CL_SHOWINCLUDES_PREFIX) 59 | set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}") 60 | endif() 61 | 62 | 63 | 64 | 65 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "c") 66 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib;/usr/local/cuda/lib64") 67 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 68 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/3.5.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-4.15.0-72-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "4.15.0-72-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Linux-4.15.0-72-generic") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "4.15.0-72-generic") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/3.5.1/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/3.5.1/CompilerIdC/a.out -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/3.5.1/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/3.5.1/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/CMakeDirectoryInformation.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.5 3 | 4 | # Relative path conversion top directories. 5 | set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/src") 6 | set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build") 7 | 8 | # Force unix paths in dependencies. 9 | set(CMAKE_FORCE_UNIX_PATHS 1) 10 | 11 | 12 | # The C and CXX include file regular expressions for this directory. 13 | set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") 14 | set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") 15 | set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) 16 | set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) 17 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Determining if the pthread_create exist failed with the following output: 2 | Change Dir: /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp 3 | 4 | Run Build Command:"/usr/bin/make" "cmTC_1e684/fast" 5 | /usr/bin/make -f CMakeFiles/cmTC_1e684.dir/build.make CMakeFiles/cmTC_1e684.dir/build 6 | make[1]: Entering directory '/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp' 7 | Building C object CMakeFiles/cmTC_1e684.dir/CheckSymbolExists.c.o 8 | /usr/bin/cc -o CMakeFiles/cmTC_1e684.dir/CheckSymbolExists.c.o -c /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c 9 | Linking C executable cmTC_1e684 10 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1e684.dir/link.txt --verbose=1 11 | /usr/bin/cc CMakeFiles/cmTC_1e684.dir/CheckSymbolExists.c.o -o cmTC_1e684 -rdynamic 12 | CMakeFiles/cmTC_1e684.dir/CheckSymbolExists.c.o: In function `main': 13 | CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create' 14 | collect2: error: ld returned 1 exit status 15 | CMakeFiles/cmTC_1e684.dir/build.make:97: recipe for target 'cmTC_1e684' failed 16 | make[1]: *** [cmTC_1e684] Error 1 17 | make[1]: Leaving directory '/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp' 18 | Makefile:126: recipe for target 'cmTC_1e684/fast' failed 19 | make: *** [cmTC_1e684/fast] Error 2 20 | 21 | File /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: 22 | /* */ 23 | #include 24 | 25 | int main(int argc, char** argv) 26 | { 27 | (void)argv; 28 | #ifndef pthread_create 29 | return ((int*)(&pthread_create))[argc]; 30 | #else 31 | (void)argc; 32 | return 0; 33 | #endif 34 | } 35 | 36 | Determining if the function pthread_create exists in the pthreads failed with the following output: 37 | Change Dir: /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp 38 | 39 | Run Build Command:"/usr/bin/make" "cmTC_f441c/fast" 40 | /usr/bin/make -f CMakeFiles/cmTC_f441c.dir/build.make CMakeFiles/cmTC_f441c.dir/build 41 | make[1]: Entering directory '/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp' 42 | Building C object CMakeFiles/cmTC_f441c.dir/CheckFunctionExists.c.o 43 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_f441c.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.5/Modules/CheckFunctionExists.c 44 | Linking C executable cmTC_f441c 45 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f441c.dir/link.txt --verbose=1 46 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_f441c.dir/CheckFunctionExists.c.o -o cmTC_f441c -rdynamic -lpthreads 47 | /usr/bin/ld: cannot find -lpthreads 48 | collect2: error: ld returned 1 exit status 49 | CMakeFiles/cmTC_f441c.dir/build.make:97: recipe for target 'cmTC_f441c' failed 50 | make[1]: *** [cmTC_f441c] Error 1 51 | make[1]: Leaving directory '/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/CMakeTmp' 52 | Makefile:126: recipe for target 'cmTC_f441c/fast' failed 53 | make: *** [cmTC_f441c/fast] Error 2 54 | 55 | 56 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/rebuild_cache.dir 2 | /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/install/strip.dir 3 | /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/chisel.dir 4 | /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/install.dir 5 | /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/install/local.dir 6 | /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/list_install_components.dir 7 | /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/CMakeFiles/edit_cache.dir 8 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/chisel.dir/open_chisel/io/PLY.cpp.o" 3 | "CMakeFiles/chisel.dir/open_chisel/mesh/Mesh.cpp.o" 4 | "CMakeFiles/chisel.dir/open_chisel/ProjectionIntegrator.cpp.o" 5 | "CMakeFiles/chisel.dir/open_chisel/ChunkManager.cpp.o" 6 | "CMakeFiles/chisel.dir/open_chisel/marching_cubes/MarchingCubes.cpp.o" 7 | "CMakeFiles/chisel.dir/open_chisel/Chisel.cpp.o" 8 | "CMakeFiles/chisel.dir/open_chisel/ColorVoxel.cpp.o" 9 | "CMakeFiles/chisel.dir/open_chisel/Chunk.cpp.o" 10 | "CMakeFiles/chisel.dir/open_chisel/DistVoxel.cpp.o" 11 | "CMakeFiles/chisel.dir/open_chisel/geometry/Plane.cpp.o" 12 | "CMakeFiles/chisel.dir/open_chisel/geometry/Raycast.cpp.o" 13 | "CMakeFiles/chisel.dir/open_chisel/geometry/Frustum.cpp.o" 14 | "CMakeFiles/chisel.dir/open_chisel/geometry/AABB.cpp.o" 15 | "CMakeFiles/chisel.dir/open_chisel/camera/PinholeCamera.cpp.o" 16 | "CMakeFiles/chisel.dir/open_chisel/camera/Intrinsics.cpp.o" 17 | "libchisel.pdb" 18 | "libchisel.so" 19 | ) 20 | 21 | # Per-language clean rules from dependency scanning. 22 | foreach(lang CXX) 23 | include(CMakeFiles/chisel.dir/cmake_clean_${lang}.cmake OPTIONAL) 24 | endforeach() 25 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.5 3 | 4 | # compile CXX with /usr/bin/c++ 5 | CXX_FLAGS = -O3 -msse2 -msse3 -msse4.1 -Wall -std=c++14 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -ftree-vectorize -lboost_system -lpthread -lboost_thread -mavx2 -O3 -DNDEBUG -fPIC 6 | 7 | CXX_DEFINES = -Dchisel_EXPORTS 8 | 9 | CXX_INCLUDES = -I/usr/local/lib/cmake/Pangolin/../../../include -I/usr/local/include/eigen3 -I/usr/include/suitesparse -I/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/src/. 10 | 11 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/link.txt: -------------------------------------------------------------------------------- 1 | /usr/bin/c++ -fPIC -O3 -msse2 -msse3 -msse4.1 -Wall -std=c++14 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -ftree-vectorize -lboost_system -lpthread -lboost_thread -mavx2 -O3 -DNDEBUG -shared -Wl,-soname,libchisel.so -o libchisel.so CMakeFiles/chisel.dir/open_chisel/io/PLY.cpp.o CMakeFiles/chisel.dir/open_chisel/mesh/Mesh.cpp.o CMakeFiles/chisel.dir/open_chisel/ProjectionIntegrator.cpp.o CMakeFiles/chisel.dir/open_chisel/ChunkManager.cpp.o CMakeFiles/chisel.dir/open_chisel/marching_cubes/MarchingCubes.cpp.o CMakeFiles/chisel.dir/open_chisel/Chisel.cpp.o CMakeFiles/chisel.dir/open_chisel/ColorVoxel.cpp.o CMakeFiles/chisel.dir/open_chisel/Chunk.cpp.o CMakeFiles/chisel.dir/open_chisel/DistVoxel.cpp.o CMakeFiles/chisel.dir/open_chisel/geometry/Plane.cpp.o CMakeFiles/chisel.dir/open_chisel/geometry/Raycast.cpp.o CMakeFiles/chisel.dir/open_chisel/geometry/Frustum.cpp.o CMakeFiles/chisel.dir/open_chisel/geometry/AABB.cpp.o CMakeFiles/chisel.dir/open_chisel/camera/PinholeCamera.cpp.o CMakeFiles/chisel.dir/open_chisel/camera/Intrinsics.cpp.o /usr/local/lib/libpangolin.so -lamd -lcamd -lccolamd -lcholmod -lcolamd -lcxsparse -lspqr -lGLU -lGL -lglut -lXmu -lXi -lboost_system -lboost_thread -lboost_chrono -lboost_date_time -lboost_atomic -lpthread -lGLEW -lSM -lICE -lX11 -lXext -lrt -lpthread -ldc1394 -lavcodec -lavformat -lavutil -lswscale /home/blue/anaconda3/lib/libpng.so /home/blue/anaconda3/lib/libz.so /home/blue/anaconda3/lib/libjpeg.so /home/blue/anaconda3/lib/libtiff.so /home/blue/anaconda3/lib/libzstd.so -Wl,-rpath,/usr/local/lib:/home/blue/anaconda3/lib: 2 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/Chisel.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/Chisel.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/Chunk.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/Chunk.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/ChunkManager.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/ChunkManager.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/ColorVoxel.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/ColorVoxel.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/DistVoxel.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/DistVoxel.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/ProjectionIntegrator.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/ProjectionIntegrator.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/camera/Intrinsics.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/camera/Intrinsics.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/camera/PinholeCamera.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/camera/PinholeCamera.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/AABB.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/AABB.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/Frustum.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/Frustum.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/Plane.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/Plane.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/Raycast.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/geometry/Raycast.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/io/PLY.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/io/PLY.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/marching_cubes/MarchingCubes.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/marching_cubes/MarchingCubes.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/open_chisel/mesh/Mesh.cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/chisel.dir/open_chisel/mesh/Mesh.cpp.o -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/chisel.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 1 2 | CMAKE_PROGRESS_2 = 2 3 | CMAKE_PROGRESS_3 = 3 4 | CMAKE_PROGRESS_4 = 4 5 | CMAKE_PROGRESS_5 = 5 6 | CMAKE_PROGRESS_6 = 6 7 | CMAKE_PROGRESS_7 = 7 8 | CMAKE_PROGRESS_8 = 8 9 | CMAKE_PROGRESS_9 = 9 10 | CMAKE_PROGRESS_10 = 10 11 | CMAKE_PROGRESS_11 = 11 12 | CMAKE_PROGRESS_12 = 12 13 | CMAKE_PROGRESS_13 = 13 14 | CMAKE_PROGRESS_14 = 14 15 | CMAKE_PROGRESS_15 = 15 16 | CMAKE_PROGRESS_16 = 16 17 | 18 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/feature_tests.c: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "C_FEATURE:" 4 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /CHISEL/build/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /CHISEL/build/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/src 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Release") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Install shared libraries without execute permission? 31 | if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 32 | set(CMAKE_INSTALL_SO_NO_EXE "1") 33 | endif() 34 | 35 | if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified") 36 | if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libchisel.so" AND 37 | NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libchisel.so") 38 | file(RPATH_CHECK 39 | FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libchisel.so" 40 | RPATH "") 41 | endif() 42 | file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES "/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/libchisel.so") 43 | if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libchisel.so" AND 44 | NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libchisel.so") 45 | file(RPATH_CHANGE 46 | FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libchisel.so" 47 | OLD_RPATH "/usr/local/lib:/home/blue/anaconda3/lib:" 48 | NEW_RPATH "") 49 | if(CMAKE_INSTALL_DO_STRIP) 50 | execute_process(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libchisel.so") 51 | endif() 52 | endif() 53 | endif() 54 | 55 | if(CMAKE_INSTALL_COMPONENT) 56 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 57 | else() 58 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 59 | endif() 60 | 61 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 62 | "${CMAKE_INSTALL_MANIFEST_FILES}") 63 | file(WRITE "/home/blue/Documents/flashfusion_opensource/flashfusion2/CHISEL/build/${CMAKE_INSTALL_MANIFEST}" 64 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 65 | -------------------------------------------------------------------------------- /CHISEL/build/libchisel.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/build/libchisel.so -------------------------------------------------------------------------------- /CHISEL/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | 3 | project(CHISEL) 4 | 5 | 6 | 7 | 8 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}") 9 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) 10 | 11 | set(Pangolin_DIR "../../third_party_library/Pangolin-master/build") 12 | 13 | find_package(Pangolin 0.1 REQUIRED) 14 | find_package(SuiteSparse REQUIRED) 15 | find_package(OpenGL REQUIRED) 16 | find_package(GLUT REQUIRED) 17 | find_package(Boost COMPONENTS system thread REQUIRED ) 18 | 19 | 20 | include_directories(${Pangolin_INCLUDE_DIRS}) 21 | include_directories(${EIGEN_INCLUDE_DIRS}) 22 | include_directories(${SUITESPARSE_INCLUDE_DIRS}) 23 | include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ) 24 | include_directories( ${Boost_INCLUDE_DIR} ) 25 | include_directories( ./ ) 26 | 27 | file(GLOB_RECURSE CHISEL_srcs *.cpp ) 28 | 29 | if(WIN32) 30 | file(GLOB_RECURSE CHISEL_hdrs *.h) 31 | endif() 32 | 33 | 34 | SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) 35 | 36 | 37 | if(WIN32) 38 | set(ADDITIONAL_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) 39 | endif() 40 | execute_process(COMMAND cat /proc/cpuinfo OUTPUT_VARIABLE CPU_INFO) 41 | string(REGEX MATCHALL "avx2" AVX_STRING ${CPU_INFO}) 42 | list(LENGTH AVX_STRING AVX_STRING_LENGTH) 43 | message(STATUS "AVX_STRING: " ${AVX_STRING}) 44 | 45 | set(CMAKE_CXX_FLAGS ${ADDITIONAL_CMAKE_CXX_FLAGS} "-O3 -msse2 -msse3 -msse4.1 -Wall -std=c++14") 46 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -ftree-vectorize -lboost_system -lpthread -lboost_thread") 47 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2") 48 | 49 | if(WIN32) 50 | add_definitions(-DWIN32_LEAN_AND_MEAN) 51 | add_definitions(-DNOMINMAX) 52 | set (EXTRA_WINDOWS_LIBS ${EXTRA_WINDOWS_LIBS} ws2_32) 53 | endif() 54 | 55 | add_library(chisel SHARED 56 | ${CHISEL_srcs} 57 | ${containers} 58 | ${CHISEL_hdrs} 59 | ) 60 | 61 | target_link_libraries(chisel 62 | ${Eigen_LIBRARIES} 63 | ${Pangolin_LIBRARIES} 64 | ${SUITESPARSE_LIBRARIES} 65 | ${EXTRA_WINDOWS_LIBS} 66 | ${OPENGL_LIBRARIES} 67 | ${GLUT_LIBRARY} 68 | ${Boost_LIBRARIES} 69 | ) 70 | 71 | 72 | INSTALL(TARGETS chisel 73 | RUNTIME DESTINATION bin 74 | LIBRARY DESTINATION lib 75 | ARCHIVE DESTINATION lib 76 | ) 77 | -------------------------------------------------------------------------------- /CHISEL/src/CudaComputeTargetFlags.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Compute target flags macros by Anatoly Baksheev 3 | # 4 | # Usage in CmakeLists.txt: 5 | # include(CudaComputeTargetFlags.cmake) 6 | # APPEND_TARGET_ARCH_FLAGS() 7 | 8 | #compute flags macros 9 | MACRO(CUDA_COMPUTE_TARGET_FLAGS arch_bin arch_ptx cuda_nvcc_target_flags) 10 | string(REGEX REPLACE "\\." "" ARCH_BIN_WITHOUT_DOTS "${${arch_bin}}") 11 | string(REGEX REPLACE "\\." "" ARCH_PTX_WITHOUT_DOTS "${${arch_ptx}}") 12 | 13 | set(cuda_computer_target_flags_temp "") 14 | 15 | # Tell NVCC to add binaries for the specified GPUs 16 | string(REGEX MATCHALL "[0-9()]+" ARCH_LIST "${ARCH_BIN_WITHOUT_DOTS}") 17 | foreach(ARCH IN LISTS ARCH_LIST) 18 | if (ARCH MATCHES "([0-9]+)\\(([0-9]+)\\)") 19 | # User explicitly specified PTX for the concrete BIN 20 | set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1}) 21 | else() 22 | # User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN 23 | set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${ARCH},code=sm_${ARCH}) 24 | endif() 25 | endforeach() 26 | 27 | # Tell NVCC to add PTX intermediate code for the specified architectures 28 | string(REGEX MATCHALL "[0-9]+" ARCH_LIST "${ARCH_PTX_WITHOUT_DOTS}") 29 | foreach(ARCH IN LISTS ARCH_LIST) 30 | set(cuda_computer_target_flags_temp ${cuda_computer_target_flags_temp} -gencode arch=compute_${ARCH},code=compute_${ARCH}) 31 | endforeach() 32 | 33 | set(${cuda_nvcc_target_flags} ${cuda_computer_target_flags_temp}) 34 | ENDMACRO() 35 | 36 | MACRO(APPEND_TARGET_ARCH_FLAGS) 37 | set(cuda_nvcc_target_flags "") 38 | CUDA_COMPUTE_TARGET_FLAGS(CUDA_ARCH_BIN CUDA_ARCH_PTX cuda_nvcc_target_flags) 39 | if (cuda_nvcc_target_flags) 40 | message(STATUS "CUDA NVCC target flags: ${cuda_nvcc_target_flags}") 41 | list(APPEND CUDA_NVCC_FLAGS ${cuda_nvcc_target_flags}) 42 | endif() 43 | ENDMACRO() -------------------------------------------------------------------------------- /CHISEL/src/chisel.found: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/CHISEL/src/chisel.found -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/ColorVoxel.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace chisel 25 | { 26 | 27 | ColorVoxel::ColorVoxel() 28 | { 29 | colorData = (unsigned short *)_mm_malloc(512 * 4 * 2, 32); 30 | for(int i = 0; i < 128; i++) 31 | { 32 | _mm256_store_si256((__m256i *)&colorData[i * 16],_mm256_set1_epi16(0)); 33 | } 34 | } 35 | 36 | ColorVoxel::~ColorVoxel() 37 | { 38 | _mm_free(colorData); 39 | } 40 | 41 | } // namespace chisel 42 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/ColorVoxel.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef COLORVOXEL_H_ 23 | #define COLORVOXEL_H_ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | #define VOXEL_NUM 512 // 8 * 8 * 8 34 | namespace chisel 35 | { 36 | 37 | class ColorVoxel 38 | { 39 | public: 40 | ColorVoxel(); 41 | ~ColorVoxel(); 42 | 43 | 44 | float GetRed(int voxel_index) 45 | { 46 | return colorData[voxel_index*4 + 0] / ((float)colorData[voxel_index*4 + 3]); 47 | } 48 | float GetGreen(int voxel_index) 49 | { 50 | return colorData[voxel_index*4 + 1] / ((float)colorData[voxel_index*4 + 3]); 51 | } 52 | float GetBlue(int voxel_index) 53 | { 54 | return colorData[voxel_index*4 + 2] / ((float)colorData[voxel_index*4 + 3]); 55 | } 56 | 57 | inline void Reset(int voxel_index) 58 | { 59 | colorData[voxel_index * 4 + 0] = 0; 60 | colorData[voxel_index * 4 + 1] = 0; 61 | colorData[voxel_index * 4 + 2] = 0; 62 | colorData[voxel_index * 4 + 3] = 0; 63 | } 64 | 65 | unsigned short *colorData; 66 | 67 | protected: 68 | 69 | }; 70 | 71 | } // namespace chisel 72 | 73 | #endif // COLORVOXEL_H_ 74 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/DistVoxel.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace chisel 25 | { 26 | 27 | DistVoxel::DistVoxel() 28 | { 29 | } 30 | 31 | DistVoxel::~DistVoxel() 32 | { 33 | 34 | } 35 | 36 | } // namespace chisel 37 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/FixedPointFloat.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | #ifndef FIXEDPOINTFLOAT_H_ 24 | #define FIXEDPOINTFLOAT_H_ 25 | 26 | #include 27 | 28 | namespace chisel 29 | { 30 | const float MinFloatValue = -1000; 31 | const float MaxFloatValue = 1000; 32 | const float MaxUFloat = 1000; 33 | typedef uint16_t FixedFloat16; 34 | typedef uint16_t UFixedFloat16; 35 | 36 | inline float ClampFloat(const float& input) 37 | { 38 | return std::max(std::min(input, MaxFloatValue), MinFloatValue); 39 | } 40 | 41 | inline float ClampUnsignedFloat(const float input) 42 | { 43 | return std::max(std::min(input, MaxUFloat), 0.0f); 44 | } 45 | 46 | inline FixedFloat16 FloatToFixedFloat16(const float& input) 47 | { 48 | return static_cast(((ClampFloat(input) - MinFloatValue) / (MaxFloatValue - MinFloatValue)) * std::numeric_limits::max()); 49 | } 50 | 51 | inline float FixedFloat16ToFloat(const FixedFloat16& input) 52 | { 53 | const float t = static_cast(input) / std::numeric_limits::max(); 54 | return MinFloatValue + t * (MaxFloatValue - MinFloatValue); 55 | } 56 | 57 | inline UFixedFloat16 FloatToUFixedFloat16(const float& input) 58 | { 59 | return static_cast((ClampUnsignedFloat(input) / MaxUFloat) * std::numeric_limits::max()); 60 | } 61 | 62 | inline float UFixedFloat16ToFloat(const UFixedFloat16& input) 63 | { 64 | const float t = static_cast(input) / std::numeric_limits::max(); 65 | return t * (MaxUFloat); 66 | } 67 | } 68 | 69 | 70 | 71 | #endif // FIXEDPOINTFLOAT_H_ 72 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/camera/Intrinsics.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace chisel 25 | { 26 | 27 | Intrinsics::Intrinsics() 28 | { 29 | // TODO Auto-generated constructor stub 30 | 31 | } 32 | 33 | Intrinsics::~Intrinsics() 34 | { 35 | // TODO Auto-generated destructor stub 36 | } 37 | 38 | } // namespace chisel 39 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/camera/Intrinsics.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef INTRINSICS_H_ 23 | #define INTRINSICS_H_ 24 | 25 | #include 26 | #include 27 | 28 | namespace chisel 29 | { 30 | 31 | class Intrinsics 32 | { 33 | public: 34 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 35 | Intrinsics(); 36 | virtual ~Intrinsics(); 37 | 38 | inline float GetFx() const { return matrix(0, 0); } 39 | inline void SetFx(float fx) { matrix(0, 0) = fx; } 40 | inline float GetFy() const { return matrix(1, 1); } 41 | inline void SetFy(float fy) { matrix(1, 1) = fy; } 42 | inline float GetCx() const { return matrix(0, 2); } 43 | inline void SetCx(float cx) { matrix(0, 2) = cx; } 44 | inline float GetCy() const { return matrix(1, 2); } 45 | inline void SetCy(float cy) { matrix(1, 2) = cy; } 46 | 47 | inline const Mat3x3& GetMatrix() const { return matrix; } 48 | inline Mat3x3& GetMutableMatrix() { return matrix; } 49 | inline void SetMatrix(const Mat3x3& m) { matrix = m; } 50 | 51 | protected: 52 | Mat3x3 matrix; 53 | }; 54 | typedef std::shared_ptr IntrinsicsPtr; 55 | typedef std::shared_ptr IntrinsicsConstPtr; 56 | 57 | } // namespace chisel 58 | 59 | #endif // INTRINSICS_H_ 60 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/camera/PinholeCamera.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace chisel 25 | { 26 | 27 | PinholeCamera::PinholeCamera() 28 | { 29 | 30 | 31 | } 32 | 33 | PinholeCamera::~PinholeCamera() 34 | { 35 | 36 | } 37 | 38 | Vec3 PinholeCamera::ProjectPoint(const Vec3& point) const 39 | { 40 | const float& x = point(0); 41 | const float& y = point(1); 42 | const float& z = point(2); 43 | const float invZ = 1.0f / z; 44 | return Vec3(fx * x * invZ + cx, fy * y * invZ + cy, z); 45 | } 46 | 47 | Vec3 PinholeCamera::UnprojectPoint(const Vec3& point) const 48 | { 49 | const float& u = point(0); 50 | const float& v = point(1); 51 | const float& z = point(2); 52 | return Vec3(z * ((u - cx) / fx), z * ((v - cy) / fy), z); 53 | } 54 | 55 | void PinholeCamera::SetupFrustum(const Transform& view, Frustum* frustum) const 56 | { 57 | assert(frustum != nullptr); 58 | frustum->SetFromParams(view, nearPlane, farPlane, fx, fy, cx, cy, width, height); 59 | } 60 | 61 | bool PinholeCamera::IsPointOnImage(const Vec3& point) const 62 | { 63 | return point(0) >= 1 && point(1) >= 1 && point(0) < width - 1 && point(1) < height - 1; 64 | } 65 | 66 | } // namespace chisel 67 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/camera/PinholeCamera.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef PINHOLECAMERA_H_ 23 | #define PINHOLECAMERA_H_ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace chisel 31 | { 32 | 33 | class PinholeCamera 34 | { 35 | public: 36 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 37 | 38 | PinholeCamera(); 39 | virtual ~PinholeCamera(); 40 | 41 | // inline const Intrinsics& GetIntrinsics(float fx,float fy,float cx,float cy) const { return intrinsics; } 42 | // inline Intrinsics& GetMutableIntrinsics() { return intrinsics; } 43 | inline void SetIntrinsics(float ifx, float ify, float icx, float icy) { fx = ifx; fy = ify; cx = icx; cy = icy; } 44 | 45 | inline int GetWidth() const { return width; } 46 | inline int GetFx() const { return fx; } 47 | inline int GetFy() const { return fy; } 48 | inline int GetCx() const { return cx; } 49 | inline int GetCy() const { return cy; } 50 | inline int GetHeight() const { return height; } 51 | inline void SetWidth(int value) { width = value; } 52 | inline void SetHeight(int value) { height = value; } 53 | inline float GetNearPlane() const { return nearPlane; } 54 | inline float GetFarPlane() const { return farPlane; } 55 | inline void SetNearPlane(float value) { nearPlane = value; } 56 | inline void SetFarPlane(float value) { farPlane = value; } 57 | 58 | void SetupFrustum(const Transform& view, Frustum* frustum) const; 59 | 60 | Vec3 ProjectPoint(const Vec3& point) const; 61 | Vec3 UnprojectPoint(const Vec3& point) const; 62 | 63 | bool IsPointOnImage(const Vec3& point) const; 64 | 65 | protected: 66 | float fx; 67 | float fy; 68 | float cx; 69 | float cy; 70 | 71 | int width; 72 | int height; 73 | float nearPlane; 74 | float farPlane; 75 | 76 | }; 77 | typedef std::shared_ptr PinholeCameraPtr; 78 | typedef std::shared_ptr PinholeCameraConstPtr; 79 | 80 | } // namespace chisel 81 | 82 | #endif // PINHOLECAMERA_H_ 83 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/AABB.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace chisel 25 | { 26 | 27 | AABB::AABB() 28 | { 29 | 30 | } 31 | 32 | AABB::AABB(const Vec3& _min, const Vec3& _max) : 33 | min(_min), max(_max) 34 | { 35 | 36 | } 37 | 38 | Plane::IntersectionType AABB::Intersects(const Plane& plane) const 39 | { 40 | //check all corner side of plane 41 | Vec3 ext = GetExtents(); 42 | 43 | Vec3List corners; 44 | corners.resize(8); 45 | corners[0] = max; 46 | corners[1] = min; 47 | corners[2] = min + Vec3(ext(0), 0, 0); 48 | corners[3] = min + Vec3(0, ext(1), 0); 49 | corners[4] = min + Vec3(0, 0, ext(2)); 50 | corners[5] = min + Vec3(ext(0), 0, ext(2)); 51 | corners[6] = min + Vec3(ext(0), ext(1), 0); 52 | corners[7] = min + Vec3(0, ext(1), ext(2)); 53 | 54 | float lastdistance = plane.normal.dot(corners[0]) + plane.distance; 55 | 56 | for (int i = 1; i < 8; i++) 57 | { 58 | float distance = plane.normal.dot(corners[i]) + plane.distance; 59 | 60 | if ((distance <= 0.0f && lastdistance > 0.0f) || (distance >= 0.0f && lastdistance < 0.0f)) 61 | return Plane::IntersectionType::Intersects; 62 | 63 | lastdistance = distance; 64 | } 65 | 66 | if (lastdistance > 0.0f) 67 | return Plane::IntersectionType::Outside; 68 | 69 | return Plane::IntersectionType::Inside; 70 | 71 | } 72 | 73 | AABB::~AABB() 74 | { 75 | 76 | } 77 | 78 | } // namespace chisel 79 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/AABB.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef AABB_H_ 23 | #define AABB_H_ 24 | 25 | #include 26 | #include 27 | 28 | #include "Geometry.h" 29 | #include "Plane.h" 30 | 31 | namespace chisel 32 | { 33 | 34 | class AABB 35 | { 36 | public: 37 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 38 | AABB(); 39 | AABB(const Vec3& min, const Vec3& max); 40 | virtual ~AABB(); 41 | 42 | inline bool Contains(const Vec3& pos) const 43 | { 44 | return pos(0) >= min(0) && pos(1) >= min(1) && pos(2) >= min(2) && 45 | pos(0) <= max(0) && pos(1) <= max(1) && pos(2) <= max(2); 46 | } 47 | 48 | inline bool Intersects(const AABB& other) const 49 | { 50 | if(min.x() > other.max.x()) return false; 51 | if(min.y() > other.max.y()) return false; 52 | if(min.z() > other.max.z()) return false; 53 | if(max.x() < other.min.x()) return false; 54 | if(max.y() < other.min.y()) return false; 55 | if(max.z() < other.min.z()) return false; 56 | return true; 57 | } 58 | 59 | inline Vec3 GetCenter() const 60 | { 61 | return (max + min) * 0.5f; 62 | } 63 | 64 | inline Vec3 GetExtents() const 65 | { 66 | return (max - min) * 0.5f; 67 | } 68 | 69 | Plane::IntersectionType Intersects(const Plane& other) const; 70 | 71 | Vec3 min; 72 | Vec3 max; 73 | }; 74 | typedef std::shared_ptr AABBPtr; 75 | typedef std::shared_ptr AABBConstPtr; 76 | 77 | } // namespace chisel 78 | 79 | #endif // AABB_H_ 80 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/Frustum.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef FRUSTUM_H_ 23 | #define FRUSTUM_H_ 24 | 25 | #include 26 | #include "Geometry.h" 27 | #include "AABB.h" 28 | 29 | namespace chisel 30 | { 31 | 32 | class Frustum 33 | { 34 | public: 35 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 36 | 37 | Frustum(); 38 | virtual ~Frustum(); 39 | 40 | bool Intersects(const AABB& box) const; 41 | bool Contains(const Vec3& point) const; 42 | void ComputeBoundingBox(AABB* box) const; 43 | void SetFromParams(const Transform& view, float near, float far, float fx, float fy, float cx, float cy, float imgWidth, float imgHeight); 44 | void SetFromVectors(const Vec3& forward, const Vec3& pos, const Vec3& right, const Vec3& up, float near, float far, float fov, float aspect); 45 | void SetFromOpenGLViewProjection(const Mat4x4& view, const Mat4x4& proj); 46 | 47 | const Plane& GetBottomPlane() const { return bottom; } 48 | const Plane& GetTopPlane() const { return top; } 49 | const Plane& GetLeftPlane() const { return left; } 50 | const Plane& GetRightPlane() const { return right; } 51 | const Plane& GetNearPlane() const { return near; } 52 | const Plane& GetFarPlane() const { return far; } 53 | 54 | const Vec3* GetLines() const { return lines; } 55 | const Vec3* GetCorners() const { return corners; } 56 | 57 | protected: 58 | Vec3 corners[8]; 59 | Vec3 lines[24]; 60 | Plane top; 61 | Plane left; 62 | Plane right; 63 | Plane bottom; 64 | Plane near; 65 | Plane far; 66 | }; 67 | typedef std::shared_ptr FrustumPtr; 68 | typedef std::shared_ptr FrustumConstPtr; 69 | 70 | } // namespace chisel 71 | 72 | #endif // FRUSTUM_H_ 73 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/Geometry.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | #ifndef CHISEL_GEOMETRY_H_ 24 | #define CHISEL_GEOMETRY_H_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace chisel 32 | { 33 | typedef Eigen::Vector2i Point2; 34 | typedef Eigen::Vector3i Point3; 35 | typedef Eigen::Vector2f Vec2; 36 | typedef Eigen::Vector3f Vec3; 37 | typedef Eigen::Vector4f Vec4; 38 | typedef Eigen::Matrix3f Mat3x3; 39 | typedef Eigen::Matrix4f Mat4x4; 40 | typedef Eigen::Affine3f Transform; 41 | typedef Eigen::Quaternionf Quaternion; 42 | 43 | typedef std::vector > Point2List; 44 | typedef std::vector > Point3List; 45 | typedef std::vector > Vec2List; 46 | typedef std::vector > Vec3List; 47 | typedef std::vector > Vec4List; 48 | typedef std::vector > Mat3x3List; 49 | typedef std::vector > Mat4List; 50 | typedef std::vector > TransformList; 51 | typedef std::vector > QuaternionList; 52 | } 53 | #endif // GEOMETRY_H_ 54 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/Interpolate.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | #ifndef INTERPOLATE_H_ 24 | #define INTERPOLATE_H_ 25 | 26 | namespace chisel 27 | { 28 | inline float LinearInterpolate(float s, float e, float t) 29 | { 30 | return s+(e-s)*t; 31 | } 32 | 33 | inline float BilinearInterpolate(float c00, float c10, float c01, float c11, float tx, float ty) 34 | { 35 | return LinearInterpolate(LinearInterpolate(c00, c10, tx), LinearInterpolate(c01, c11, tx), ty); 36 | } 37 | } 38 | 39 | #endif // INTERPOLATE_H_ 40 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/Plane.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace chisel 25 | { 26 | 27 | Plane::Plane() 28 | { 29 | 30 | } 31 | 32 | Plane::Plane(const Vec4& params) : 33 | normal(Vec3(params(0), params(1), params(2))), distance(params(3)) 34 | { 35 | 36 | } 37 | 38 | Plane::Plane(const Vec3& _normal, float _distance) : 39 | normal(_normal), distance() 40 | { 41 | 42 | } 43 | 44 | Plane::Plane(const Vec3& a, const Vec3& b, const Vec3& c) 45 | { 46 | Vec3 ab = b - a; 47 | Vec3 ac = c - a; 48 | 49 | Vec3 cross = ab.cross(ac); 50 | normal = cross.normalized(); 51 | distance = -(cross.dot(a)); 52 | } 53 | 54 | Plane::Plane(float a, float b, float c, float d) : 55 | normal(a, b, c), distance(d) 56 | { 57 | 58 | } 59 | 60 | float Plane::GetSignedDistance(const Vec3& point) const 61 | { 62 | return point.dot(normal) + distance; 63 | } 64 | 65 | Plane::~Plane() 66 | { 67 | 68 | } 69 | 70 | } // namespace chisel 71 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/Plane.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef PLANE_H_ 23 | #define PLANE_H_ 24 | 25 | #include 26 | #include "Geometry.h" 27 | 28 | namespace chisel 29 | { 30 | 31 | class Plane 32 | { 33 | public: 34 | 35 | enum class IntersectionType 36 | { 37 | Inside, 38 | Outside, 39 | Intersects 40 | }; 41 | 42 | Plane(); 43 | Plane(const Vec4& params); 44 | Plane(const Vec3& normal, float distance); 45 | Plane(const Vec3& p1, const Vec3& p2, const Vec3& p3); 46 | Plane(float a, float b, float c, float d); 47 | virtual ~Plane(); 48 | 49 | float GetSignedDistance(const Vec3& point) const; 50 | 51 | inline IntersectionType ClassifyPoint(const Vec3& point) const 52 | { 53 | float d = GetSignedDistance(point); 54 | 55 | if(d < 0) 56 | { 57 | return IntersectionType::Inside; 58 | } 59 | else if(d > 0) 60 | { 61 | return IntersectionType::Outside; 62 | } 63 | return IntersectionType::Intersects; 64 | } 65 | 66 | Vec3 normal; 67 | float distance; 68 | 69 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 70 | }; 71 | typedef std::shared_ptr PlanePtr; 72 | typedef std::shared_ptr PlaneConstPtr; 73 | 74 | } // namespace chisel 75 | 76 | #endif // PLANE_H_ 77 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/geometry/Raycast.h: -------------------------------------------------------------------------------- 1 | #ifndef RAYCAST_H_ 2 | #define RAYCAST_H_ 3 | 4 | #include "Geometry.h" 5 | 6 | float signum(float x); 7 | float mod(float value, float modulus); 8 | float intbound(float s, float ds); 9 | bool RayIntersectsAABB(const chisel::Vec3& start, const chisel::Vec3& end, const chisel::Point3& lb, const chisel::Point3& rt); 10 | void Raycast(const chisel::Vec3& start, const chisel::Vec3& end, const chisel::Point3& min, const chisel::Point3& max, chisel::Point3List* output); 11 | 12 | #endif // RAYCAST_H_ 13 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/io/PLY.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace chisel 28 | { 29 | bool SaveMeshPLYASCII(const std::string& fileName, const chisel::MeshConstPtr& mesh) 30 | { 31 | std::ofstream stream(fileName.c_str()); 32 | 33 | if (!stream) 34 | { 35 | return false; 36 | } 37 | 38 | size_t numPoints = mesh->vertices.size(); 39 | stream << "ply" << std::endl; 40 | stream << "format ascii 1.0" << std::endl; 41 | stream << "element vertex " << numPoints << std::endl; 42 | stream << "property float x" << std::endl; 43 | stream << "property float y" << std::endl; 44 | stream << "property float z" << std::endl; 45 | if (mesh->HasColors()) 46 | { 47 | stream << "property uchar red" << std::endl; 48 | stream << "property uchar green" << std::endl; 49 | stream << "property uchar blue" << std::endl; 50 | } 51 | stream << "element face " << numPoints / 3 << std::endl; 52 | stream << "property list uchar int vertex_index" << std::endl; 53 | stream << "end_header" << std::endl; 54 | 55 | size_t vert_idx = 0; 56 | for (const Vec3& vert : mesh->vertices) 57 | { 58 | stream << vert(0) << " " << vert(1) << " " << vert(2); 59 | 60 | if (mesh->HasColors()) 61 | { 62 | const Vec3& color = mesh->colors[vert_idx]; 63 | int r = static_cast(color(0) * 255.0f); 64 | int g = static_cast(color(1) * 255.0f); 65 | int b = static_cast(color(2) * 255.0f); 66 | 67 | stream << " " << r << " " << g << " " << b; 68 | } 69 | 70 | stream << std::endl; 71 | vert_idx++; 72 | } 73 | 74 | for (size_t i = 0; i < mesh->indices.size(); i+=3) 75 | { 76 | stream << "3 "; 77 | 78 | for(int j = 0; j < 3; j++) 79 | { 80 | stream << mesh->indices.at(i + j) << " "; 81 | } 82 | 83 | stream << std::endl; 84 | } 85 | 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/io/PLY.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | #ifndef PLY_H_ 24 | #define PLY_H_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace chisel 31 | { 32 | bool SaveMeshPLYASCII(const std::string& fileName, const chisel::MeshConstPtr& mesh); 33 | } 34 | 35 | #endif // PLY_H_ 36 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/mesh/Mesh.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace chisel 25 | { 26 | 27 | Mesh::Mesh() 28 | { 29 | 30 | } 31 | 32 | Mesh::~Mesh() 33 | { 34 | 35 | } 36 | 37 | } // namespace chisel 38 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/mesh/Mesh.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright noticec and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef MESH_H_ 23 | #define MESH_H_ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace chisel 30 | { 31 | 32 | 33 | typedef size_t VertIndex; 34 | typedef std::vector VertIndexList; 35 | class Mesh 36 | { 37 | public: 38 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; 39 | Mesh(); 40 | virtual ~Mesh(); 41 | 42 | inline bool HasVertices() const { return !vertices.empty(); } 43 | inline bool HasNormals() const { return !normals.empty(); } 44 | inline bool HasColors() const { return !colors.empty(); } 45 | inline bool HasIndices() const { return !indices.empty(); } 46 | 47 | inline void Clear() 48 | { 49 | int vertexNum = vertices.size(); 50 | vertices.clear(); 51 | normals.clear(); 52 | colors.clear(); 53 | indices.clear(); 54 | vertices.reserve(vertexNum + 3); 55 | normals.reserve(vertexNum + 3); 56 | colors.reserve(vertexNum + 3); 57 | indices.reserve(vertexNum + 3); 58 | } 59 | 60 | 61 | Vec3List vertices; 62 | VertIndexList indices; 63 | Vec3List normals; 64 | Vec3List colors; 65 | Vec3 averageNoraml; 66 | Point3 chunkID; 67 | 68 | }; 69 | typedef std::shared_ptr MeshPtr; 70 | typedef std::shared_ptr MeshConstPtr; 71 | 72 | } // namespace chisel 73 | 74 | #endif // MESH_H_ 75 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/threading/Threading.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | #ifndef THREADING_H_ 24 | #define THREADING_H_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | 33 | namespace chisel 34 | { 35 | template 36 | void parallel_for(const Iterator& first, const Iterator& last, Function&& f, const int threshold = 1000) 37 | { 38 | 39 | static int nthreads = std::thread::hardware_concurrency() - 2; 40 | 41 | const auto group = std::max(std::max(ptrdiff_t(1), ptrdiff_t(std::abs(threshold))), ((last-first))/std::abs(nthreads)); 42 | std::vector threads; 43 | threads.reserve(nthreads); 44 | Iterator it = first; 45 | for (; it < last - group; it = std::min(it + group, last)) 46 | { 47 | threads.push_back(std::thread([=,&f](){std::for_each(it, std::min(it+group, last), f);})); 48 | } 49 | // last steps while we wait for other threads 50 | std::for_each(it, last, f); 51 | 52 | std::for_each(threads.begin(), threads.end(), [](std::thread& x){x.join();}); 53 | } 54 | } 55 | 56 | #endif // THREADING_H_ 57 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/truncation/ConstantTruncator.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef CONSTANTTRUNCATOR_H_ 23 | #define CONSTANTTRUNCATOR_H_ 24 | 25 | #include "Truncator.h" 26 | 27 | namespace chisel 28 | { 29 | 30 | class ConstantTruncator : public Truncator 31 | { 32 | public: 33 | ConstantTruncator() = default; 34 | 35 | ConstantTruncator(float value) : 36 | truncationDistance(value) 37 | { 38 | 39 | } 40 | 41 | virtual ~ConstantTruncator() 42 | { 43 | 44 | } 45 | 46 | inline void SetTruncationDistance(float value) { truncationDistance = value; } 47 | 48 | float GetTruncationDistance(float reading) const 49 | { 50 | return truncationDistance; 51 | } 52 | 53 | protected: 54 | float truncationDistance; 55 | 56 | }; 57 | typedef std::shared_ptr ConstantTruncatorPtr; 58 | typedef std::shared_ptr ConstantTruncatorConstPtr; 59 | 60 | } // namespace chisel 61 | 62 | #endif // CONSTANTTRUNCATOR_H_ 63 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/truncation/QuadraticTruncator.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef QUADRATICTRUNCATOR_H_ 23 | #define QUADRATICTRUNCATOR_H_ 24 | 25 | namespace chisel 26 | { 27 | 28 | class QuadraticTruncator : public Truncator 29 | { 30 | public: 31 | QuadraticTruncator() = default; 32 | 33 | QuadraticTruncator(float quadratic, float linear, float constant, float scale) : 34 | quadraticTerm(quadratic), linearTerm(linear), constantTerm(constant), scalingFactor(scale) 35 | { 36 | 37 | } 38 | 39 | virtual ~QuadraticTruncator() 40 | { 41 | 42 | } 43 | 44 | 45 | float GetTruncationDistance(float reading) const 46 | { 47 | return std::abs(GetQuadraticTerm() * pow(reading, 2) + GetLinearTerm() * reading + GetConstantTerm()) * scalingFactor; 48 | } 49 | 50 | inline float GetQuadraticTerm() const { return quadraticTerm; } 51 | inline float GetLinearTerm() const { return linearTerm; } 52 | inline float GetConstantTerm() const { return constantTerm; } 53 | inline float GetScalingFactor() const { return scalingFactor; } 54 | inline void SetQuadraticTerm(float value) { quadraticTerm = value; } 55 | inline void SetLinearTerm(float value) { linearTerm = value; } 56 | inline void SetConstantTerm(float value) { constantTerm = value; } 57 | inline void SetScalingFactor(float value) { scalingFactor = value; } 58 | 59 | protected: 60 | float quadraticTerm; 61 | float linearTerm; 62 | float constantTerm; 63 | float scalingFactor; 64 | 65 | }; 66 | typedef std::shared_ptr QuadraticTruncatorPtr; 67 | typedef std::shared_ptr QuadraticTruncatorConstPtr; 68 | 69 | } // namespace chisel 70 | 71 | #endif // QUADRATICTRUNCATOR_H_ 72 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/truncation/Truncator.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef TRUNCATOR_H_ 23 | #define TRUNCATOR_H_ 24 | 25 | namespace chisel 26 | { 27 | 28 | class Truncator 29 | { 30 | public: 31 | Truncator() = default; 32 | virtual ~Truncator() 33 | { 34 | 35 | } 36 | 37 | virtual float GetTruncationDistance(float depthReading) const = 0; 38 | }; 39 | 40 | typedef std::shared_ptr TruncatorPtr; 41 | typedef std::shared_ptr TruncatorConstPtr; 42 | } // namespace chisel 43 | 44 | #endif // TRUNCATOR_H_ 45 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/weighting/ConstantWeighter.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef CONSTANTWEIGHTER_H_ 23 | #define CONSTANTWEIGHTER_H_ 24 | 25 | #include "Weighter.h" 26 | 27 | namespace chisel 28 | { 29 | 30 | class ConstantWeighter : public Weighter 31 | { 32 | public: 33 | ConstantWeighter() = default; 34 | ConstantWeighter(float w) 35 | { 36 | weight = w; 37 | } 38 | virtual ~ConstantWeighter() 39 | { 40 | 41 | } 42 | 43 | virtual float GetWeight(float surfaceDist, float truncationDist) const 44 | { 45 | return weight / (2 * truncationDist); 46 | } 47 | 48 | protected: 49 | float weight; 50 | 51 | }; 52 | typedef std::shared_ptr ConstantWeighterPtr; 53 | typedef std::shared_ptr ConstantWeighterConstPtr; 54 | 55 | } // namespace chisel 56 | 57 | #endif // CONSTANTWEIGHTER_H_ 58 | -------------------------------------------------------------------------------- /CHISEL/src/open_chisel/weighting/Weighter.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // Copyright (c) 2014 Matthew Klingensmith and Ivan Dryanovski 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef WEIGHTER_H_ 23 | #define WEIGHTER_H_ 24 | 25 | namespace chisel 26 | { 27 | 28 | class Weighter 29 | { 30 | public: 31 | Weighter() = default; 32 | virtual ~Weighter() 33 | { 34 | 35 | } 36 | 37 | virtual float GetWeight(float surfaceDist, float truncationDist) const = 0; 38 | }; 39 | typedef std::shared_ptr WeighterPtr; 40 | typedef std::shared_ptr WeighterConstPtr; 41 | 42 | } // namespace chisel 43 | 44 | #endif // WEIGHTER_H_ 45 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(flashfusion) 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}") 5 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) 6 | message( "cmake path: " ${CMAKE_MODULE_PATH}) 7 | 8 | set(OpenCV_DIR "./third_party_library/opencv-3.3.0/build") 9 | set(Pangolin_DIR "./third_party_library/Pangolin-master/build") 10 | set(Sophus_DIR "./third_party_library/Sophus/build") 11 | set(SOPHUS_INCLUDE_DIR "./third_party_library/Sophus") 12 | 13 | 14 | set(GCFUSION_SHADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Shaders" CACHE PATH "Where the shaders live") 15 | 16 | 17 | find_package(OpenCV REQUIRED) 18 | find_package(OpenGL) 19 | find_package(GLUT) 20 | find_package(Chisel REQUIRED) 21 | find_package(OpenNI2 REQUIRED) 22 | find_package(Sophus REQUIRED) 23 | find_package(Pangolin 0.1 REQUIRED) 24 | find_package(PkgConfig) 25 | pkg_check_modules( EIGEN3 REQUIRED eigen3 ) 26 | find_package(Boost COMPONENTS system thread filesystem REQUIRED) 27 | 28 | set(realsense2_DIR "./third_party_library/librealsense-master/build") 29 | set(REALSENSE2_INCLUDE_DIRS "./third_party_library/librealsense-master/include") 30 | find_library(REALSENSE2_FOUND realsense2 HINTS ${realsense2_DIR} REQUIRED) 31 | 32 | if(NOT REALSENSE2_FOUND) 33 | message(WARN "Failed to find_library(realsense2)") 34 | else() 35 | message( STATUS "Realsense lib found: " ${REALSENSE2_FOUND}) 36 | message( STATUS "Realsense incl dir: " ${REALSENSE2_INCLUDE_DIRS}) 37 | endif() 38 | 39 | 40 | 41 | include_directories(${EIGEN3_INCLUDE_DIRS}) 42 | include_directories(${OpenCV_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ) 43 | include_directories(${Pangolin_INCLUDE_DIRS}) 44 | include_directories( ${SOPHUS_INCLUDE_DIR} ) 45 | include_directories( ${Boost_INCLUDE_DIR} ) 46 | include_directories(${CHISEL_INCLUDE_DIR}) 47 | include_directories(${OPENNI2_INCLUDE_DIR}) 48 | include_directories(${REALSENSE2_INCLUDE_DIRS}) 49 | 50 | add_definitions(-DWITH_REALSENSE) 51 | 52 | 53 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w") 54 | set(CMAKE_CXX_FLAGS ${ADDITIONAL_CMAKE_CXX_FLAGS} "-O3 -msse2 -msse3 -msse4.1 -Wall -std=c++14 -DSHADER_DIR=${GCFUSION_SHADER_DIR}") 55 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -ftree-vectorize -lboost_system -lpthread -lboost_thread -lboost_filesystem -mavx2") 56 | 57 | file(GLOB SOURCE_FILES 58 | "*.cpp" 59 | "*.h" 60 | "Tools/*.h" 61 | "Tools/*.cpp" 62 | "GCSLAM/*.cpp" 63 | "GCSLAM/*.h" 64 | "GCSLAM/MILD/*.cpp" 65 | "GCSLAM/MILD/*.h" 66 | "GCSLAM/ORBSLAM/*.cpp" 67 | "GCSLAM/ORBSLAM/*.h" 68 | "GCFusion/*.cpp" 69 | "GCFusion/*.h" 70 | "Shaders/*.cpp" 71 | "Shaders/*.h" 72 | ) 73 | 74 | add_executable(FlashFusion ${SOURCE_FILES}) 75 | target_link_libraries(FlashFusion ${OpenCV_LIBS} 76 | ${Eigen_LIBRARIES} 77 | ${Pangolin_LIBRARIES} 78 | ${CHISEL_LIBRARY} 79 | ${OPENNI2_LIBRARY} 80 | ${OPENGL_LIBRARIES} 81 | ${GLUT_LIBRARY} 82 | ${REALSENSE2_FOUND} 83 | ${pthread} 84 | ${Boost_LIBRARIES}) 85 | -------------------------------------------------------------------------------- /FindChisel.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find Chisel 3 | # 4 | # This sets the following variables: 5 | # EFUSION_FOUND - True if EFUSION was found. 6 | # EFUSION_INCLUDE_DIRS - Directories containing the EFUSION include files. 7 | # EFUSION_LIBRARIES - Libraries needed to use EFUSION. 8 | 9 | find_path(CHISEL_INCLUDE_DIR open_chisel/Chisel.h 10 | PATHS 11 | ${CMAKE_CURRENT_SOURCE_DIR}/CHISEL/src/ 12 | PATH_SUFFIXES CHISEL 13 | ) 14 | 15 | 16 | find_library(CHISEL_LIBRARY 17 | NAMES libchisel.so 18 | PATHS 19 | ${CMAKE_CURRENT_SOURCE_DIR}/CHISEL/build 20 | ${CMAKE_CURRENT_SOURCE_DIR}/CHISEL/src/build 21 | PATH_SUFFIXES ${CHISEL_PATH_SUFFIXES} 22 | ) 23 | 24 | set(CHISEL_INCLUDE_DIR ${CHISEL_INCLUDE_DIR}) 25 | message(STATUS "chisel dir: ${CHISEL_INCLUDE_DIR}") 26 | set(CHISEL_LIBRARIES ${CHISEL_LIBRARY}) 27 | 28 | include(FindPackageHandleStandardArgs) 29 | find_package_handle_standard_args(CHISEL DEFAULT_MSG CHISEL_LIBRARY CHISEL_INCLUDE_DIR) 30 | 31 | if(NOT WIN32) 32 | mark_as_advanced(CHISEL_LIBRARY CHISEL_INCLUDE_DIR) 33 | endif() 34 | 35 | 36 | -------------------------------------------------------------------------------- /FindLibRealSense.cmake: -------------------------------------------------------------------------------- 1 | # -*- mode: cmake; -*- 2 | ############################################################################### 3 | # Find librealsense https://github.com/IntelRealSense/librealsense 4 | # 5 | # This sets the following variables: 6 | # LIBREALSENSE_FOUND - True if OPENNI was found. 7 | # LIBREALSENSE_INCLUDE_DIRS - Directories containing the OPENNI include files. 8 | # LIBREALSENSE_LIBRARIES - Libraries needed to use OPENNI. 9 | # LIBREALSENSE_DEFINITIONS - Compiler flags for OPENNI. 10 | # 11 | # File forked from augmented_dev, project of alantrrs 12 | # (https://github.com/alantrrs/augmented_dev). 13 | 14 | find_package(PkgConfig) 15 | if(${CMAKE_VERSION} VERSION_LESS 2.8.2) 16 | endif() 17 | 18 | #add a hint so that it can find it without the pkg-config 19 | find_path(LIBREALSENSE_INCLUDE_DIR rs.h 20 | HINTS /usr/include/ /usr/local/include 21 | PATH_SUFFIXES librealsense) 22 | #add a hint so that it can find it without the pkg-config 23 | find_library(LIBREALSENSE_LIBRARY 24 | NAMES librealsense.so 25 | HINTS /usr/lib /usr/local/lib ) 26 | 27 | set(LIBREALSENSE_INCLUDE_DIRS ${LIBREALSENSE_INCLUDE_DIR}) 28 | set(LIBREALSENSE_LIBRARIES ${LIBREALSENSE_LIBRARY}) 29 | 30 | include(FindPackageHandleStandardArgs) 31 | find_package_handle_standard_args(LibRealSense DEFAULT_MSG 32 | LIBREALSENSE_LIBRARY LIBREALSENSE_INCLUDE_DIR) 33 | 34 | mark_as_advanced(LIBREALSENSE_LIBRARY LIBREALSENSE_INCLUDE_DIR) 35 | -------------------------------------------------------------------------------- /FindOpenNI2.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find OpenNI2 3 | # 4 | # This sets the following variables: 5 | # OPENNI2_FOUND - True if OPENNI was found. 6 | # OPENNI2_INCLUDE_DIRS - Directories containing the OPENNI include files. 7 | # OPENNI2_LIBRARIES - Libraries needed to use OPENNI. 8 | 9 | find_package(PkgConfig) 10 | if(${CMAKE_VERSION} VERSION_LESS 2.8.2) 11 | pkg_check_modules(PC_OPENNI openni2-dev) 12 | else() 13 | pkg_check_modules(PC_OPENNI QUIET openni2-dev) 14 | endif() 15 | 16 | set(OPENNI2_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER}) 17 | 18 | #add a hint so that it can find it without the pkg-config 19 | find_path(OPENNI2_INCLUDE_DIR OpenNI.h 20 | HINTS 21 | ${PC_OPENNI_INCLUDEDIR} 22 | ${PC_OPENNI_INCLUDE_DIRS} 23 | PATHS 24 | "${PROGRAM_FILES}/OpenNI2/Include" 25 | "${CMAKE_SOURCE_DIR}/../OpenNI2/Include" 26 | "${CMAKE_SOURCE_DIR}/../../OpenNI2/Include" 27 | "${CMAKE_SOURCE_DIR}/../../../OpenNI2/Include" 28 | "${CMAKE_SOURCE_DIR}/../../../../OpenNI2/Include" 29 | "${CMAKE_SOURCE_DIR}/../../../code/OpenNI2/Include" 30 | "${CMAKE_SOURCE_DIR}/../../../../code/OpenNI2/Include" 31 | "${CMAKE_SOURCE_DIR}/../deps/OpenNI2/Include" 32 | "${CMAKE_SOURCE_DIR}/../../deps/OpenNI2/Include" 33 | "${CMAKE_SOURCE_DIR}/../../../deps/OpenNI2/Include" 34 | "${CMAKE_SOURCE_DIR}/../../../../deps/OpenNI2/Include" 35 | /usr/include 36 | /user/include 37 | PATH_SUFFIXES openni2 ni2 38 | ) 39 | 40 | if(${CMAKE_CL_64}) 41 | set(OPENNI_PATH_SUFFIXES lib64) 42 | else() 43 | set(OPENNI_PATH_SUFFIXES lib) 44 | endif() 45 | 46 | #add a hint so that it can find it without the pkg-config 47 | find_library(OPENNI2_LIBRARY 48 | NAMES OpenNI2 49 | HINTS 50 | ${PC_OPENNI_LIBDIR} 51 | ${PC_OPENNI_LIBRARY_DIRS} 52 | PATHS 53 | "${PROGRAM_FILES}}/OpenNI2/Redist" 54 | "${PROGRAM_FILES}/OpenNI2" 55 | "${CMAKE_SOURCE_DIR}/../OpenNI2/Bin/x64-Release" 56 | "${CMAKE_SOURCE_DIR}/../../OpenNI2/Bin/x64-Release" 57 | "${CMAKE_SOURCE_DIR}/../../../OpenNI2/Bin/x64-Release" 58 | "${CMAKE_SOURCE_DIR}/../../../../OpenNI2/Bin/x64-Release" 59 | "${CMAKE_SOURCE_DIR}/../../../code/OpenNI2/Bin/x64-Release" 60 | "${CMAKE_SOURCE_DIR}/../../../../code/OpenNI2/Bin/x64-Release" 61 | "${CMAKE_SOURCE_DIR}/../deps/OpenNI2/Bin/x64-Release" 62 | "${CMAKE_SOURCE_DIR}/../../deps/OpenNI2/Bin/x64-Release" 63 | "${CMAKE_SOURCE_DIR}/../../../deps/OpenNI2/Bin/x64-Release" 64 | "${CMAKE_SOURCE_DIR}/../../../../deps/OpenNI2/Bin/x64-Release" 65 | /usr/lib 66 | /user/lib 67 | PATH_SUFFIXES ${OPENNI_PATH_SUFFIXES} 68 | ) 69 | 70 | set(OPENNI2_INCLUDE_DIRS ${OPENNI2_INCLUDE_DIR}) 71 | set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY}) 72 | 73 | include(FindPackageHandleStandardArgs) 74 | find_package_handle_standard_args(OpenNI2 DEFAULT_MSG 75 | OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR) 76 | 77 | mark_as_advanced(OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR) 78 | -------------------------------------------------------------------------------- /FindRealSense.cmake: -------------------------------------------------------------------------------- 1 | set(REALSENSE_ROOT "/home/luvision/library/librealsense-2.10.4" CACHE PATH "Root directory of libREALSENSE") 2 | 3 | FIND_PATH(REALSENSE_INCLUDE_DIR libREALSENSE HINTS "${REALSENSE_ROOT}/include") 4 | FIND_LIBRARY(REALSENSE_LIBRARY REALSENSE HINTS "${REALSENSE_ROOT}/bin/x64" "${REALSENSE_ROOT}/lib") 5 | 6 | mark_as_advanced(REALSENSE_LIBRARY REALSENSE_INCLUDE_DIR) 7 | 8 | -------------------------------------------------------------------------------- /FindSophus.cmake: -------------------------------------------------------------------------------- 1 | if (SOPHUS_INCLUDE_DIR) 2 | 3 | else (SOPHUS_INCLUDE_DIR) 4 | 5 | find_path(SOPHUS_INCLUDE_DIR NAMES sophus 6 | PATHS 7 | ${CMAKE_INSTALL_PREFIX}/include 8 | #add path to local build, if build from src 9 | ) 10 | 11 | endif(SOPHUS_INCLUDE_DIR) 12 | 13 | -------------------------------------------------------------------------------- /GCFusion.config: -------------------------------------------------------------------------------- 1 | // Add predefined macros for your project here. For example: 2 | // #define THE_ANSWER 42 3 | -------------------------------------------------------------------------------- /GCFusion.creator: -------------------------------------------------------------------------------- 1 | [General] 2 | -------------------------------------------------------------------------------- /GCSLAM/GCSLAM.h: -------------------------------------------------------------------------------- 1 | #ifndef GCSLAM_H 2 | #define GCSLAM_H 3 | #include "MultiViewGeometry.h" 4 | #include 5 | 6 | 7 | 8 | class GCSLAM 9 | { 10 | 11 | public: 12 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW 13 | GCSLAM() 14 | { 15 | GCSLAM_INIT_FLAG = 0; 16 | minimumDisparity = 0.1; 17 | salientScoreThreshold = 1.0; 18 | maxCandidateNum = 5; 19 | } 20 | void init(const int maximum_frame_num, const MultiViewGeometry::CameraPara &camera_para_t) 21 | { 22 | GCSLAM_INIT_FLAG = 1; 23 | mild.init(FEATURE_TYPE_ORB, 16, 0); 24 | keyFrameCorrList.reserve(maximum_frame_num * 5); 25 | KeyframeDataList.reserve(maximum_frame_num); 26 | globalFrameList.reserve(maximum_frame_num); 27 | camera_para = camera_para_t; 28 | } 29 | 30 | 31 | 32 | void finalBA(std::vector &frame_list) 33 | { 34 | 35 | std::vector &fCorrList_keyframes = keyFrameCorrList; 36 | std::vector &kflist = KeyframeDataList; 37 | initGraphHuberNorm(fCorrList_keyframes,frame_list); 38 | MultiViewGeometry::optimizeKeyFrameMap(fCorrList_keyframes, frame_list, kflist,0); 39 | } 40 | 41 | 42 | 43 | void select_closure_candidates(Frame &f, std::vector &candidate_frame_index); 44 | 45 | void update_keyframe(int newKeyFrameIndex, 46 | MultiViewGeometry::FrameCorrespondence &key_frame_corr, 47 | float average_disparity, 48 | PoseSE3d relative_pose_from_key_to_new, 49 | int registration_success); 50 | 51 | /* 52 | frame_input will be added into frame database, and matched with previous keyframes 53 | if the disparity between frame_input and previous keyframe is larger than a threshold, frame_input is recogonized as a new keyframe 54 | FastBA is activated if new keyframe is inserted, and all previous frames' poses are updated 55 | */ 56 | void update_frame(Frame &frame_input); 57 | 58 | 59 | void updateMapOrigin(std::vector &fCorrCandidate, 60 | std::vector ®istration_success_list, int newKeyFrameIndex); 61 | inline const std::vector & GetKeyframeDataList() {return KeyframeDataList;} 62 | 63 | 64 | 65 | 66 | void SetMinimumDisparity(float inputMinDisp) { minimumDisparity = inputMinDisp; } 67 | void SetMaxCandidateNum(int inputMaxCandidateNum) {maxCandidateNum = inputMaxCandidateNum; } 68 | void SetSalientScoreThreshold(float salientThreshold) {salientScoreThreshold = salientThreshold; } 69 | 70 | std::vector globalFrameList; // database for all frames 71 | std::vector keyFrameCorrList; // database for matched keyframe pairs 72 | std::vector KeyframeDataList; // database for all keyframes 73 | 74 | private: 75 | 76 | int GCSLAM_INIT_FLAG; 77 | MILD::LoopClosureDetector mild; // interface for loop closure detector 78 | MultiViewGeometry::CameraPara camera_para; // camera parameters 79 | 80 | float minimumDisparity; // minimum disparity to update keyframes 81 | float salientScoreThreshold; // minimum salient score for loop closures 82 | int maxCandidateNum; // maximum closure candidate num 83 | }; 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /GCSLAM/MILD/mild.hpp: -------------------------------------------------------------------------------- 1 | // MILD : Multi-Index based Loop closure Detection 2 | #pragma once 3 | #ifndef MILD_H 4 | #define MILD_H 5 | 6 | #include 7 | #include 8 | 9 | #include "lightweight_vector.hpp" 10 | 11 | 12 | typedef int64_t __int64; 13 | namespace MILD 14 | { 15 | 16 | 17 | 18 | #define FEATURE_TYPE_ORB 1 19 | #define FEATURE_TYPE_BRISK 2 20 | #define ORB_DESCRIPTOR_LEN 256 21 | #define BRISK_DESCRIPTOR_LEN 512 22 | 23 | #define DEFAULT_MAX_UNIT_NUM_PER_ENTRY 200 24 | #define DEFAULT_HAMMING_DISTANCE_THRESHOLD (64) 25 | #define HAMMING_COVARIANCE (900.0f) // used in calculating feature similarity 26 | 27 | #define DEBUG_MODE_MILD 0 28 | 29 | // cunstrcut hash table index 30 | // mapping from desc to entry_idx 31 | inline void multi_index_hashing(std::vector &entry_idx, unsigned int * desc, 32 | int hash_table_num, int bits_per_substring) 33 | { 34 | 35 | if(bits_per_substring == 16) 36 | { 37 | 38 | unsigned short * entry_value = (unsigned short *)desc; 39 | for (int i = 0; i < hash_table_num; i++) 40 | { 41 | entry_idx[i] = entry_value[i]; 42 | } 43 | } 44 | else 45 | { 46 | unsigned long index = 0; 47 | unsigned int mask[32]; 48 | for (int j = 0; j < 32; j++) 49 | { 50 | mask[j] = 0; 51 | for (int i = 0; i < j; i++) 52 | { 53 | mask[j] += 1 << i; 54 | } 55 | } 56 | for (int i = 0; i < hash_table_num; i++) 57 | { 58 | int si = (bits_per_substring * i) / 32; 59 | int ei = (bits_per_substring * (i + 1)) / 32; 60 | int sp = (bits_per_substring * i) % 32; 61 | int ep = (bits_per_substring * (i + 1)) % 32; 62 | if (si == ei) 63 | { 64 | index = (desc[si] >> sp) & mask[bits_per_substring]; 65 | } 66 | if (si < ei) 67 | { 68 | index = ((desc[si] >> sp) & mask[32 - sp]) + ((desc[ei] & mask[ep]) << (bits_per_substring - ep)); 69 | } 70 | 71 | entry_idx[i] = index; 72 | } 73 | } 74 | 75 | } 76 | 77 | // output neighbor_entry_idx of entry_idx, whose hamming distance is less than my_depth_leve. 78 | inline void generate_neighbor_candidates(int my_depth_level, unsigned long entry_idx, std::vector &neighbor_entry_idx, int bits_per_substring) 79 | { 80 | if (my_depth_level <= 0) 81 | { 82 | return; 83 | } 84 | my_depth_level--; 85 | for (int i = 0; i < bits_per_substring; i++) 86 | { 87 | unsigned long nidx = entry_idx ^ (1 << i); 88 | int redundancy_flag = 0; 89 | for (int j = 0; j < neighbor_entry_idx.size(); j++) 90 | { 91 | if (nidx == neighbor_entry_idx[j]) 92 | { 93 | redundancy_flag = 1; 94 | } 95 | } 96 | if (redundancy_flag == 0) 97 | { 98 | neighbor_entry_idx.push_back(nidx); 99 | } 100 | generate_neighbor_candidates(my_depth_level, nidx, neighbor_entry_idx, bits_per_substring); 101 | } 102 | return; 103 | } 104 | 105 | 106 | } 107 | 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FlashFusion: An efficient dense 3D reconstruction that only relies on CPU computing. 2 | 3 | ## Introduction 4 | This is the official code repository for FlashFusion, an efficient dense 3D reconstruction system that only relies on CPU computing. 5 | 6 | This is a project from LuVision SIGMA, Tsinghua University. Visit our website for more interesting works: http://www.luvision.net/ 7 | 8 | ## License 9 | This project is released under the [GPLv3 license](LICENSE). We only allow free use for academic use. For commercial use, please contact us to negotiate a different license by: `fanglu at tsinghua.edu.cn` 10 | 11 | ## Citing 12 | 13 | If you find our code useful, please kindly cite the following papers: 14 | 15 | ```bibtex 16 | @inproceedings{han2018flashfusion, 17 | title={FlashFusion: Real-time Globally Consistent Dense 3D Reconstruction using CPU Computing.}, 18 | author={Han, Lei and Fang, Lu}, 19 | booktitle={Robotics: Science and Systems}, 20 | volume={1}, 21 | number={6}, 22 | pages={7}, 23 | year={2018} 24 | } 25 | ``` 26 | ```bibtex 27 | @ARTICLE{8606275, 28 | author={Han, Lei and Xu, Lan and Bobkov, Dmytro and Steinbach, Eckehard and Fang, Lu}, 29 | journal={IEEE Transactions on Robotics}, 30 | title={Real-Time Global Registration for Globally Consistent RGB-D SLAM}, 31 | year={2019}, 32 | volume={35}, 33 | number={2}, 34 | pages={498-508}, 35 | doi={10.1109/TRO.2018.2882730}} 36 | ``` 37 | 38 | 39 | ## Environment setup 40 | 41 | ### Preliminary Requirements: 42 | * Ubuntu 16.04/18.04 43 | * Intel cpu 44 | 45 | ### Compile 46 | ```bash 47 | source prepare.sh 48 | mkdir build 49 | cd build 50 | cmake .. 51 | make -j 52 | ``` 53 | 54 | ### Data preparation 55 | The format of offline dataset follows TUM RGBD Dataset. 56 | Example sequences can be downloaded at http://221.228.239.253:81/opensource_data/FlashFusion/dataset.zip 57 | Put the dataset at `dataset/`, organized as 58 | ``` 59 | dataset 60 | |---- iclnuim 61 | |---- tum 62 | |---- xtion 63 | ``` 64 | 65 | ### Usage 66 | ``` 67 | sudo ./FlashFusion sensor_type calib_file voxel_size dataset_path 68 | 69 | sensor_type: 0:dataset 1:realtime openni_camera(such as xtion) 2: realtime realsense_camera 70 | 71 | Example: 72 | sudo ./FlashFusion 0 ../param/calib_tum.txt 0.005 ../dataset/tum/fr1_desk/ 73 | sudo ./FlashFusion 0 ../param/calib_icl.txt 0.005 ../dataset/iclnuim/icl0n/ 74 | sudo ./FlashFusion 0 ../param/calib_xtion.txt 0.005 ../dataset/xtion/ 75 | 76 | sudo ./FlashFusion 1 ../param/calib_xtion.txt 0.005 77 | 78 | ``` 79 | -------------------------------------------------------------------------------- /Shaders/Defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was written for porting ElasticFusion to windows 3 | * by Filip Srajer (filip.srajer@inf.ethz.ch). 4 | * 5 | */ 6 | 7 | #pragma once 8 | 9 | #ifndef WIN32 10 | # define EFUSION_API 11 | #else 12 | # ifdef efusion_EXPORTS 13 | # define EFUSION_API __declspec(dllexport) 14 | # else 15 | # define EFUSION_API __declspec(dllimport) 16 | # endif 17 | #endif 18 | -------------------------------------------------------------------------------- /Shaders/Parse.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #include "Parse.h" 20 | 21 | Parse::Parse() 22 | { 23 | 24 | } 25 | 26 | const Parse & Parse::get() 27 | { 28 | static const Parse instance; 29 | return instance; 30 | } 31 | 32 | int Parse::arg(int argc, char** argv, const char* str, std::string &val) const 33 | { 34 | int index = findArg(argc, argv, str) + 1; 35 | 36 | if(index > 0 && index < argc) 37 | { 38 | val = argv[index]; 39 | } 40 | 41 | return index - 1; 42 | } 43 | 44 | int Parse::arg(int argc, char** argv, const char* str, float &val) const 45 | { 46 | int index = findArg(argc, argv, str) + 1; 47 | 48 | if(index > 0 && index < argc) 49 | { 50 | val = atof(argv[index]); 51 | } 52 | 53 | return index - 1; 54 | } 55 | 56 | int Parse::arg(int argc, char** argv, const char* str, int &val) const 57 | { 58 | int index = findArg(argc, argv, str) + 1; 59 | 60 | if(index > 0 && index < argc) 61 | { 62 | val = atoi(argv[index]); 63 | } 64 | 65 | return index - 1; 66 | } 67 | 68 | std::string Parse::shaderDir() const 69 | { 70 | std::string currentVal = STR(SHADER_DIR); 71 | 72 | assert(pangolin::FileExists(currentVal) && "Shader directory not found!"); 73 | 74 | return currentVal; 75 | } 76 | 77 | std::string Parse::baseDir() const 78 | { 79 | char buf[256]; 80 | #ifdef WIN32 81 | int length = GetModuleFileName(NULL,buf,sizeof(buf)); 82 | #else 83 | int length = readlink("/proc/self/exe",buf,sizeof(buf)); 84 | #endif 85 | std::string currentVal; 86 | currentVal.append((char *)&buf, length); 87 | 88 | currentVal = currentVal.substr(0, currentVal 89 | #ifdef WIN32 90 | .rfind("\\build\\")); 91 | #else 92 | .rfind("/build/")); 93 | #endif 94 | return currentVal; 95 | } 96 | 97 | int Parse::findArg(int argc, char** argv, const char* argument_name) const 98 | { 99 | for(int i = 1; i < argc; ++i) 100 | { 101 | // Search for the string 102 | if(strcmp(argv[i], argument_name) == 0) 103 | { 104 | return i; 105 | } 106 | } 107 | return -1; 108 | } 109 | -------------------------------------------------------------------------------- /Shaders/Parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | #ifndef PARSE_H_ 19 | #define PARSE_H_ 20 | 21 | #ifdef WIN32 22 | # include 23 | #else 24 | # include 25 | #endif 26 | 27 | #include 28 | #include 29 | #ifndef WIN32 30 | # include 31 | #endif 32 | #include 33 | #include 34 | 35 | #include "Defines.h" 36 | 37 | #define XSTR(x) #x 38 | #define STR(x) XSTR(x) 39 | 40 | class Parse 41 | { 42 | public: 43 | EFUSION_API static const Parse & get(); 44 | 45 | EFUSION_API int arg(int argc, char** argv, const char* str, std::string &val) const; 46 | 47 | EFUSION_API int arg(int argc, char** argv, const char* str, float &val) const; 48 | 49 | EFUSION_API int arg(int argc, char** argv, const char* str, int &val) const; 50 | 51 | EFUSION_API std::string shaderDir() const; 52 | 53 | EFUSION_API std::string baseDir() const; 54 | 55 | private: 56 | EFUSION_API Parse(); 57 | 58 | EFUSION_API int findArg(int argc,char** argv,const char* argument_name) const; 59 | }; 60 | 61 | #endif /* PARSE_H_ */ 62 | -------------------------------------------------------------------------------- /Shaders/Uniform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #ifndef UNIFORM_H_ 20 | #define UNIFORM_H_ 21 | 22 | #include 23 | #include 24 | 25 | class Uniform 26 | { 27 | public: 28 | Uniform(const std::string & id, const int & v) 29 | : id(id), 30 | i(v), 31 | t(INT) 32 | {} 33 | 34 | Uniform(const std::string & id, const float & v) 35 | : id(id), 36 | f(v), 37 | t(FLOAT) 38 | {} 39 | 40 | Uniform(const std::string & id, const Eigen::Vector2f & v) 41 | : id(id), 42 | v2(v), 43 | t(VEC2) 44 | {} 45 | 46 | Uniform(const std::string & id, const Eigen::Vector3f & v) 47 | : id(id), 48 | v3(v), 49 | t(VEC3) 50 | {} 51 | 52 | Uniform(const std::string & id, const Eigen::Vector4f & v) 53 | : id(id), 54 | v4(v), 55 | t(VEC4) 56 | {} 57 | 58 | Uniform(const std::string & id, const Eigen::Matrix4f & v) 59 | : id(id), 60 | m4(v), 61 | t(MAT4) 62 | {} 63 | 64 | std::string id; 65 | 66 | int i; 67 | float f; 68 | Eigen::Vector2f v2; 69 | Eigen::Vector3f v3; 70 | Eigen::Vector4f v4; 71 | Eigen::Matrix4f m4; 72 | 73 | enum Type 74 | { 75 | INT, 76 | FLOAT, 77 | VEC2, 78 | VEC3, 79 | VEC4, 80 | MAT4, 81 | NONE 82 | }; 83 | 84 | Type t; 85 | }; 86 | 87 | 88 | #endif /* UNIFORM_H_ */ 89 | -------------------------------------------------------------------------------- /Shaders/Vertex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #include "Vertex.h" 20 | 21 | /* 22 | * OK this is the structure 23 | * 24 | *-------------------- 25 | * vec3 position 26 | * float confidence 27 | * 28 | * float color (encoded as a 24-bit integer) 29 | * float 30 | * float initTime 31 | * float timestamp 32 | * 33 | * vec3 normal 34 | * float radius 35 | *-------------------- 36 | 37 | * Which is three vec4s 38 | */ 39 | 40 | const int Vertex::SIZE = sizeof(Eigen::Vector4f) * 3; 41 | -------------------------------------------------------------------------------- /Shaders/Vertex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #ifndef VERTEX_H_ 20 | #define VERTEX_H_ 21 | 22 | #include 23 | 24 | #include "Defines.h" 25 | 26 | class Vertex 27 | { 28 | public: 29 | EFUSION_API static const int SIZE; 30 | 31 | private: 32 | Vertex(){} 33 | }; 34 | 35 | 36 | #endif /* VERTEX_H_ */ 37 | -------------------------------------------------------------------------------- /Shaders/color.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | float encodeColor(vec3 c) 20 | { 21 | int rgb = int(round(c.x * 255.0f)); 22 | rgb = (rgb << 8) + int(round(c.y * 255.0f)); 23 | rgb = (rgb << 8) + int(round(c.z * 255.0f)); 24 | return float(rgb); 25 | } 26 | 27 | vec3 decodeColor(float c) 28 | { 29 | vec3 col; 30 | col.x = float(int(c) >> 16 & 0xFF) / 255.0f; 31 | col.y = float(int(c) >> 8 & 0xFF) / 255.0f; 32 | col.z = float(int(c) & 0xFF) / 255.0f; 33 | return col; 34 | } 35 | -------------------------------------------------------------------------------- /Shaders/combo_splat.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | uniform vec4 cam; //cx, cy, fx, fy 22 | uniform float maxDepth; 23 | 24 | in vec4 position; 25 | in vec4 normRad; 26 | in vec4 colTime; 27 | 28 | layout(location = 0) out vec4 image; 29 | layout(location = 1) out vec4 vertex; 30 | layout(location = 2) out vec4 normal; 31 | layout(location = 3) out uint time; 32 | 33 | #include "color.glsl" 34 | 35 | void main() 36 | { 37 | vec3 l = normalize(vec3((vec2(gl_FragCoord) - cam.xy) / cam.zw, 1.0f)); 38 | 39 | vec3 corrected_pos = (dot(position.xyz, normRad.xyz) / dot(l, normRad.xyz)) * l; 40 | 41 | //check if the intersection is inside the surfel 42 | float sqrRad = pow(normRad.w, 2); 43 | vec3 diff = corrected_pos - position.xyz; 44 | 45 | if(dot(diff, diff) > sqrRad) 46 | { 47 | discard; 48 | } 49 | 50 | image = vec4(decodeColor(colTime.x), 1); 51 | 52 | float z = corrected_pos.z; 53 | 54 | vertex = vec4((gl_FragCoord.x - cam.x) * z * (1.f / cam.z), (gl_FragCoord.y - cam.y) * z * (1.f / cam.w), z, position.w); 55 | 56 | normal = normRad; 57 | 58 | time = uint(colTime.z); 59 | 60 | gl_FragDepth = (corrected_pos.z / (2 * maxDepth)) + 0.5f; 61 | } 62 | -------------------------------------------------------------------------------- /Shaders/copy_unstable.geom: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout(points) in; 22 | layout(points, max_vertices = 1) out; 23 | 24 | in vec4 vPosition[]; 25 | in vec4 vColor[]; 26 | in vec4 vNormRad[]; 27 | flat in int test[]; 28 | 29 | out vec4 vPosition0; 30 | out vec4 vColor0; 31 | out vec4 vNormRad0; 32 | 33 | void main() 34 | { 35 | if(test[0] > 0) 36 | { 37 | vPosition0 = vPosition[0]; 38 | vColor0 = vColor[0]; 39 | vNormRad0 = vNormRad[0]; 40 | EmitVertex(); 41 | EndPrimitive(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Shaders/data.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec4 vPosition0; 22 | in vec4 vColor0; 23 | in vec4 vNormRad0; 24 | flat in int updateId0; 25 | 26 | layout(location = 0) out vec4 vPosition1; 27 | layout(location = 1) out vec4 vColor1; 28 | layout(location = 2) out vec4 vNormRad1; 29 | 30 | void main() 31 | { 32 | //If we have a point to update in the existing model, store that 33 | if(updateId0 == 1) 34 | { 35 | vPosition1 = vPosition0; 36 | vColor1 = vColor0; 37 | vNormRad1 = vNormRad0; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Shaders/data.geom: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout(points) in; 22 | layout(points, max_vertices = 1) out; 23 | 24 | in vec4 vPosition[]; 25 | in vec4 vColor[]; 26 | in vec4 vNormRad[]; 27 | flat in int updateId[]; 28 | 29 | out vec4 vPosition0; 30 | out vec4 vColor0; 31 | out vec4 vNormRad0; 32 | flat out int updateId0; 33 | 34 | void main() 35 | { 36 | //Emit a vertex if either we have an update to store, or a new unstable vertex to store 37 | if(updateId[0] > 0) 38 | { 39 | vPosition0 = vPosition[0]; 40 | vColor0 = vColor[0]; 41 | vNormRad0 = vNormRad[0]; 42 | updateId0 = updateId[0]; 43 | 44 | //This will be -10, -10 (offscreen) for new unstable vertices, so they don't show in the fragment shader 45 | gl_Position = gl_in[0].gl_Position; 46 | 47 | EmitVertex(); 48 | EndPrimitive(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Shaders/depth_bilateral.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec2 texcoord; 22 | 23 | out uint FragColor; 24 | 25 | uniform usampler2D gSampler; 26 | uniform float cols; 27 | uniform float rows; 28 | uniform float maxD; 29 | 30 | void main() 31 | { 32 | uint value = uint(texture(gSampler, texcoord.xy)); 33 | 34 | if(value > uint(maxD * 1000.0f) || value < 300U) 35 | { 36 | FragColor = 0U; 37 | } 38 | else 39 | { 40 | int x = int(texcoord.x * cols); 41 | int y = int(texcoord.y * rows); 42 | 43 | const float sigma_space2_inv_half = 0.024691358; // 0.5 / (sigma_space * sigma_space) 44 | const float sigma_color2_inv_half = 0.000555556; // 0.5 / (sigma_color * sigma_color) 45 | 46 | const int R = 6; 47 | const int D = R * 2 + 1; 48 | 49 | int tx = min(x - D / 2 + D, int(cols)); 50 | int ty = min(y - D / 2 + D, int(rows)); 51 | 52 | float sum1 = 0; 53 | float sum2 = 0; 54 | 55 | for(int cy = max(y - D / 2, 0); cy < ty; ++cy) 56 | { 57 | for(int cx = max(x - D / 2, 0); cx < tx; ++cx) 58 | { 59 | float texX = float(cx) / cols; 60 | float texY = float(cy) / rows; 61 | 62 | uint tmp = uint(texture(gSampler, vec2(texX, texY))); 63 | 64 | float space2 = (float(x) - float(cx)) * (float(x) - float(cx)) + (float(y) - float(cy)) * (float(y) - float(cy)); 65 | float color2 = (float(value) - float(tmp)) * (float(value) - float(tmp)); 66 | 67 | float weight = exp(-(space2 * sigma_space2_inv_half + color2 * sigma_color2_inv_half)); 68 | 69 | sum1 += float(tmp) * weight; 70 | sum2 += weight; 71 | } 72 | } 73 | 74 | FragColor = uint(round(sum1/sum2)); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Shaders/depth_metric.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec2 texcoord; 22 | 23 | out float FragColor; 24 | 25 | uniform usampler2D gSampler; 26 | uniform float maxD; 27 | 28 | void main() 29 | { 30 | uint value = uint(texture(gSampler, texcoord.xy)); 31 | 32 | if(value > uint(maxD * 1000.0f) || value < 300U) 33 | { 34 | FragColor = 0U; 35 | } 36 | else 37 | { 38 | FragColor = float(value) / 1000.0f; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Shaders/depth_norm.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec2 texcoord; 22 | 23 | out float FragColor; 24 | 25 | uniform usampler2D gSampler; 26 | uniform float minVal; 27 | uniform float maxVal; 28 | 29 | void main() 30 | { 31 | uint value = uint(texture(gSampler, texcoord.xy)); 32 | if(value > uint(minVal) && value < uint(maxVal)) 33 | FragColor = 1.0f - (value / maxVal); 34 | else 35 | FragColor = 0; 36 | } 37 | -------------------------------------------------------------------------------- /Shaders/depth_splat.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | uniform vec4 cam; //cx, cy, fx, fy 22 | uniform float maxDepth; 23 | 24 | in vec4 position; 25 | in vec4 normRad; 26 | 27 | out float FragColor; 28 | 29 | void main() 30 | { 31 | vec3 l = normalize(vec3((vec2(gl_FragCoord) - cam.xy) / cam.zw, 1.0f)); 32 | 33 | vec3 corrected_pos = (dot(position.xyz, normRad.xyz) / dot(l, normRad.xyz)) * l; 34 | 35 | //check if the intersection is inside the surfel 36 | float sqrRad = pow(normRad.w, 2); 37 | vec3 diff = corrected_pos - position.xyz; 38 | 39 | if(dot(diff, diff) > sqrRad) 40 | { 41 | discard; 42 | } 43 | 44 | FragColor = corrected_pos.z; 45 | 46 | gl_FragDepth = (corrected_pos.z / (2 * maxDepth)) + 0.5f; 47 | } 48 | -------------------------------------------------------------------------------- /Shaders/draw_feedback.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec4 vColor; 22 | 23 | out vec4 FragColor; 24 | 25 | void main() 26 | { 27 | FragColor = vColor; 28 | } 29 | -------------------------------------------------------------------------------- /Shaders/draw_feedback.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 130 core 20 | 21 | layout (location = 0) in vec4 position; 22 | layout (location = 1) in vec4 color; 23 | layout (location = 2) in vec4 normal; 24 | 25 | uniform mat4 MVP; 26 | uniform mat4 pose; 27 | uniform float threshold; 28 | uniform int colorType; 29 | uniform int time; 30 | uniform int timeDelta; 31 | 32 | out vec4 vColor; 33 | 34 | #include "color.glsl" 35 | 36 | void main() 37 | { 38 | if(position.w > threshold) 39 | { 40 | if(colorType == 1) 41 | { 42 | vColor = vec4(normal.xyz, 1.0); 43 | } 44 | else if(colorType == 2) 45 | { 46 | vColor = vec4(decodeColor(color.x), 1.0); 47 | } 48 | else if(colorType == 3) 49 | { 50 | vColor = vec4(decodeColor(color.x), 1.0); 51 | float minimum = 1.0f; 52 | float maximum = 300; 53 | float ctime = color.z - (int(color.z /300)) * 300; 54 | ctime = min(ctime, maximum); 55 | ctime = max(ctime, 0); 56 | vColor.x = min(1, 3 * ctime / maximum ); 57 | vColor.y = min(1, max(0, (3 * ctime - maximum) / maximum )); 58 | vColor.z = min(1, max(0, (3 * ctime - 2 * maximum) / maximum )); 59 | } 60 | else 61 | { 62 | vColor = vec4((vec3(.5f, .5f, .5f) * abs(dot(normal.xyz, vec3(1.0, 1.0, 1.0)))) + vec3(0.1f, 0.1f, 0.1f), 1.0f); 63 | } 64 | gl_Position = MVP * pose * vec4(position.xyz, 1.0); 65 | } 66 | else 67 | { 68 | gl_Position = vec4(-10, -10, 0, 1); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Shaders/draw_feedback_Phong.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 450 core 20 | 21 | 22 | uniform vec3 Lightla; 23 | uniform vec3 Lightld; 24 | uniform vec3 Lightls; 25 | uniform vec3 Lightldir; 26 | uniform vec3 fma; 27 | uniform vec3 fmd; 28 | uniform vec3 fms; 29 | uniform float fss; 30 | uniform vec3 bma; 31 | uniform vec3 bmd; 32 | uniform vec3 bms; 33 | uniform float bss; 34 | 35 | uniform int colorType; 36 | in VS_OUT 37 | { 38 | vec3 v; 39 | vec3 fn; 40 | vec3 bn; 41 | vec4 vColor; 42 | } fs_in; 43 | 44 | 45 | out vec4 FragColor; 46 | 47 | void main() 48 | { 49 | vec4 PhongColor; 50 | vec3 ldir = normalize(-Lightldir); 51 | vec3 fn = normalize(fs_in.fn); 52 | vec3 bn = normalize(fs_in.bn); 53 | vec3 vdir = normalize(-fs_in.v); 54 | vec3 frdir = reflect(-ldir, fn); 55 | vec3 brdir = reflect(-ldir, bn); 56 | if (gl_FrontFacing) { 57 | vec3 ka = Lightla * fma; 58 | vec3 kd = Lightld * fmd; 59 | vec3 ks = Lightls * fms; 60 | /*calculate Phong lighting of front-facing fragment*/ 61 | vec3 fca = ka; 62 | vec3 fcd = kd * max(dot(fn, ldir), 0.0); 63 | vec3 fcs = ks * pow(max(dot(vdir, frdir), 0.0), fss); 64 | vec3 fc = clamp(fca + fcd + fcs, 0.0, 1.0); 65 | PhongColor = vec4(fc, 1.0); 66 | } 67 | else{ 68 | vec3 ka = Lightla * bma; 69 | vec3 kd = Lightld * bmd; 70 | vec3 ks = Lightls * bms; 71 | /*calculate Phong lighting of back-facing fragment*/ 72 | vec3 bca = ka; 73 | vec3 bcd = kd * max(dot(bn, ldir), 0.0); 74 | vec3 bcs = ks * pow(max(dot(vdir, brdir), 0.0), bss); 75 | vec3 bc = clamp(bca + bcd + bcs, 0.0, 1.0); 76 | PhongColor = vec4(bc, 1.0); 77 | } 78 | 79 | if(colorType == 1 || colorType == 2 || colorType == 3) 80 | { 81 | FragColor = fs_in.vColor; 82 | // FragColor = vec4(fss/2,fss/2,fss/2,1.0); 83 | // if(colorType == 1) 84 | // { 85 | // FragColor = vec4(fma,1); 86 | // } 87 | // if(colorType == 2) 88 | // { 89 | // FragColor = vec4(fms, 1); 90 | // } 91 | // if(colorType == 3) 92 | // { 93 | // FragColor = vec4(fmd, 1); 94 | //} 95 | } 96 | else 97 | { 98 | FragColor = PhongColor; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Shaders/draw_feedback_Phong.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 450 core 20 | 21 | layout (location = 0) in vec4 position; 22 | layout (location = 1) in vec4 color; 23 | layout (location = 2) in vec4 normal; 24 | 25 | uniform mat4 proj_matrix; 26 | uniform mat4 view_matrix; 27 | uniform float threshold; 28 | uniform int colorType; 29 | uniform int time; 30 | uniform int timeDelta; 31 | 32 | 33 | uniform mat4 user_view_matrix; 34 | uniform mat4 user_light_matrix; 35 | uniform vec4 user_rot_center; 36 | 37 | out VS_OUT 38 | { 39 | vec3 v; 40 | vec3 fn; 41 | vec3 bn; 42 | vec4 vColor; 43 | } vs_out; 44 | 45 | 46 | 47 | #include "color.glsl" 48 | 49 | void main() 50 | { 51 | if(position.w > threshold) 52 | { 53 | 54 | // gl_Position = proj_matrix * view_matrix * vec4(position.xyz, 1.0); 55 | 56 | mat4 mv_mat = view_matrix; 57 | mat3 normal_mat = mat3(user_view_matrix) * mat3(mv_mat); 58 | 59 | /*calculate vertex coordinates in camera frame*/ 60 | vec4 v_cam = mv_mat * vec4(position.xyz, 1.0); 61 | 62 | /*calculate vertex coordinates in user view*/ 63 | vec4 v_user = user_view_matrix * vec4((v_cam-user_rot_center).xyz, 1.0) + user_rot_center; 64 | 65 | vs_out.v = v_user.xyz; 66 | 67 | /*calculating front and back normal directions*/ 68 | vec3 front_normal = normalize(normal_mat * normal.xyz); 69 | vec3 back_normal = -front_normal; 70 | vs_out.fn = front_normal; 71 | vs_out.bn = back_normal; 72 | 73 | // gl_Position = MVP * pose * vec4(position.xyz, 1.0); 74 | // gl_Position = proj_matrix * v_user; 75 | gl_Position = proj_matrix * view_matrix * vec4(position.xyz, 1.0); 76 | if(colorType == 1) 77 | { 78 | vs_out.vColor = vec4(-normal.xyz, 1.0); 79 | } 80 | else if(colorType == 2) 81 | { 82 | vs_out.vColor = vec4(decodeColor(color.x), 1.0); 83 | } 84 | else if(colorType == 3) 85 | { 86 | vs_out.vColor = vec4(decodeColor(color.x), 1.0); 87 | float minimum = 1.0f; 88 | float maximum = 300; 89 | float ctime = color.z - (int(color.z /300)) * 300; 90 | ctime = min(ctime, maximum); 91 | ctime = max(ctime, 0); 92 | vs_out.vColor.x = min(1, 3 * ctime / maximum ); 93 | vs_out.vColor.y = min(1, max(0, (3 * ctime - maximum) / maximum )); 94 | vs_out.vColor.z = min(1, max(0, (3 * ctime - 2 * maximum) / maximum )); 95 | } 96 | else 97 | { 98 | 99 | // shading 100 | // vColor = vec4((vec3(.5f, .5f, .5f) * abs(dot(normal.xyz, vec3(1.0, 1.0, 1.0)))) + vec3(0.1f, 0.1f, 0.1f), 1.0f); 101 | 102 | 103 | 104 | } 105 | } 106 | else 107 | { 108 | gl_Position = vec4(-10, -10, 0, 1); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Shaders/draw_feedback_VoxelHashing.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 130 20 | 21 | in vec4 vColor; 22 | 23 | out vec4 FragColor; 24 | 25 | void main() 26 | { 27 | FragColor = vColor; 28 | } 29 | -------------------------------------------------------------------------------- /Shaders/draw_feedback_VoxelHashing.vert: -------------------------------------------------------------------------------- 1 | #version 130 2 | 3 | in vec4 position; 4 | in vec4 color; 5 | in vec4 normal; 6 | 7 | uniform mat4 MVP; 8 | uniform mat4 pose; 9 | uniform float threshold; 10 | uniform int colorType; 11 | uniform int time; 12 | uniform int timeDelta; 13 | 14 | uniform float materialShininess; 15 | uniform vec4 materialAmbient; 16 | uniform vec4 materialDiffuse; 17 | uniform vec4 materialSpecular; 18 | uniform vec4 lightAmbient; 19 | uniform vec4 lightDiffuse; 20 | uniform vec4 lightSpecular; 21 | 22 | 23 | out vec4 vColor; 24 | 25 | #include "color.glsl" 26 | 27 | void main() 28 | { 29 | if(position.w > threshold) 30 | { 31 | if(colorType == 1) 32 | { 33 | vColor = vec4(-normal.xyz, 1.0); 34 | } 35 | else if(colorType == 2) 36 | { 37 | vColor = vec4(decodeColor(color.x), 1.0); 38 | } 39 | else if(colorType == 3) 40 | { 41 | vColor = vec4(decodeColor(color.x), 1.0); 42 | float minimum = 1.0f; 43 | float maximum = 300; 44 | float ctime = color.z - (int(color.z /300)) * 300; 45 | ctime = min(ctime, maximum); 46 | ctime = max(ctime, 0); 47 | vColor.x = min(1, 3 * ctime / maximum ); 48 | vColor.y = min(1, max(0, (3 * ctime - maximum) / maximum )); 49 | vColor.z = min(1, max(0, (3 * ctime - 2 * maximum) / maximum )); 50 | } 51 | else 52 | { 53 | // use Phong shading 54 | 55 | vec4 material = materialDiffuse; 56 | 57 | vec3 eyeDir = normalize(position.xyz); 58 | vec4 light_dir_vec4 = vec4(eyeDir,1.0); 59 | vec3 light_dir = light_dir_vec4.xyz; 60 | vec3 R = normalize(reflect(-normalize(light_dir), normal.xyz)); 61 | 62 | vec4 res = lightAmbient * materialAmbient // Ambient 63 | + lightDiffuse * material * max(dot(normal.xyz, -normalize(light_dir)), 0.0) // Diffuse 64 | + lightSpecular * materialSpecular * pow(max(dot(R, eyeDir), 0.0f), materialShininess); // Specular 65 | 66 | vColor = clamp(res, 0.0, 1.0); 67 | // vColor = vec4((vec3(.5f, .5f, .5f) * abs(dot(normal.xyz, vec3(1.0, 1.0, 1.0)))) + vec3(0.1f, 0.1f, 0.1f), 1.0f); 68 | } 69 | gl_Position = MVP * pose * vec4(position.xyz, 1.0); 70 | } 71 | else 72 | { 73 | gl_Position = vec4(-10, -10, 0, 1); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Shaders/draw_global_surface.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec3 vColor0; 22 | in vec2 texcoord; 23 | in float radius; 24 | flat in int unstablePoint; 25 | 26 | out vec4 FragColor; 27 | 28 | void main() 29 | { 30 | if(dot(texcoord, texcoord) > 1.0) 31 | discard; 32 | 33 | FragColor = vec4(vColor0, 1.0f); 34 | 35 | if(unstablePoint == 1) 36 | { 37 | gl_FragDepth = gl_FragCoord.z + radius; 38 | } 39 | else 40 | { 41 | gl_FragDepth = gl_FragCoord.z; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Shaders/draw_global_surface.geom: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout(points) in; 22 | layout(triangle_strip, max_vertices = 4) out; 23 | 24 | uniform float threshold; 25 | uniform float signMult; 26 | 27 | in vec4 vColor[]; 28 | in vec4 vPosition[]; 29 | in vec4 vNormRad[]; 30 | in mat4 vMVP[]; 31 | in int colorType0[]; 32 | in int drawWindow0[]; 33 | in int vTime[]; 34 | in int timeDelta0[]; 35 | 36 | out vec3 vColor0; 37 | out vec3 v; 38 | out vec3 n; 39 | out vec2 texcoord; 40 | out float radius; 41 | flat out int unstablePoint; 42 | 43 | #include "color.glsl" 44 | 45 | void main() 46 | { 47 | if(colorType0[0] != -1) 48 | { 49 | if(colorType0[0] == 1) 50 | { 51 | vColor0 = vNormRad[0].xyz; 52 | } 53 | else if(colorType0[0] == 2) 54 | { 55 | vColor0 = decodeColor(vColor[0].x); 56 | } 57 | else if(colorType0[0] == 3) 58 | { 59 | vColor0 = vec3(vColor[0].z / float(vTime[0])); 60 | 61 | float minimum = 1.0f; 62 | float maximum = float(vTime[0]); 63 | 64 | float ratio = 2 * (vColor[0].z - minimum) / (maximum - minimum); 65 | vColor0.x = max(0, (1 - ratio)); 66 | vColor0.y = max(0, (ratio - 1)); 67 | vColor0.z = 1.0f - vColor0.x - vColor0.y; 68 | 69 | vColor0.xyz *= abs(dot(vNormRad[0].xyz, vec3(1.0, 1.0, 1.0))) + vec3(0.1f, 0.1f, 0.1f); 70 | } 71 | else 72 | { 73 | vColor0 = (vec3(.5f, .5f, .5f) * abs(dot(vNormRad[0].xyz, vec3(1.0, 1.0, 1.0)))) + vec3(0.1f, 0.1f, 0.1f); 74 | } 75 | 76 | if(drawWindow0[0] == 1 && vTime[0] - vColor[0].w > timeDelta0[0]) 77 | { 78 | vColor0 *= 0.25; 79 | } 80 | 81 | unstablePoint = (vPosition[0].w <= threshold ? 1 : 0); 82 | 83 | radius = vNormRad[0].w; 84 | 85 | vec3 x = normalize(vec3((vNormRad[0].y - vNormRad[0].z), -vNormRad[0].x, vNormRad[0].x)) * vNormRad[0].w * 1.41421356; 86 | 87 | vec3 y = cross(vNormRad[0].xyz, x); 88 | 89 | n = signMult * vNormRad[0].xyz; 90 | 91 | texcoord = vec2(-1.0, -1.0); 92 | gl_Position = vMVP[0] * vec4(vPosition[0].xyz + x, 1.0); 93 | v = vPosition[0].xyz + x; 94 | EmitVertex(); 95 | 96 | texcoord = vec2(1.0, -1.0); 97 | gl_Position = vMVP[0] * vec4(vPosition[0].xyz + y, 1.0); 98 | v = vPosition[0].xyz + y; 99 | EmitVertex(); 100 | 101 | texcoord = vec2(-1.0, 1.0); 102 | gl_Position = vMVP[0] * vec4(vPosition[0].xyz - y, 1.0); 103 | v = vPosition[0].xyz - y; 104 | EmitVertex(); 105 | 106 | texcoord = vec2(1.0, 1.0); 107 | gl_Position = vMVP[0] * vec4(vPosition[0].xyz - x, 1.0); 108 | v = vPosition[0].xyz - x; 109 | EmitVertex(); 110 | EndPrimitive(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Shaders/draw_global_surface.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec4 position; 22 | layout (location = 1) in vec4 color; 23 | layout (location = 2) in vec4 normal; 24 | 25 | uniform mat4 MVP; 26 | uniform float threshold; 27 | uniform int colorType; 28 | uniform int unstable; 29 | uniform int drawWindow; 30 | uniform int time; 31 | uniform int timeDelta; 32 | 33 | out vec4 vColor; 34 | out vec4 vPosition; 35 | out vec4 vNormRad; 36 | out mat4 vMVP; 37 | out int vTime; 38 | out int colorType0; 39 | out int drawWindow0; 40 | out int timeDelta0; 41 | 42 | void main() 43 | { 44 | if((position.w > threshold )|| unstable == 1) 45 | { 46 | colorType0 = colorType; 47 | drawWindow0 = drawWindow; 48 | vColor = color; 49 | vPosition = position; 50 | vNormRad = normal; 51 | vMVP = MVP; 52 | vTime = time; 53 | timeDelta0 = timeDelta; 54 | gl_Position = MVP * vec4(position.xyz, 1.0); 55 | } 56 | else 57 | { 58 | colorType0 = -1; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Shaders/draw_global_surface_phong.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec3 n; 22 | in vec3 v; 23 | in vec3 vColor0; 24 | in vec2 texcoord; 25 | in float radius; 26 | flat in int unstablePoint; 27 | 28 | out vec4 FragColor; 29 | 30 | uniform vec3 lightpos; 31 | 32 | void main() 33 | { 34 | if(dot(texcoord, texcoord) > 1.0) 35 | discard; 36 | 37 | vec4 diffuse = vec4(0.0); 38 | vec4 specular = vec4(0.0); 39 | 40 | // ambient term 41 | vec4 ambient = vec4(0.3 * vColor0, 1); 42 | 43 | // diffuse color 44 | vec4 kd = vec4(vColor0, 1.0); 45 | 46 | // specular color 47 | vec4 ks = vec4(1.0, 1.0, 1.0, 1.0); 48 | 49 | // diffuse term 50 | vec3 lightDir = normalize(lightpos - v); 51 | float NdotL = dot(n, lightDir); 52 | 53 | if (NdotL > 0.0) 54 | diffuse = kd * NdotL; 55 | 56 | // specular term 57 | vec3 rVector = normalize(2.0 * n * dot(n, lightDir) - lightDir); 58 | vec3 viewVector = normalize(-v); 59 | float RdotV = dot(rVector, viewVector); 60 | 61 | if (RdotV > 0.0) 62 | specular = ks * pow(RdotV, 32); 63 | 64 | FragColor = ambient + diffuse + specular; 65 | 66 | if(unstablePoint == 1) 67 | { 68 | gl_FragDepth = gl_FragCoord.z + radius; 69 | } 70 | else 71 | { 72 | gl_FragDepth = gl_FragCoord.z; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Shaders/draw_tsdf_feedback.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec4 vColor; 22 | 23 | out vec4 FragColor; 24 | 25 | void main() 26 | { 27 | FragColor = vColor; 28 | } 29 | -------------------------------------------------------------------------------- /Shaders/draw_tsdf_feedback.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec4 position; 22 | layout (location = 1) in vec4 color; 23 | layout (location = 2) in vec4 normal; 24 | 25 | uniform mat4 MVP; 26 | uniform mat4 pose; 27 | uniform float threshold; 28 | uniform int colorType; 29 | 30 | out vec4 vColor; 31 | 32 | #include "color.glsl" 33 | 34 | void main() 35 | { 36 | if(position.w > threshold) 37 | { 38 | if(colorType == 1) 39 | { 40 | vColor = vec4(normal.xyz, 1.0); 41 | } 42 | else if(colorType == 2) 43 | { 44 | vColor = vec4(decodeColor(color.x), 1.0); 45 | } 46 | else if(colorType0[0] == 3) 47 | { 48 | vColor0 = vec3(vColor[0].z / float(vTime[0])); 49 | 50 | float minimum = 1.0f; 51 | float maximum = float(vTime[0]); 52 | 53 | float ratio = 2 * (vColor[0].z - minimum) / (maximum - minimum); 54 | vColor0.x = max(0, (1 - ratio)); 55 | vColor0.y = max(0, (ratio - 1)); 56 | vColor0.z = 1.0f - vColor0.x - vColor0.y; 57 | 58 | vColor0.xyz *= abs(dot(vNormRad[0].xyz, vec3(1.0, 1.0, 1.0))) + vec3(0.1f, 0.1f, 0.1f); 59 | } 60 | else 61 | { 62 | vColor = vec4((vec3(.5f, .5f, .5f) * abs(dot(normal.xyz, vec3(1.0, 1.0, 1.0)))) + vec3(0.1f, 0.1f, 0.1f), 1.0f); 63 | } 64 | gl_Position = MVP * pose * vec4(position.xyz, 1.0); 65 | } 66 | else 67 | { 68 | gl_Position = vec4(-10, -10, 0, 1); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Shaders/empty.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 20 | 21 | void main() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /Shaders/fill_normal.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec2 texcoord; 22 | 23 | out vec4 FragColor; 24 | 25 | uniform sampler2D eSampler; 26 | uniform usampler2D rSampler; 27 | uniform vec4 cam; //cx, cy, 1/fx, 1/fy 28 | uniform float cols; 29 | uniform float rows; 30 | uniform int passthrough; 31 | 32 | #include "geometry.glsl" 33 | 34 | void main() 35 | { 36 | float halfPixX = 0.5 * (1.0 / cols); 37 | float halfPixY = 0.5 * (1.0 / rows); 38 | 39 | vec4 sample = textureLod(eSampler, texcoord, 0.0); 40 | 41 | if(sample.z == 0 || passthrough == 1) 42 | { 43 | vec4 vPos = vec4(getVertex(texcoord, int(texcoord.x * cols), int(texcoord.y * rows), cam, rSampler), 1); 44 | FragColor = vec4(getNormal(vPos.xyz, texcoord, int(texcoord.x * cols), int(texcoord.y * rows), cam, rSampler), 1); 45 | } 46 | else 47 | { 48 | FragColor = sample; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Shaders/fill_rgb.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec2 texcoord; 22 | 23 | out vec4 FragColor; 24 | 25 | uniform sampler2D eSampler; 26 | uniform sampler2D rSampler; 27 | uniform int passthrough; 28 | 29 | void main() 30 | { 31 | vec4 sample = texture2D(eSampler, texcoord.xy); 32 | 33 | if(sample.x + sample.y + sample.z == 0 || passthrough == 1) 34 | FragColor = texture2D(rSampler, texcoord.xy); 35 | else 36 | FragColor = sample; 37 | } 38 | -------------------------------------------------------------------------------- /Shaders/fill_vertex.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec2 texcoord; 22 | 23 | out vec4 FragColor; 24 | 25 | uniform sampler2D eSampler; 26 | uniform usampler2D rSampler; 27 | uniform vec4 cam; //cx, cy, 1/fx, 1/fy 28 | uniform float cols; 29 | uniform float rows; 30 | uniform int passthrough; 31 | 32 | vec3 getVertex(int x, int y, float z) 33 | { 34 | return vec3((x - cam.x) * z * cam.z, (y - cam.y) * z * cam.w, z); 35 | } 36 | 37 | void main() 38 | { 39 | float halfPixX = 0.5 * (1.0 / cols); 40 | float halfPixY = 0.5 * (1.0 / rows); 41 | 42 | vec4 sample = textureLod(eSampler, texcoord, 0.0); 43 | 44 | if(sample.z == 0 || passthrough == 1) 45 | { 46 | float z = float(textureLod(rSampler, texcoord, 0.0)) / 1000.0f; 47 | FragColor = vec4(getVertex(int(texcoord.x * cols), int(texcoord.y * rows), z), 1); 48 | } 49 | else 50 | { 51 | FragColor = sample; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Shaders/fxaa.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | #define FXAA_REDUCE_MIN (1.0/ 128.0) 22 | #define FXAA_REDUCE_MUL (1.0 / 8.0) 23 | #define FXAA_SPAN_MAX 8.0 24 | 25 | uniform sampler2D tex; 26 | uniform vec2 resolution; 27 | 28 | in vec2 texcoord; 29 | 30 | out vec4 FragColor; 31 | 32 | void main() 33 | { 34 | vec4 color; 35 | 36 | vec2 inverseVP = 1.0 / resolution.xy; 37 | vec2 v_rgbNW = texcoord + (vec2(-1.0, -1.0) * inverseVP); 38 | vec2 v_rgbNE = texcoord + (vec2(1.0, -1.0) * inverseVP); 39 | vec2 v_rgbSW = texcoord + (vec2(-1.0, 1.0) * inverseVP); 40 | vec2 v_rgbSE = texcoord + (vec2(1.0, 1.0) * inverseVP); 41 | 42 | vec2 v_rgbN = texcoord + (vec2(-1.0, 0.0) * inverseVP); 43 | vec2 v_rgbE = texcoord + (vec2(1.0, 0.0) * inverseVP); 44 | vec2 v_rgbW = texcoord + (vec2(0.0, -1.0) * inverseVP); 45 | vec2 v_rgbS = texcoord + (vec2(0.0, 1.0) * inverseVP); 46 | 47 | vec2 v_rgbM = texcoord; 48 | 49 | vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; 50 | vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; 51 | vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; 52 | vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; 53 | 54 | vec3 rgbN = texture2D(tex, v_rgbN).xyz; 55 | vec3 rgbE = texture2D(tex, v_rgbE).xyz; 56 | vec3 rgbW = texture2D(tex, v_rgbW).xyz; 57 | vec3 rgbS = texture2D(tex, v_rgbS).xyz; 58 | 59 | vec3 rgbM = texture2D(tex, v_rgbM).xyz; 60 | vec3 luma = vec3(0.299, 0.587, 0.114); 61 | float lumaNW = dot(rgbNW, luma); 62 | float lumaNE = dot(rgbNE, luma); 63 | float lumaSW = dot(rgbSW, luma); 64 | float lumaSE = dot(rgbSE, luma); 65 | float lumaM = dot(rgbM, luma); 66 | float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); 67 | float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); 68 | 69 | vec2 dir; 70 | dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); 71 | dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); 72 | 73 | float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); 74 | 75 | float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); 76 | 77 | dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * inverseVP; 78 | 79 | vec3 rgbA = 0.5 * (texture2D(tex, texcoord + dir * (1.0 / 3.0 - 0.5)).xyz + texture2D(tex, texcoord + dir * (2.0 / 3.0 - 0.5)).xyz); 80 | 81 | vec3 rgbB = rgbA * 0.5 + 0.25 * (texture2D(tex, texcoord + dir * -0.5).xyz + texture2D(tex, texcoord + dir * 0.5).xyz); 82 | 83 | float lumaB = dot(rgbB, luma); 84 | 85 | if ((lumaB < lumaMin) || (lumaB > lumaMax)) 86 | FragColor = vec4(rgbA, 1); 87 | else 88 | FragColor = vec4(rgbB, 1); 89 | } 90 | -------------------------------------------------------------------------------- /Shaders/geometry.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | //Central difference on floating point depth maps 20 | //Cam is //cx, cy, 1 / fx, 1 / fy 21 | vec3 getVertex(vec2 texCoord, float x, float y, vec4 cam, sampler2D depth) 22 | { 23 | float z = float(textureLod(depth, texCoord, 0.0)); 24 | return vec3((x - cam.x) * z * cam.z, (y - cam.y) * z * cam.w, z); 25 | } 26 | 27 | //Cam is //cx, cy, 1 / fx, 1 / fy 28 | vec3 getNormal(vec3 vPosition, vec2 texCoord, float x, float y, vec4 cam, sampler2D depth) 29 | { 30 | vec3 vPosition_xf = getVertex(vec2(texCoord.x + (1.0 / cols), texCoord.y), x + 1, y, cam, depth); 31 | vec3 vPosition_xb = getVertex(vec2(texCoord.x - (1.0 / cols), texCoord.y), x - 1, y, cam, depth); 32 | 33 | vec3 vPosition_yf = getVertex(vec2(texCoord.x, texCoord.y + (1.0 / rows)), x, y + 1, cam, depth); 34 | vec3 vPosition_yb = getVertex(vec2(texCoord.x, texCoord.y - (1.0 / rows)), x, y - 1, cam, depth); 35 | 36 | vec3 del_x = ((vPosition_xb + vPosition) / 2) - ((vPosition_xf + vPosition) / 2); 37 | vec3 del_y = ((vPosition_yb + vPosition) / 2) - ((vPosition_yf + vPosition) / 2); 38 | 39 | return normalize(cross(del_x, del_y)); 40 | } 41 | 42 | //Forward difference on raw depth maps still in ushort mm 43 | //Cam is //cx, cy, 1 / fx, 1 / fy 44 | vec3 getVertex(vec2 texcoord, int x, int y, vec4 cam, usampler2D depth) 45 | { 46 | float z = float(textureLod(depth, texcoord, 0.0)) / 1000.0f; 47 | return vec3((x - cam.x) * z * cam.z, (y - cam.y) * z * cam.w, z); 48 | } 49 | 50 | //Cam is //cx, cy, 1 / fx, 1 / fy 51 | vec3 getNormal(vec3 vPosition, vec2 texcoord, int x, int y, vec4 cam, usampler2D depth) 52 | { 53 | vec3 vPosition_x = getVertex(vec2(texcoord.x + (1.0 / cols), texcoord.y), x + 1, y, cam, depth); 54 | vec3 vPosition_y = getVertex(vec2(texcoord.x, texcoord.y + (1.0 / rows)), x, y + 1, cam, depth); 55 | 56 | vec3 del_x = vPosition_x - vPosition; 57 | vec3 del_y = vPosition_y - vPosition; 58 | 59 | return normalize(cross(del_x, del_y)); 60 | } 61 | -------------------------------------------------------------------------------- /Shaders/index_map.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec4 vPosition0; 22 | in vec4 vColorTime0; 23 | in vec4 vNormRad0; 24 | flat in int vertexId; 25 | 26 | layout(location = 0) out int FragColor; 27 | layout(location = 1) out vec4 vPosition1; 28 | layout(location = 2) out vec4 vColorTime1; 29 | layout(location = 3) out vec4 vNormRad1; 30 | 31 | void main() 32 | { 33 | vPosition1 = vPosition0; 34 | vColorTime1 = vColorTime0; 35 | vNormRad1 = vNormRad0; 36 | FragColor = vertexId; 37 | } 38 | -------------------------------------------------------------------------------- /Shaders/index_map.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec4 vPosition; 22 | layout (location = 1) in vec4 vColorTime; 23 | layout (location = 2) in vec4 vNormRad; 24 | 25 | out vec4 vPosition0; 26 | out vec4 vColorTime0; 27 | out vec4 vNormRad0; 28 | flat out int vertexId; 29 | 30 | uniform mat4 t_inv; 31 | uniform vec4 cam; //cx, cy, fx, fy 32 | uniform float cols; 33 | uniform float rows; 34 | uniform float maxDepth; 35 | uniform int time; 36 | uniform int timeDelta; 37 | 38 | void main() 39 | { 40 | vec4 vPosHome = t_inv * vec4(vPosition.xyz, 1.0); 41 | 42 | float x = 0; 43 | float y = 0; 44 | 45 | if(vPosHome.z > maxDepth || vPosHome.z < 0 || time - vColorTime.w > timeDelta) 46 | { 47 | x = -10; 48 | y = -10; 49 | vertexId = 0; 50 | } 51 | else 52 | { 53 | x = ((((cam.z * vPosHome.x) / vPosHome.z) + cam.x) - (cols * 0.5)) / (cols * 0.5); 54 | y = ((((cam.w * vPosHome.y) / vPosHome.z) + cam.y) - (rows * 0.5)) / (rows * 0.5); 55 | vertexId = gl_VertexID; 56 | } 57 | 58 | gl_Position = vec4(x, y, vPosHome.z / maxDepth, 1.0); 59 | 60 | vPosition0 = vec4(vPosHome.xyz, vPosition.w); 61 | vColorTime0 = vColorTime; 62 | vNormRad0 = vec4(normalize(mat3(t_inv) * vNormRad.xyz), vNormRad.w); 63 | } 64 | -------------------------------------------------------------------------------- /Shaders/init_unstable.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec4 vPosition; 22 | layout (location = 1) in vec4 vColor; 23 | layout (location = 2) in vec4 vNormRad; 24 | 25 | out vec4 vPosition0; 26 | out vec4 vColor0; 27 | out vec4 vNormRad0; 28 | 29 | void main() 30 | { 31 | vPosition0 = vPosition; 32 | vColor0 = vColor; 33 | vColor0.y = 0; //Unused 34 | vColor0.z = 1; //This sets the vertex's initialisation time 35 | vNormRad0 = vNormRad; 36 | } 37 | -------------------------------------------------------------------------------- /Shaders/quad.geom: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout(points) in; 22 | layout(triangle_strip, max_vertices = 4) out; 23 | 24 | out vec2 texcoord; 25 | 26 | void main() 27 | { 28 | gl_Position = vec4(1.0, 1.0, 0.0, 1.0); 29 | texcoord = vec2(1.0, 1.0); 30 | EmitVertex(); 31 | 32 | gl_Position = vec4(-1.0, 1.0, 0.0, 1.0); 33 | texcoord = vec2(0.0, 1.0); 34 | EmitVertex(); 35 | 36 | gl_Position = vec4(1.0,-1.0, 0.0, 1.0); 37 | texcoord = vec2(1.0, 0.0); 38 | EmitVertex(); 39 | 40 | gl_Position = vec4(-1.0,-1.0, 0.0, 1.0); 41 | texcoord = vec2(0.0, 0.0); 42 | EmitVertex(); 43 | 44 | EndPrimitive(); 45 | } 46 | -------------------------------------------------------------------------------- /Shaders/resize.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | in vec2 texcoord; 22 | 23 | out vec4 FragColor; 24 | 25 | uniform sampler2D eSampler; 26 | 27 | void main() 28 | { 29 | FragColor = texture2D(eSampler, texcoord.xy); 30 | } 31 | -------------------------------------------------------------------------------- /Shaders/sample.geom: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout(points) in; 22 | layout(points, max_vertices = 1) out; 23 | 24 | in vec4 vPosition0[]; 25 | in vec4 vColorTime0[]; 26 | in vec4 vNormRad0[]; 27 | flat in int id[]; 28 | 29 | out vec4 vData; 30 | 31 | void main() 32 | { 33 | if(id[0] % 5000 == 0) 34 | { 35 | vData.xyz = vPosition0[0].xyz; 36 | vData.w = vColorTime0[0].z; 37 | EmitVertex(); 38 | EndPrimitive(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Shaders/sample.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec4 vPosition; 22 | layout (location = 1) in vec4 vColorTime; 23 | layout (location = 2) in vec4 vNormRad; 24 | 25 | out vec4 vPosition0; 26 | out vec4 vColorTime0; 27 | out vec4 vNormRad0; 28 | flat out int id; 29 | 30 | void main() 31 | { 32 | vPosition0 = vPosition; 33 | vColorTime0 = vColorTime; 34 | vNormRad0 = vNormRad; 35 | id = gl_VertexID; 36 | } 37 | -------------------------------------------------------------------------------- /Shaders/splat.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec4 vPosition; 22 | layout (location = 1) in vec4 vColor; 23 | layout (location = 2) in vec4 vNormRad; 24 | 25 | uniform mat4 t_inv; 26 | uniform vec4 cam; //cx, cy, fx, fy 27 | uniform float cols; 28 | uniform float rows; 29 | uniform float maxDepth; 30 | uniform float confThreshold; 31 | uniform int time; 32 | uniform int maxTime; 33 | uniform int timeDelta; 34 | 35 | out vec4 position; 36 | out vec4 normRad; 37 | out vec4 colTime; 38 | 39 | vec3 projectPoint(vec3 p) 40 | { 41 | return vec3(((((cam.z * p.x) / p.z) + cam.x) - (cols * 0.5)) / (cols * 0.5), 42 | ((((cam.w * p.y) / p.z) + cam.y) - (rows * 0.5)) / (rows * 0.5), 43 | p.z / maxDepth); 44 | } 45 | 46 | vec3 projectPointImage(vec3 p) 47 | { 48 | return vec3(((cam.z * p.x) / p.z) + cam.x, 49 | ((cam.w * p.y) / p.z) + cam.y, 50 | p.z); 51 | } 52 | 53 | void main() 54 | { 55 | vec4 vPosHome = t_inv * vec4(vPosition.xyz, 1.0); 56 | 57 | if(vPosHome.z > maxDepth || vPosHome.z < 0 || vPosition.w < confThreshold || time - vColor.w > timeDelta || vColor.w > maxTime) 58 | { 59 | gl_Position = vec4(1000.0f, 1000.0f, 1000.0f, 1000.0f); 60 | gl_PointSize = 0; 61 | } 62 | else 63 | { 64 | gl_Position = vec4(projectPoint(vPosHome.xyz), 1.0); 65 | 66 | colTime = vColor; 67 | position = vec4(vPosHome.xyz, vPosition.w); 68 | normRad = vec4(normalize(mat3(t_inv) * vNormRad.xyz), vNormRad.w); 69 | 70 | vec3 x1 = normalize(vec3((normRad.y - normRad.z), -normRad.x, normRad.x)) * normRad.w * 1.41421356; 71 | 72 | vec3 y1 = cross(normRad.xyz, x1); 73 | 74 | vec4 proj1 = vec4(projectPointImage(vPosHome.xyz + x1), 1.0); 75 | vec4 proj2 = vec4(projectPointImage(vPosHome.xyz + y1), 1.0); 76 | vec4 proj3 = vec4(projectPointImage(vPosHome.xyz - y1), 1.0); 77 | vec4 proj4 = vec4(projectPointImage(vPosHome.xyz - x1), 1.0); 78 | 79 | vec2 xs = vec2(min(proj1.x, min(proj2.x, min(proj3.x, proj4.x))), max(proj1.x, max(proj2.x, max(proj3.x, proj4.x)))); 80 | vec2 ys = vec2(min(proj1.y, min(proj2.y, min(proj3.y, proj4.y))), max(proj1.y, max(proj2.y, max(proj3.y, proj4.y)))); 81 | 82 | float xDiff = abs(xs.y - xs.x); 83 | float yDiff = abs(ys.y - ys.x); 84 | 85 | gl_PointSize = max(0, max(xDiff, yDiff)); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Shaders/surfels.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | float getRadius(float depth, float norm_z) 20 | { 21 | float meanFocal = ((1.0 / abs(cam.z)) + (1.0 / abs(cam.w))) / 2.0; 22 | 23 | const float sqrt2 = 1.41421356237f; 24 | 25 | float radius = (depth / meanFocal) * sqrt2; 26 | 27 | float radius_n = radius; 28 | 29 | radius_n = radius_n / abs(norm_z); 30 | 31 | radius_n = min(2.0f * radius, radius_n); 32 | 33 | return radius_n; 34 | } 35 | 36 | float confidence(float x, float y, float weighting) 37 | { 38 | const float maxRadDist = 400; //sqrt((width * 0.5)^2 + (height * 0.5)^2) 39 | const float twoSigmaSquared = 0.72; //2*(0.6^2) from paper 40 | 41 | vec2 pixelPosCentered = vec2(x, y) - cam.xy; 42 | 43 | float radialDist = sqrt(dot(pixelPosCentered, pixelPosCentered)) / maxRadDist; 44 | 45 | return exp((-(radialDist * radialDist) / twoSigmaSquared)) * weighting; 46 | } 47 | -------------------------------------------------------------------------------- /Shaders/update.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec4 vPosition; 22 | layout (location = 1) in vec4 vColor; 23 | layout (location = 2) in vec4 vNormRad; 24 | 25 | out vec4 vPosition0; 26 | out vec4 vColor0; 27 | out vec4 vNormRad0; 28 | uniform float texDim; 29 | uniform int time; 30 | 31 | uniform sampler2D vertSamp; 32 | uniform sampler2D colorSamp; 33 | uniform sampler2D normSamp; 34 | 35 | #include "color.glsl" 36 | 37 | void main() 38 | { 39 | int intY = gl_VertexID / int(texDim); 40 | int intX = gl_VertexID - (intY * int(texDim)); 41 | 42 | float halfPixel = 0.5 * (1.0f / texDim); 43 | float y = (float(intY) / texDim) + halfPixel; 44 | float x = (float(intX) / texDim) + halfPixel; 45 | 46 | vec4 newColor = textureLod(colorSamp, vec2(x, y), 0); 47 | 48 | //Do averaging here 49 | if(newColor.w == -1) 50 | { 51 | vec4 newPos = textureLod(vertSamp, vec2(x, y), 0); 52 | vec4 newNorm = textureLod(normSamp, vec2(x, y), 0); 53 | 54 | float c_k = vPosition.w; 55 | vec3 v_k = vPosition.xyz; 56 | 57 | float a = newPos.w; 58 | vec3 v_g = newPos.xyz; 59 | 60 | if(newNorm.w < (1.0 + 0.5) * vNormRad.w) 61 | { 62 | vPosition0 = vec4(((c_k * v_k) + (a * v_g)) / (c_k + a), c_k + a); 63 | 64 | vec3 oldCol = decodeColor(vColor.x); 65 | vec3 newCol = decodeColor(newColor.x); 66 | 67 | vec3 avgColor = ((c_k * oldCol.xyz) + (a * newCol.xyz)) / (c_k + a); 68 | 69 | vColor0 = vec4(encodeColor(avgColor), vColor.y, vColor.z, time); 70 | 71 | vNormRad0 = ((c_k * vNormRad) + (a * newNorm)) / (c_k + a); 72 | 73 | vNormRad0.xyz = normalize(vNormRad0.xyz); 74 | } 75 | else 76 | { 77 | vPosition0 = vPosition; 78 | vColor0 = vColor; 79 | vNormRad0 = vNormRad; 80 | 81 | vPosition0.w = c_k + a; 82 | vColor0.w = time; 83 | } 84 | } 85 | else 86 | { 87 | //This point isn't being updated, so just transfer it 88 | vPosition0 = vPosition; 89 | vColor0 = vColor; 90 | vNormRad0 = vNormRad; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Shaders/vertex_feedback.geom: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout(points) in; 22 | layout(points, max_vertices = 1) out; 23 | 24 | in vec4 vPosition[]; 25 | in vec4 vColor[]; 26 | in vec4 vNormRad[]; 27 | in float zVal[]; 28 | 29 | out vec4 vPosition0; 30 | out vec4 vColor0; 31 | out vec4 vNormRad0; 32 | 33 | void main() 34 | { 35 | if(zVal[0] > 0) 36 | { 37 | vPosition0 = vPosition[0]; 38 | vColor0 = vColor[0]; 39 | vNormRad0 = vNormRad[0]; 40 | EmitVertex(); 41 | EndPrimitive(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Shaders/vertex_feedback.vert: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | layout (location = 0) in vec2 texcoord; 22 | 23 | out vec4 vPosition; 24 | out vec4 vColor; 25 | out vec4 vNormRad; 26 | out float zVal; 27 | 28 | uniform sampler2D gSampler; 29 | uniform sampler2D cSampler; 30 | uniform vec4 cam; //cx, cy, 1/fx, 1/fy 31 | uniform float cols; 32 | uniform float rows; 33 | uniform int time; 34 | uniform float maxDepth; 35 | #include "surfels.glsl" 36 | #include "color.glsl" 37 | #include "geometry.glsl" 38 | 39 | void main() 40 | { 41 | //Should be guaranteed to be in bounds 42 | float x = texcoord.x * cols; 43 | float y = texcoord.y * rows; 44 | 45 | vPosition = vec4(getVertex(texcoord.xy, x, y, cam, gSampler), 1); 46 | vColor = textureLod(cSampler, texcoord.xy, 0.0); 47 | 48 | vec3 vNormLocal = getNormal(vPosition.xyz, texcoord.xy, x, y, cam, gSampler); 49 | vNormRad = vec4(vNormLocal, getRadius(vPosition.z, vNormLocal.z)); 50 | 51 | if(vPosition.z <= 0 || vPosition.z > maxDepth) 52 | { 53 | zVal = 0; 54 | } 55 | else 56 | { 57 | zVal = vPosition.z; 58 | } 59 | 60 | vPosition.w = confidence(x, y, 1.0f); 61 | 62 | vColor.x = encodeColor(vColor.xyz); 63 | 64 | vColor.y = 0; 65 | //Timestamp 66 | vColor.w = float(time); 67 | } 68 | -------------------------------------------------------------------------------- /Shaders/visualise_textures.frag: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #version 330 core 20 | 21 | uniform sampler2D texVerts; 22 | uniform float maxDepth; 23 | 24 | in vec2 texcoord; 25 | 26 | out vec4 FragColor; 27 | 28 | void main() 29 | { 30 | vec4 vertex = texture2D(texVerts, texcoord); 31 | 32 | if(vertex.z > maxDepth || vertex.z <= 0) 33 | { 34 | discard; 35 | } 36 | else 37 | { 38 | FragColor = 1.0f - vec4(vertex.z / maxDepth); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Tools/CameraInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "ThreadMutexObject.h" 9 | 10 | class CameraInterface 11 | { 12 | public: 13 | virtual ~CameraInterface() {} 14 | 15 | virtual bool ok() = 0; 16 | virtual std::string error() = 0; 17 | 18 | static const int numBuffers = 10; 19 | ThreadMutexObject latestDepthIndex; 20 | std::pair,int64_t> frameBuffers[numBuffers]; 21 | 22 | virtual void setAutoExposure(bool value) = 0; 23 | virtual void setAutoWhiteBalance(bool value) = 0; 24 | 25 | virtual bool getAutoExposure() = 0; 26 | }; 27 | -------------------------------------------------------------------------------- /Tools/JPEGLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #ifndef TOOLS_JPEGLOADER_H_ 20 | #define TOOLS_JPEGLOADER_H_ 21 | 22 | extern "C" 23 | { 24 | #include "jpeglib.h" 25 | } 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | static void jpegFail(j_common_ptr cinfo) 32 | { 33 | assert(false && "JPEG decoding error!"); 34 | } 35 | 36 | static void doNothing(j_decompress_ptr) 37 | { 38 | 39 | } 40 | 41 | class JPEGLoader 42 | { 43 | public: 44 | JPEGLoader() 45 | {} 46 | 47 | void readData(unsigned char * src, const int numBytes, unsigned char * data) 48 | { 49 | jpeg_decompress_struct cinfo; // IJG JPEG codec structure 50 | 51 | jpeg_error_mgr errorMgr; 52 | 53 | errorMgr.error_exit = jpegFail; 54 | 55 | cinfo.err = jpeg_std_error(&errorMgr); 56 | 57 | jpeg_create_decompress(&cinfo); 58 | 59 | jpeg_source_mgr srcMgr; 60 | 61 | cinfo.src = &srcMgr; 62 | 63 | // Prepare for suspending reader 64 | srcMgr.init_source = doNothing; 65 | srcMgr.resync_to_restart = jpeg_resync_to_restart; 66 | srcMgr.term_source = doNothing; 67 | srcMgr.next_input_byte = src; 68 | srcMgr.bytes_in_buffer = numBytes; 69 | 70 | jpeg_read_header(&cinfo, TRUE); 71 | 72 | jpeg_calc_output_dimensions(&cinfo); 73 | 74 | jpeg_start_decompress(&cinfo); 75 | 76 | int width = cinfo.output_width; 77 | int height = cinfo.output_height; 78 | 79 | JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, width * 4, 1); 80 | 81 | for(; height--; data += (width * 3)) 82 | { 83 | jpeg_read_scanlines(&cinfo, buffer, 1); 84 | 85 | unsigned char * bgr = (unsigned char *)buffer[0]; 86 | unsigned char * rgb = (unsigned char *)data; 87 | 88 | for(int i = 0; i < width; i++, bgr += 3, rgb += 3) 89 | { 90 | unsigned char t0 = bgr[0], t1 = bgr[1], t2 = bgr[2]; 91 | rgb[2] = t0; rgb[1] = t1; rgb[0] = t2; 92 | } 93 | } 94 | 95 | jpeg_finish_decompress(&cinfo); 96 | 97 | jpeg_destroy_decompress(&cinfo); 98 | } 99 | }; 100 | 101 | 102 | #endif /* TOOLS_JPEGLOADER_H_ */ 103 | -------------------------------------------------------------------------------- /Tools/LiveLogReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #ifndef LIVELOGREADER_H_ 20 | #define LIVELOGREADER_H_ 21 | 22 | #include 23 | #include 24 | #ifndef WIN32 25 | # include 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "LogReader.h" 32 | #include "CameraInterface.h" 33 | 34 | class LiveLogReader : public LogReader 35 | { 36 | public: 37 | enum CameraType 38 | { 39 | OpenNI2,RealSense 40 | }; 41 | 42 | LiveLogReader(std::string file, bool flipColors, CameraType type); 43 | 44 | virtual ~LiveLogReader(); 45 | 46 | void getNext(); 47 | 48 | int getNumFrames(); 49 | 50 | bool hasMore(); 51 | 52 | bool rewound() 53 | { 54 | return false; 55 | } 56 | 57 | void rewind() 58 | { 59 | 60 | } 61 | 62 | void getBack() 63 | { 64 | 65 | } 66 | 67 | void fastForward(int frame) 68 | { 69 | 70 | } 71 | 72 | const std::string getFile(); 73 | 74 | void setAuto(bool value); 75 | 76 | CameraInterface * cam; 77 | 78 | private: 79 | int64_t lastFrameTime; 80 | int lastGot; 81 | }; 82 | 83 | #endif /* LIVELOGREADER_H_ */ 84 | -------------------------------------------------------------------------------- /Tools/LogReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #ifndef LOGREADER_H_ 20 | #define LOGREADER_H_ 21 | 22 | #ifdef WIN32 23 | # include 24 | #endif 25 | #include 26 | #if (defined WIN32) && (defined FAR) 27 | # undef FAR 28 | #endif 29 | #include 30 | #ifndef WIN32 31 | # include 32 | #endif 33 | 34 | #include "JPEGLoader.h" 35 | 36 | class LogReader 37 | { 38 | public: 39 | LogReader(std::string file, bool flipColors) 40 | : flipColors(flipColors), 41 | timestamp(0), 42 | depth(0), 43 | rgb(0), 44 | currentFrame(0), 45 | decompressionBufferDepth(0), 46 | decompressionBufferImage(0), 47 | file(file), 48 | width(640), 49 | height(480), 50 | numPixels(width * height) 51 | {} 52 | 53 | virtual ~LogReader() 54 | {} 55 | 56 | virtual void getNext() = 0; 57 | 58 | virtual int getNumFrames() = 0; 59 | 60 | virtual bool hasMore() = 0; 61 | 62 | virtual bool rewound() = 0; 63 | 64 | virtual void rewind() = 0; 65 | 66 | virtual void getBack() = 0; 67 | 68 | virtual void fastForward(int frame) = 0; 69 | 70 | virtual const std::string getFile() = 0; 71 | 72 | virtual void setAuto(bool value) = 0; 73 | 74 | bool flipColors; 75 | int64_t timestamp; 76 | 77 | unsigned short * depth; 78 | unsigned char * rgb; 79 | int currentFrame; 80 | 81 | protected: 82 | Bytef * decompressionBufferDepth; 83 | Bytef * decompressionBufferImage; 84 | unsigned char * depthReadBuffer; 85 | unsigned char * imageReadBuffer; 86 | int32_t depthSize; 87 | int32_t imageSize; 88 | 89 | const std::string file; 90 | FILE * fp; 91 | int32_t numFrames; 92 | int width; 93 | int height; 94 | int numPixels; 95 | 96 | JPEGLoader jpeg; 97 | }; 98 | 99 | #endif /* LOGREADER_H_ */ 100 | -------------------------------------------------------------------------------- /Tools/RawLogReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #ifndef RAWLOGREADER_H_ 20 | #define RAWLOGREADER_H_ 21 | 22 | 23 | #include 24 | 25 | #include "LogReader.h" 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class RawLogReader : public LogReader 35 | { 36 | public: 37 | RawLogReader(std::string file, bool flipColors); 38 | 39 | virtual ~RawLogReader(); 40 | 41 | void getNext(); 42 | 43 | void getBack(); 44 | 45 | int getNumFrames(); 46 | 47 | bool hasMore(); 48 | 49 | bool rewound(); 50 | 51 | void rewind(); 52 | 53 | void fastForward(int frame); 54 | 55 | const std::string getFile(); 56 | 57 | void setAuto(bool value); 58 | 59 | std::stack filePointers; 60 | 61 | private: 62 | void getCore(); 63 | }; 64 | 65 | #endif /* RAWLOGREADER_H_ */ 66 | -------------------------------------------------------------------------------- /Tools/RealSenseInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "RealSenseInterface.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | using namespace rs2; 12 | 13 | 14 | float get_depth_scale(rs2::device dev) 15 | { 16 | // Go over the device's sensors 17 | for (rs2::sensor& sensor : dev.query_sensors()) 18 | { 19 | // Check if the sensor if a depth sensor 20 | if (rs2::depth_sensor dpt = sensor.as()) 21 | { 22 | return dpt.get_depth_scale(); 23 | } 24 | } 25 | throw std::runtime_error("Device does not have a depth sensor"); 26 | } 27 | 28 | 29 | rs2_stream find_stream_to_align(const std::vector& streams) 30 | { 31 | //Given a vector of streams, we try to find a depth stream and another stream to align depth with. 32 | //We prioritize color streams to make the view look better. 33 | //If color is not available, we take another stream that (other than depth) 34 | rs2_stream align_to = RS2_STREAM_ANY; 35 | bool depth_stream_found = false; 36 | bool color_stream_found = false; 37 | for (rs2::stream_profile sp : streams) 38 | { 39 | rs2_stream profile_stream = sp.stream_type(); 40 | if (profile_stream != RS2_STREAM_DEPTH) 41 | { 42 | if (!color_stream_found) //Prefer color 43 | align_to = profile_stream; 44 | 45 | if (profile_stream == RS2_STREAM_COLOR) 46 | { 47 | color_stream_found = true; 48 | } 49 | } 50 | else 51 | { 52 | depth_stream_found = true; 53 | } 54 | } 55 | 56 | if(!depth_stream_found) 57 | throw std::runtime_error("No Depth stream available"); 58 | 59 | if (align_to == RS2_STREAM_ANY) 60 | throw std::runtime_error("No stream found to align with Depth"); 61 | 62 | return align_to; 63 | } 64 | 65 | bool profile_changed(const std::vector& current, const std::vector& prev) 66 | { 67 | for (auto&& sp : prev) 68 | { 69 | //If previous profile is in current (maybe just added another) 70 | auto itr = std::find_if(std::begin(current), std::end(current), [&sp](const rs2::stream_profile& current_sp) { return sp.unique_id() == current_sp.unique_id(); }); 71 | if (itr == std::end(current)) //If it previous stream wasn't found in current 72 | { 73 | return true; 74 | } 75 | } 76 | return false; 77 | } 78 | -------------------------------------------------------------------------------- /Tools/RealSenseInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef REALSENSEINTERFACE_H 2 | #define REALSENSEINTERFACE_H 3 | 4 | 5 | 6 | #include 7 | 8 | 9 | 10 | float get_depth_scale(rs2::device dev); 11 | rs2_stream find_stream_to_align(const std::vector& streams); 12 | bool profile_changed(const std::vector& current, const std::vector& prev); 13 | 14 | 15 | #endif // REALSENSEINTERFACE_H 16 | -------------------------------------------------------------------------------- /Tools/ThreadMutexObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ElasticFusion. 3 | * 4 | * Copyright (C) 2015 Imperial College London 5 | * 6 | * The use of the code within this file and all code within files that 7 | * make up the software that is ElasticFusion is permitted for 8 | * non-commercial purposes only. The full terms and conditions that 9 | * apply to the code within this file are detailed within the LICENSE.txt 10 | * file and at 11 | * unless explicitly stated. By downloading this file you agree to 12 | * comply with these terms. 13 | * 14 | * If you wish to use any of this code for commercial purposes then 15 | * please email researchcontracts.engineering@imperial.ac.uk. 16 | * 17 | */ 18 | 19 | #ifndef THREADMUTEXOBJECT_H_ 20 | #define THREADMUTEXOBJECT_H_ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | template 28 | class ThreadMutexObject 29 | { 30 | public: 31 | ThreadMutexObject() 32 | {} 33 | 34 | ThreadMutexObject(T initialValue) 35 | : object(initialValue), 36 | lastCopy(initialValue) 37 | {} 38 | 39 | void assign(T newValue) 40 | { 41 | mutex.lock(); 42 | 43 | object = lastCopy = newValue; 44 | 45 | mutex.unlock(); 46 | } 47 | 48 | std::mutex & getMutex() 49 | { 50 | return mutex; 51 | } 52 | 53 | T & getReference() 54 | { 55 | return object; 56 | } 57 | 58 | void assignAndNotifyAll(T newValue) 59 | { 60 | mutex.lock(); 61 | 62 | object = newValue; 63 | 64 | signal.notify_all(); 65 | 66 | mutex.unlock(); 67 | } 68 | 69 | void notifyAll() 70 | { 71 | mutex.lock(); 72 | 73 | signal.notify_all(); 74 | 75 | mutex.unlock(); 76 | } 77 | 78 | T getValue() 79 | { 80 | mutex.lock(); 81 | 82 | lastCopy = object; 83 | 84 | mutex.unlock(); 85 | 86 | return lastCopy; 87 | } 88 | 89 | T waitForSignal() 90 | { 91 | mutex.lock(); 92 | 93 | signal.wait(mutex); 94 | 95 | lastCopy = object; 96 | 97 | mutex.unlock(); 98 | 99 | return lastCopy; 100 | } 101 | 102 | T getValueWait(int wait = 33000) 103 | { 104 | std::this_thread::sleep_for(std::chrono::microseconds(wait)); 105 | 106 | mutex.lock(); 107 | 108 | lastCopy = object; 109 | 110 | mutex.unlock(); 111 | 112 | return lastCopy; 113 | } 114 | 115 | T & getReferenceWait(int wait = 33000) 116 | { 117 | std::this_thread::sleep_for(std::chrono::microseconds(wait)); 118 | 119 | mutex.lock(); 120 | 121 | lastCopy = object; 122 | 123 | mutex.unlock(); 124 | 125 | return lastCopy; 126 | } 127 | 128 | void operator++(int) 129 | { 130 | mutex.lock(); 131 | 132 | object++; 133 | 134 | mutex.unlock(); 135 | } 136 | 137 | private: 138 | T object; 139 | T lastCopy; 140 | std::mutex mutex; 141 | std::condition_variable_any signal; 142 | }; 143 | 144 | #endif /* THREADMUTEXOBJECT_H_ */ 145 | -------------------------------------------------------------------------------- /evaluation.m: -------------------------------------------------------------------------------- 1 | function evaluation(flag_file, probability_file, truth_file) 2 | 3 | fp = fopen(probability_file,'rb'); 4 | ori_p = fread(fp,'float'); 5 | fclose(fp); 6 | fp = fopen(flag_file,'rb'); 7 | ori_f = fread(fp,'float'); 8 | fclose(fp); 9 | 10 | frame_num = floor(sqrt(length(ori_f))); 11 | input_probability = zeros(frame_num,frame_num); 12 | input_flag = zeros(frame_num,frame_num); 13 | visited_probability = zeros(frame_num,frame_num); 14 | visited_flag = zeros(frame_num,frame_num); 15 | 16 | 17 | try 18 | load(truth_file); 19 | catch 20 | fprintf(1,'no truth files\r\n'); 21 | truth = zeros(frame_num,frame_num); 22 | end 23 | 24 | for i = 1:frame_num 25 | input_probability(i,:) = ori_p(i*frame_num-frame_num+1:i*frame_num); 26 | input_flag(i,:) = ori_f(i*frame_num-frame_num+1:i*frame_num); 27 | end 28 | 29 | visited_flag = input_flag; 30 | 31 | truth = truth > 0; 32 | tp = (visited_flag == truth & truth > 0); 33 | detected_true_positive = sum(tp,2) > 0; 34 | true_positive = sum(truth,2) >0; 35 | detected_positive = sum(visited_flag,2) > 0; 36 | recall = sum(detected_true_positive == true_positive & true_positive > 0) / sum(true_positive); 37 | precision = sum(detected_positive == true_positive & true_positive > 0) / sum(detected_positive); 38 | if(1) 39 | figure; 40 | imagesc((visited_flag - truth) * 2 + truth ); 41 | figure; 42 | plot(true_positive,'r*'); 43 | hold on; 44 | plot(detected_positive,'b'); 45 | legend('true positive', 'detected positive'); 46 | fprintf(1,'recall : %f\n', recall); 47 | fprintf(1,'precision : %f\n', precision); 48 | figure;imagesc(input_probability);title('input probability'); 49 | figure;imagesc(input_flag);title('input flag'); 50 | 51 | end 52 | endfunction 53 | -------------------------------------------------------------------------------- /param/calib_icl.txt: -------------------------------------------------------------------------------- 1 | 640 480 481.20 480.00 319.50 239.50 0 0 0 0 0 5000 8.0 2 | -------------------------------------------------------------------------------- /param/calib_tum.txt: -------------------------------------------------------------------------------- 1 | 640 480 517.3 516.5 318.6 255.3 0.2624 -0.9531 -0.0054 0.0026 1.1633 5000 10 2 | -------------------------------------------------------------------------------- /param/calib_xtion.txt: -------------------------------------------------------------------------------- 1 | 640 480 514.817 515.375 318.771 238.447 0.0 0.0 0.0 0.0 0.0 1000 10 2 | -------------------------------------------------------------------------------- /param/settings.yaml: -------------------------------------------------------------------------------- 1 | %YAML:1.0 2 | 3 | max_feature_num: 2000 4 | # for experiments 5 | runFrameNum: 10000 6 | runTestFlag: 0 7 | runRefFrame: 800 8 | runNewFrame: 800 9 | debug_mode: 1 10 | # trade-off between accuracy and efficiency 11 | ransac_maximum_iterations: 400 12 | maximum_keyframe_match_num: 5 13 | use_fine_search: 1 14 | 15 | 16 | # should be optimized by algorithm, select the parameters automatically. 17 | minimum_disparity: 0.1 18 | reprojection_error_3d_threshold: 0.01 19 | reprojection_error_2d_threshold: 6 20 | keyframe_minimum_distance: 4 21 | remove_outlier_keyframes: 0 22 | use_icp_registration: 0 23 | icp_weight: 0.5 24 | far_plane_distance: 3 25 | 26 | 27 | # not sure if it is reasonable 28 | 29 | #fixed parameters 30 | hamming_distance_threshold: 50 31 | salient_score_threshold: 1.5 32 | maximum_local_frame_match_num: 10 33 | save_ply_files: 0 34 | -------------------------------------------------------------------------------- /prepare.sh: -------------------------------------------------------------------------------- 1 | # install basic dependency 2 | sudo apt-get install build-essential pkg-config cmake libwxgtk3.0-dev libftdi-dev freeglut3-dev zlib1g-dev libusb-1.0-0-dev libudev-dev libfreenect-dev libdc1394-22-dev libavformat-dev libswscale-dev 3 | sudo apt-get install libassimp-dev libjpeg-dev libgtest-dev libeigen3-dev libsuitesparse-dev libpcap-dev libsuitesparse-dev build-essential cmake git ffmpeg libopencv-dev libgtk-3-dev python-numpy python3-numpy libdc1394-22 libdc1394-22-dev 4 | sudo apt-get install libjpeg-dev libpng-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libv4l-dev libtbb-dev qtbase5-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev 5 | sudo apt-get install libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip libglew-dev libpython2.7-dev ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libglfw3-dev 6 | sudo apt-get install libxmu-dev libxi-dev libboost-all-dev libxmu-dev libxi-dev qtbase5-dev -y g++ python doxygen graphviz openjdk-8-jdk 7 | 8 | # openni support 9 | sudo apt-get install libopenni2-dev 10 | # test install result 11 | # pkg-config --modversion libopenni2 12 | sudo ln -s /lib/x86_64-linux-gnu/libudev.so.1.6.4 /lib/x86_64-linux-gnu/libudev.so.0 13 | 14 | 15 | cd third_party_library 16 | unzip opencv-3.3.0.zip 17 | tar -xzf Sophus.tar.gz 18 | unzip librealsense-master.zip 19 | unzip Pangolin-master.zip 20 | 21 | # opencv 22 | cd opencv-3.3.0 23 | mkdir build 24 | cd build 25 | cmake -D CMAKE_BUILD_TYPE=RELEASE -DBUILD_opencv_stitching=OFF -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUDA=OFF -DENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D BUILD_TIFF=ON .. 26 | make -j 27 | 28 | # pangolin 29 | cd ../../Pangolin-master 30 | mkdir build 31 | cd build 32 | cmake .. 33 | make -j 34 | 35 | # sophus 36 | cd ../../Sophus 37 | mkdir build 38 | cd build 39 | cmake .. 40 | make -j 41 | 42 | # librealsense 43 | cd ../../librealsense-master 44 | mkdir build 45 | cd build 46 | cmake .. 47 | make -j 48 | 49 | # chisel 50 | cd ../../../CHISEL 51 | mkdir build 52 | cd build 53 | cmake ../src 54 | make -j 55 | cd ../.. 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /settings.yaml: -------------------------------------------------------------------------------- 1 | %YAML:1.0 2 | 3 | max_feature_num: 2000 4 | # for experiments 5 | runFrameNum: 10000 6 | runTestFlag: 0 7 | runRefFrame: 800 8 | runNewFrame: 800 9 | debug_mode: 1 10 | # trade-off between accuracy and efficiency 11 | ransac_maximum_iterations: 400 12 | maximum_keyframe_match_num: 5 13 | use_fine_search: 1 14 | 15 | 16 | # should be optimized by algorithm, select the parameters automatically. 17 | minimum_disparity: 0.1 18 | reprojection_error_3d_threshold: 0.01 19 | reprojection_error_2d_threshold: 6 20 | keyframe_minimum_distance: 4 21 | remove_outlier_keyframes: 0 22 | use_icp_registration: 0 23 | icp_weight: 0.5 24 | far_plane_distance: 3 25 | 26 | 27 | # not sure if it is reasonable 28 | 29 | #fixed parameters 30 | hamming_distance_threshold: 50 31 | salient_score_threshold: 1.5 32 | maximum_local_frame_match_num: 10 33 | save_ply_files: 0 34 | -------------------------------------------------------------------------------- /third_party_library/OpenNI-Linux-x64-2.2.0.33.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/third_party_library/OpenNI-Linux-x64-2.2.0.33.tar.bz2 -------------------------------------------------------------------------------- /third_party_library/Pangolin-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/third_party_library/Pangolin-master.zip -------------------------------------------------------------------------------- /third_party_library/Sophus.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/third_party_library/Sophus.tar.gz -------------------------------------------------------------------------------- /third_party_library/librealsense-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/third_party_library/librealsense-master.zip -------------------------------------------------------------------------------- /third_party_library/opencv-3.3.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/THU-luvision/Flashfusion/f9cd28b19a1272d08033354729d2a5d748853910/third_party_library/opencv-3.3.0.zip --------------------------------------------------------------------------------