-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Added external Libraries if possible as git submodules -Added Catch2 Test Framework & structure -General Helper Classes moved to KinectFusion cmake Library
- Loading branch information
Showing
18 changed files
with
926 additions
and
794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "extern/Catch2"] | ||
path = extern/Catch2 | ||
url = https://github.com/catchorg/Catch2.git | ||
[submodule "extern/eigen-git-mirror"] | ||
path = extern/eigen-git-mirror | ||
url = https://github.com/eigenteam/eigen-git-mirror.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,24 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
set(PROJECT_NAME KinectFusion) | ||
project(${PROJECT_NAME}) | ||
|
||
cmake_minimum_required(VERSION 3.1) | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | ||
|
||
set(EXECUTABLE_OUTPUT_PATH bin) | ||
set(LIBRARY_OUTPUT_PATH lib) | ||
|
||
# Required libraries | ||
find_package(Eigen3 REQUIRED) | ||
include_directories(${EIGEN3_INCLUDE_DIR}) | ||
set (CMAKE_CXX_STANDARD 14) | ||
|
||
find_package(FreeImage REQUIRED) | ||
include_directories(${FREEIMAGE_INCLUDE_DIRS}) | ||
|
||
set( HEADER_FILES | ||
${PROJECT_SOURCE_DIR}/src/FreeImageHelper.h | ||
${PROJECT_SOURCE_DIR}/src/VirtualSensor.h | ||
) | ||
#adds gitsubmodules | ||
add_subdirectory(extern) | ||
### if CMAKE Build Time | ||
#adds our KinectFusion Lib | ||
add_subdirectory(FusionLib) | ||
|
||
set( SOURCE_FILES | ||
${PROJECT_SOURCE_DIR}/src/FreeImageHelper.cpp | ||
${PROJECT_SOURCE_DIR}/src/DepthMapConverter.cpp | ||
${PROJECT_SOURCE_DIR}/src/main.cpp | ||
) | ||
#<-------Stuff for directly building an Application-----> | ||
set(APP_ONE ${PROJECT_NAME} ) | ||
add_executable(${APP_ONE} main.cpp) | ||
#target_link_libraries (${TEST_TARGET_ONE} graph Eigen3::Eigen )# libdl)# pybind11) | ||
target_link_libraries (${APP_ONE} kfusion eigenI ${FREEIMAGE_LIBRARIES})# libdl)# pybind11) | ||
target_compile_features(${APP_ONE} PUBLIC cxx_std_17) | ||
|
||
ADD_EXECUTABLE(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES}) | ||
|
||
target_link_libraries(${PROJECT_NAME} ${FREEIMAGE_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
|
||
include_directories(include) | ||
set(FUSION_Name kfusion) | ||
###set Kinect Fusion Library sources### | ||
set(FUSION_SOURCES | ||
src/DepthMapConverter.cpp | ||
src/FreeImageHelper.cpp | ||
src/VirtualSensor.cpp) | ||
|
||
add_library(${FUSION_Name} ${FUSION_SOURCES}) | ||
target_include_directories(${FUSION_Name} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include) | ||
### link external libraries to Kinect Fusion Library | ||
target_link_libraries(${FUSION_Name} eigenI catch2I ) | ||
set_target_properties(${FUSION_Name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) | ||
|
||
### Adds catch2 Tests in FusionLib/tests ### | ||
MACRO (FUSIONLib_TEST NAME) | ||
SET(MODULES "${ARGN}") | ||
ADD_EXECUTABLE(test_${NAME} test_${NAME}.cpp ${PROJECT_SOURCE_DIR}/FusionLib/test_main.cpp) | ||
TARGET_LINK_LIBRARIES(test_${NAME} ${MODULES} eigenI catch2I ) | ||
ADD_TEST(test_${NAME} test_${NAME}) | ||
ENDMACRO (FUSIONLib_TEST) | ||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,92 @@ | ||
#pragma once | ||
|
||
#ifndef VERBOSE | ||
//#define VERBOSE(msg) {std::cout << msg << std::endl;} | ||
#define VERBOSE(msg) | ||
#endif | ||
|
||
#ifndef ASSERT | ||
#define ASSERT(a) {if (!a) { std::cerr << "Error:\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\nFunction: " << __FUNCTION__ << std::endl; while(1); }} | ||
#endif | ||
|
||
#ifndef SAFE_DELETE | ||
#define SAFE_DELETE(ptr) {if(ptr!=nullptr) {delete ptr; ptr = nullptr;}} | ||
#endif | ||
|
||
#ifndef SAFE_DELETE_ARRAY | ||
#define SAFE_DELETE_ARRAY(ptr) {if(ptr!=nullptr) {delete[] ptr; ptr = nullptr;}} | ||
#endif | ||
|
||
#ifndef MINF | ||
#define MINF -std::numeric_limits<float>::infinity() | ||
#endif | ||
|
||
#ifndef M_PI | ||
#define M_PI 3.14159265359 | ||
#endif | ||
|
||
|
||
#include <Eigen/Dense> | ||
#include <Eigen/StdVector> | ||
#include <Eigen/Eigenvalues> | ||
#include <unsupported/Eigen/NonLinearOptimization> | ||
#include <Eigen/Sparse> | ||
#include <Eigen/SparseCholesky> | ||
|
||
typedef Eigen::Matrix<unsigned char, 4, 1> Vector4uc; | ||
|
||
|
||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector4f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Vector4uc) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::VectorXf) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix4f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::MatrixXf) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Quaternionf) | ||
|
||
|
||
|
||
using namespace Eigen; | ||
|
||
template<typename T,unsigned int n,unsigned m> | ||
std::istream &operator>>(std::istream &in, Matrix<T,n,m> &other) | ||
{ | ||
for(unsigned int i=0; i<other.rows(); i++) | ||
for(unsigned int j=0; j<other.cols(); j++) | ||
in >> other(i,j); | ||
return in; | ||
} | ||
|
||
template<typename T,unsigned int n,unsigned m> | ||
std::ostream &operator<<(std::ostream &out, const Matrix<T,n,m> &other) | ||
{ | ||
std::fixed(out); | ||
for(int i=0; i<other.rows(); i++) { | ||
out << other(i,0); | ||
for(int j=1; j<other.cols(); j++) { | ||
out << "\t" << other(i,j); | ||
} | ||
out << std::endl; | ||
} | ||
return out; | ||
} | ||
|
||
template<typename T> | ||
std::istream &operator>>(std::istream &in, Eigen::Quaternion<T> &other) | ||
{ | ||
in >> other.x() >> other.y() >> other.z() >> other.w(); | ||
return in; | ||
} | ||
|
||
template<typename T> | ||
std::ostream &operator<<(std::ostream &out, const Eigen::Quaternion<T> &other) | ||
{ | ||
std::fixed(out); | ||
out << other.x() << "\t" << other.y() << "\t" << other.z() << "\t" << other.w(); | ||
return out; | ||
} | ||
// | ||
// Created by pbo on 27.06.19. | ||
// | ||
|
||
#pragma once | ||
|
||
#ifndef VERBOSE | ||
//#define VERBOSE(msg) {std::cout << msg << std::endl;} | ||
#define VERBOSE(msg) | ||
#endif | ||
|
||
#ifndef ASSERT | ||
#define ASSERT(a) {if (!a) { std::cerr << "Error:\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\nFunction: " << __FUNCTION__ << std::endl; while(1); }} | ||
#endif | ||
|
||
#ifndef SAFE_DELETE | ||
#define SAFE_DELETE(ptr) {if(ptr!=nullptr) {delete ptr; ptr = nullptr;}} | ||
#endif | ||
|
||
#ifndef SAFE_DELETE_ARRAY | ||
#define SAFE_DELETE_ARRAY(ptr) {if(ptr!=nullptr) {delete[] ptr; ptr = nullptr;}} | ||
#endif | ||
|
||
#ifndef MINF | ||
#define MINF -std::numeric_limits<float>::infinity() | ||
#endif | ||
|
||
#ifndef M_PI | ||
#define M_PI 3.14159265359 | ||
#endif | ||
|
||
|
||
#include <Eigen/Dense> | ||
#include <Eigen/StdVector> | ||
#include <Eigen/Eigenvalues> | ||
#include <unsupported/Eigen/NonLinearOptimization> | ||
#include <Eigen/Sparse> | ||
#include <Eigen/SparseCholesky> | ||
|
||
typedef Eigen::Matrix<unsigned char, 4, 1> Vector4uc; | ||
|
||
|
||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector4f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Vector4uc) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::VectorXf) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix4f) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::MatrixXf) | ||
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Quaternionf) | ||
|
||
|
||
|
||
using namespace Eigen; | ||
|
||
template<typename T,unsigned int n,unsigned m> | ||
std::istream &operator>>(std::istream &in, Matrix<T,n,m> &other) | ||
{ | ||
for(unsigned int i=0; i<other.rows(); i++) | ||
for(unsigned int j=0; j<other.cols(); j++) | ||
in >> other(i,j); | ||
return in; | ||
} | ||
|
||
template<typename T,unsigned int n,unsigned m> | ||
std::ostream &operator<<(std::ostream &out, const Matrix<T,n,m> &other) | ||
{ | ||
std::fixed(out); | ||
for(int i=0; i<other.rows(); i++) { | ||
out << other(i,0); | ||
for(int j=1; j<other.cols(); j++) { | ||
out << "\t" << other(i,j); | ||
} | ||
out << std::endl; | ||
} | ||
return out; | ||
} | ||
|
||
template<typename T> | ||
std::istream &operator>>(std::istream &in, Eigen::Quaternion<T> &other) | ||
{ | ||
in >> other.x() >> other.y() >> other.z() >> other.w(); | ||
return in; | ||
} | ||
|
||
template<typename T> | ||
std::ostream &operator<<(std::ostream &out, const Eigen::Quaternion<T> &other) | ||
{ | ||
std::fixed(out); | ||
out << other.x() << "\t" << other.y() << "\t" << other.z() << "\t" << other.w(); | ||
return out; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <iostream> | ||
#include <cstring> | ||
#include <fstream> | ||
|
||
#include <EigenHelper.hpp> | ||
#include "FreeImageHelper.hpp" | ||
|
||
typedef unsigned char BYTE; | ||
|
||
// reads sensor files according to https://vision.in.tum.de/data/datasets/rgbd-dataset/file_formats | ||
class VirtualSensor | ||
{ | ||
public: | ||
|
||
VirtualSensor(); | ||
|
||
~VirtualSensor(); | ||
|
||
bool Init(const std::string& datasetDir); | ||
|
||
bool ProcessNextFrame(); | ||
|
||
unsigned int GetCurrentFrameCnt(); | ||
|
||
// get current color data | ||
BYTE* GetColorRGBX(); | ||
|
||
// get current depth data | ||
float* GetDepth(); | ||
|
||
// color camera info | ||
Eigen::Matrix3f GetColorIntrinsics(); | ||
|
||
Eigen::Matrix4f GetColorExtrinsics(); | ||
|
||
unsigned int GetColorImageWidth(); | ||
|
||
unsigned int GetColorImageHeight(); | ||
|
||
// depth (ir) camera info | ||
Eigen::Matrix3f GetDepthIntrinsics(); | ||
|
||
Eigen::Matrix4f GetDepthExtrinsics(); | ||
|
||
unsigned int GetDepthImageWidth(); | ||
|
||
unsigned int GetDepthImageHeight(); | ||
|
||
// get current trajectory transformation | ||
Eigen::Matrix4f GetTrajectory(); | ||
|
||
private: | ||
|
||
bool ReadFileList(const std::string& filename, std::vector<std::string>& result, std::vector<double>& timestamps); | ||
|
||
bool ReadTrajectoryFile(const std::string& filename, std::vector<Eigen::Matrix4f>& result, std::vector<double>& timestamps); | ||
|
||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
|
||
// current frame index | ||
int m_currentIdx; | ||
|
||
int m_increment; | ||
|
||
// frame data | ||
float* m_depthFrame; | ||
BYTE* m_colorFrame; | ||
Eigen::Matrix4f m_currentTrajectory; | ||
|
||
// color camera info | ||
Eigen::Matrix3f m_colorIntrinsics; | ||
Eigen::Matrix4f m_colorExtrinsics; | ||
unsigned int m_colorImageWidth; | ||
unsigned int m_colorImageHeight; | ||
|
||
// depth (ir) camera info | ||
Eigen::Matrix3f m_depthIntrinsics; | ||
Eigen::Matrix4f m_depthExtrinsics; | ||
unsigned int m_depthImageWidth; | ||
unsigned int m_depthImageHeight; | ||
|
||
// base dir | ||
std::string m_baseDir; | ||
// filenamelist depth | ||
std::vector<std::string> m_filenameDepthImages; | ||
std::vector<double> m_depthImagesTimeStamps; | ||
// filenamelist color | ||
std::vector<std::string> m_filenameColorImages; | ||
std::vector<double> m_colorImagesTimeStamps; | ||
|
||
// trajectory | ||
std::vector<Eigen::Matrix4f> m_trajectory; | ||
std::vector<double> m_trajectoryTimeStamps; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "VirtualSensor.hpp" | ||
|
||
#include <Eigen/Dense> | ||
|
||
|
Oops, something went wrong.