Skip to content

Commit

Permalink
final version code
Browse files Browse the repository at this point in the history
  • Loading branch information
Boyuan-Tian committed Aug 15, 2019
1 parent cfa8ebe commit a0c20cb
Show file tree
Hide file tree
Showing 969 changed files with 272,222 additions and 127,880 deletions.
20 changes: 13 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

find_package(PCL 1.7 REQUIRED)

set(PCL_DIR "/usr/local/share/pcl-1.8")
#find_package(PCL 1.9 REQUIRED HINTS "~/local/")
find_package(PCL 1.7 REQUIRED PATHS "./" NO_DEFAULT_PATH)
# find_package(PCL 1.7 REQUIRED PATHS "./")
list(REMOVE_ITEM PCL_LIBRARIES "vtkproj4")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")

include_directories(${PCL_INCLUDE_DIRS} include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -DNDEBUG -fopenmp")

message("\nPCL include: \n${PCL_INCLUDE_DIRS}\n")
include_directories("./pcl-1.7;/usr/include/eigen3;~/local/flann/include;" include)

link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS} -O3 -DNDEBUG -DPCL_NO_PRECOMPILE)
add_executable (pc_pipeline src/modules.cpp src/utils.cpp src/read_config.cpp src/pc_pipeline.cpp)
target_link_libraries (pc_pipeline ${PCL_LIBRARIES})

add_executable (pc-registration src/utils.cpp src/pc-registration.cpp)
target_link_libraries (pc-registration ${PCL_LIBRARIES})
set_property(TARGET pc_pipeline PROPERTY CXX_STANDARD 11)

set_property(TARGET pc-registration PROPERTY CXX_STANDARD 11)
SET(EXECUTABLE_OUTPUT_PATH .././bin)
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
BUILD_DIR = ./build
BIN_DIR = ./bin

.PHONY:build

build:
mkdir $(BUILD_DIR); cd $(BUILD_DIR); cmake ..; make;

clean:
rm -rf build/*;

clean_result:
rm -rf result/result*

run:
cd $(BIN_DIR); ./pc_pipeline
46 changes: 46 additions & 0 deletions bin/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[File Directory Parameters]
Dataset_Directory: ../sample_data/
Result_Directory: ../result/

[Normal Estimation Parameters]
Normal_Search_Radius: 0.75
Normal_Use_Customized_KDTree: true
Normal_Max_Leaf_Size: 64


[Key Point Detection Parameters]
Key_Point_Detection_Module: NARF


[Feature Description Parameters]
Feature_Search_Radius: 0.85
Feature_Module: SHOT


[Correspondence Estimation Parameters]
Corr_Est_Use_Reciprocal_Search: true


[Correspondence Rejection Parameters]
Ransac_Threshold: 0.2
Ransac_Max_Iteration: 10000


[ICP Parameters]
ICP_Solver: SVD
ICP_Max_Iteration: 15
ICP_Use_Ransac: true
ICP_Use_Reciprocal_Search: true

ICP_Transformation_Epsilon: 1e-9
ICP_Max_Correspondence_Distance: 1.2
ICP_Euclidean_Fitness_Epsilon: 1e-6
ICP_Ransac_Outlier_Rejection_Threshold: 120

ICP_Use_Customized_KDTree: true
ICP_Max_Leaf_Size: 32

[Approximation Search Parameters]
Approx_Radius_Search_Para: 0
Approx_Nearest_Search_Para: 0
Save_Approx_Data: false
67 changes: 0 additions & 67 deletions build/run.py

This file was deleted.

32 changes: 32 additions & 0 deletions include/modules.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef MODULES_H
#define MODULES_H

#include "typedefs.h"

extern "C" {

void filter(FeatureCloud &cloud);
void downSample(FeatureCloud &cloud, float gridsize);

void keyPointsNARF(FeatureCloud &cloud);
void keyPointsSIFT(FeatureCloud &cloud);
void keyPointsHARRIS(FeatureCloud &cloud);

void constructPointNormal(FeatureCloud &source_cloud, FeatureCloud &target_cloud);
void computeSurfaceNormals (FeatureCloud &cloud, std::vector<int> &LF_points_counter, \
std::vector<int> &LF_operations_counter);

void computeFeatures_FPFH (FeatureCloud &cloud, float R);
void computeFeatures_SHOT (FeatureCloud &cloud, float R);

void estimateCorrespondence(FeatureCloud &source_cloud, FeatureCloud &target_cloud, \
pcl::Correspondences &all_corres);
void rejectCorrespondences(FeatureCloud &source_cloud, FeatureCloud &target_cloud,\
pcl::Correspondences &correspondences, pcl::Correspondences &inliers, \
Result *result);
void iterativeClosestPoints(FeatureCloud &source_cloud, FeatureCloud &target_cloud, Result *result, \
pcl::Correspondences &inliers, std::vector<int> &LF_points_counter, std::vector<int> &LF_operations_counter);

}

#endif
93 changes: 93 additions & 0 deletions include/read_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <typeinfo>

// configuration file class
class Config
{

protected:
// seperator between key and value
std::string m_Comment;
// seperator between value and comments
std::string m_Delimiter;
// extracted keys and values
std::map<std::string, std::string> m_Contents;
// map iterator
typedef std::map<std::string, std::string>::const_iterator mapci;

public:

Config(std::string filename, std::string delimiter = ":", std::string comment = "#");
Config();

template<class T>
T Read(const std::string &in_key) const;

template<class T>
T Read(const std::string &in_key, const T &in_value) const;

private:

friend std::istream &operator >> (std::istream &is, Config &cf);

template<class T>
static T string_as_T(const mapci &p);

static void Trim(std::string &inout_s);

struct File_Not_Found
{
std::string filename;
File_Not_Found(const std::string &filename_ = std::string())
:filename(filename_){}
};

struct Key_Not_Found
{
std::string key;
Key_Not_Found(const std::string &key_ = std::string())
:key(key_){}
};

};

template<class T>
T Config::string_as_T(const mapci &p)
{
T t;
std::istringstream ist(p->second);

if (typeid(t) == typeid(bool)) // if key is bool type
{
ist >> std::boolalpha >> t;
std::cout << p->first << " : " << t << std::endl;
return t;
}
else if(ist >> t) // if key has a value
{
std::cout << p->first << " : " << t << std::endl;
return t;
}
else
{
std::cout << "Value For Key " << p->first << " Is Invalid!" << std::endl;
exit(-1);
}
}

template<class T>
T Config::Read(const std::string &key, const T &value) const
{
mapci p = m_Contents.find(key);
if (p == m_Contents.end())
{
std::cout << "Key " << key << " Not Found!" << std::endl;
throw Key_Not_Found(key);
}
else
return string_as_T<T>(p);
}
Loading

0 comments on commit a0c20cb

Please sign in to comment.