├── .gitignore ├── CalculateFeature ├── CalculateFeature.vcxproj ├── CalculateFeature.vcxproj.filters └── calculate_feature.cpp ├── CmdUtility ├── CmdUtility.vcxproj ├── CmdUtility.vcxproj.filters ├── cmd_utility.cpp └── cmd_utility.h ├── CompareResultTool ├── CompareResultTool.vcxproj ├── CompareResultTool.vcxproj.filters └── compare_result_tool.cpp ├── CreateGridTool ├── CreateGridTool.vcxproj ├── CreateGridTool.vcxproj.filters └── create_grid_tool.cpp ├── DataDrivenClassify ├── DataDrivenClassify.vcxproj ├── DataDrivenClassify.vcxproj.filters └── classify.cpp ├── Downsample ├── Downsample.vcxproj ├── Downsample.vcxproj.filters └── downsample.cpp ├── OutlierRemover └── outlier_remover.cpp ├── ParsingEngine.sln ├── ParsingFacadeTool ├── ParsingFacadeTool.vcxproj ├── ParsingFacadeTool.vcxproj.filters └── parse_facade_tool.cpp ├── PassThroughFilter ├── PassThroughFilter.vcxproj ├── PassThroughFilter.vcxproj.filters └── pass_through_filter.cpp ├── PclCore ├── PclCore.vcxproj ├── PclCore.vcxproj.filters ├── pclib.cpp └── pclib.h ├── ReadMe ├── ReinforcementLearningCore ├── ReinforcementLearningCore.filters ├── ReinforcementLearningCore.vcxproj ├── ReinforcementLearningCore.vcxproj.filters ├── rl_algorithm.cpp ├── rl_algorithm.h ├── rl_utility.cpp └── rl_utility.h ├── ReviseGridTool ├── ReviseGridTool.vcxproj ├── ReviseGridTool.vcxproj.filters └── revise_grid_tool.cpp ├── SampleInput ├── cofigure.json └── grammar.json ├── ShapeGrammarCore ├── ShapeGrammarCore.vcxproj ├── ShapeGrammarCore.vcxproj.filters ├── facade_geography.cpp ├── facade_geography.h ├── facade_grammar.cpp ├── facade_grammar.h ├── facade_model.cpp ├── facade_model.h ├── grammar_elements.cpp ├── grammar_elements.h ├── main_page.h ├── rule_define.h ├── scale_model.cpp └── scale_model.h ├── TestShapeGrammar ├── TestShapeGrammarCore.vcxproj ├── TestShapeGrammarCore.vcxproj.filters └── test.cpp ├── Tests ├── Tests.vcxproj ├── Tests.vcxproj.filters ├── rl_utility_test.h ├── run_tests.cpp ├── shape_grammar_test.h └── test_suits.h ├── TransformPointCloudTool ├── TransformPointCloudTool.vcxproj ├── TransformPointCloudTool.vcxproj.filters └── transform_cloud.cpp ├── Txt2Pcd └── txt2pcd.cpp ├── Usage └── key guid /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # My folders 5 | 3rd/ 6 | Doc/ 7 | Experiments/ 8 | RawData/ 9 | ResultGallery/ 10 | TestResults/ 11 | *.pcd 12 | *.txt 13 | 14 | # User-specific files 15 | *.suo 16 | *.user 17 | *.sln.docstates 18 | 19 | # Build results 20 | 21 | [Dd]ebug/ 22 | [Rr]elease/ 23 | x64/ 24 | build/ 25 | [Bb]in/ 26 | [Oo]bj/ 27 | 28 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 29 | !packages/*/build/ 30 | 31 | # MSTest test Results 32 | [Tt]est[Rr]esult*/ 33 | [Bb]uild[Ll]og.* 34 | 35 | *_i.c 36 | *_p.c 37 | *.ilk 38 | *.meta 39 | *.obj 40 | *.pch 41 | *.pdb 42 | *.pgc 43 | *.pgd 44 | *.rsp 45 | *.sbr 46 | *.tlb 47 | *.tli 48 | *.tlh 49 | *.tmp 50 | *.tmp_proj 51 | *.log 52 | *.vspscc 53 | *.vssscc 54 | .builds 55 | *.pidb 56 | *.log 57 | *.scc 58 | 59 | # Visual C++ cache files 60 | ipch/ 61 | *.aps 62 | *.ncb 63 | *.opensdf 64 | *.sdf 65 | *.cachefile 66 | 67 | # Visual Studio profiler 68 | *.psess 69 | *.vsp 70 | *.vspx 71 | 72 | # Guidance Automation Toolkit 73 | *.gpState 74 | 75 | # ReSharper is a .NET coding add-in 76 | _ReSharper*/ 77 | *.[Rr]e[Ss]harper 78 | 79 | # TeamCity is a build add-in 80 | _TeamCity* 81 | 82 | # DotCover is a Code Coverage Tool 83 | *.dotCover 84 | 85 | # NCrunch 86 | *.ncrunch* 87 | .*crunch*.local.xml 88 | 89 | # Installshield output folder 90 | [Ee]xpress/ 91 | 92 | # DocProject is a documentation generator add-in 93 | DocProject/buildhelp/ 94 | DocProject/Help/*.HxT 95 | DocProject/Help/*.HxC 96 | DocProject/Help/*.hhc 97 | DocProject/Help/*.hhk 98 | DocProject/Help/*.hhp 99 | DocProject/Help/Html2 100 | DocProject/Help/html 101 | 102 | # Click-Once directory 103 | publish/ 104 | 105 | # Publish Web Output 106 | *.Publish.xml 107 | *.pubxml 108 | 109 | # NuGet Packages Directory 110 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 111 | #packages/ 112 | 113 | # Windows Azure Build Output 114 | csx 115 | *.build.csdef 116 | 117 | # Windows Store app package directory 118 | AppPackages/ 119 | 120 | # Others 121 | sql/ 122 | *.Cache 123 | ClientBin/ 124 | [Ss]tyle[Cc]op.* 125 | ~$* 126 | *~ 127 | *.dbmdl 128 | *.[Pp]ublish.xml 129 | *.pfx 130 | *.publishsettings 131 | 132 | # RIA/Silverlight projects 133 | Generated_Code/ 134 | 135 | # Backup & report files from converting an old project file to a newer 136 | # Visual Studio version. Backup files are not needed, because we have git ;-) 137 | _UpgradeReport_Files/ 138 | Backup*/ 139 | UpgradeLog*.XML 140 | UpgradeLog*.htm 141 | 142 | # SQL Server files 143 | App_Data/*.mdf 144 | App_Data/*.ldf 145 | 146 | # ========================= 147 | # Windows detritus 148 | # ========================= 149 | 150 | # Windows image file caches 151 | Thumbs.db 152 | ehthumbs.db 153 | 154 | # Folder config file 155 | Desktop.ini 156 | 157 | # Recycle Bin used on file shares 158 | $RECYCLE.BIN/ 159 | 160 | # Mac crap 161 | .DS_Store 162 | -------------------------------------------------------------------------------- /CalculateFeature/CalculateFeature.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /CalculateFeature/calculate_feature.cpp: -------------------------------------------------------------------------------- 1 | #include "cmd_utility.h" 2 | #include "facade_model.h" 3 | #include "boost/program_options.hpp" 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | CommandLineArgument cmd_arguments; 10 | 11 | pcl::PointCloud::Ptr facade_cloud(new pcl::PointCloud); 12 | std::shared_ptr facade_grammar; 13 | std::shared_ptr facade_model; 14 | 15 | int main(int argc, char** argv) { 16 | // Step 0 17 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 18 | return -1; 19 | 20 | // Step 1 21 | cout << "\nLoad the shape grammar.\n"; 22 | facade_grammar = std::shared_ptr(new FacadeGrammar); 23 | facade_grammar->ReadGrammar(cmd_arguments.grammar_); 24 | 25 | // Step 2 26 | cout << "\nInitialize the facade model, "; 27 | facade_model = std::shared_ptr(new FacadeModel(facade_grammar)); 28 | 29 | // Step 3 30 | cout << "\nLoad grids.\n"; 31 | facade_model->LoadGrids(cmd_arguments.revise_grid_); 32 | 33 | // Step 4 34 | cout << "\nLoad point cloud ...\n"; 35 | //pcl::io::loadPCDFile(cloud_file_path, *facade_cloud); 36 | 37 | cout << "\nCompute feature ...\n"; 38 | facade_model->ComputeFeature2(); 39 | 40 | // Step 5 41 | cout << "\nShow feature.\n"; 42 | facade_model->ShowFeature(); 43 | 44 | // Step 6 45 | double vertical_thread, horizontal_thread; 46 | std::cout << "Please input the vertical thread: "; 47 | std::cin >> vertical_thread; 48 | std::cout << "Please input the horizontal thread: "; 49 | std::cin >> horizontal_thread; 50 | 51 | // Step 7 52 | std::cout << "Calculate the action parameters ...\n"; 53 | facade_model->CalculateActionParameters2(vertical_thread, horizontal_thread); 54 | 55 | // Step 8 56 | std::cout << "Save the action parameters.\n"; 57 | facade_model->SaveActionParammeters2(cmd_arguments.action_parameters_debug_); 58 | 59 | // Step 9 60 | std::cout << "Generate validate picture.\n"; 61 | facade_model->DebugCalculateFeature(cmd_arguments.action_parameters_png_); 62 | facade_model->ParseActionParameters(); 63 | 64 | facade_model->SaveActionParammeters(cmd_arguments.action_parameters_); 65 | 66 | cout << "\nDone.\n"; 67 | return 0; 68 | } -------------------------------------------------------------------------------- /CmdUtility/CmdUtility.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {6BA776B1-CF6C-46B0-A735-647D7211B8D4} 15 | Win32Proj 16 | CmdUtility 17 | 18 | 19 | 20 | StaticLibrary 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 55 | true 56 | ..\3rd\rapidjson_lib;..\3rd\boost_build\include\boost-1_54;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | D:\3rd\boost_build\lib;%(AdditionalLibraryDirectories) 62 | 63 | 64 | 65 | 66 | Level3 67 | 68 | 69 | MaxSpeed 70 | true 71 | true 72 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 73 | true 74 | 75 | 76 | Console 77 | true 78 | true 79 | true 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /CmdUtility/CmdUtility.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 23 | 24 | 源文件 25 | 26 | 27 | -------------------------------------------------------------------------------- /CmdUtility/cmd_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "cmd_utility.h" 2 | #include "rapidjson/reader.h" 3 | #include "rapidjson/filestream.h" 4 | #include "rapidjson/document.h" 5 | #include 6 | 7 | CommandLineArgument::CommandLineArgument() { 8 | // Initialize some parameters 9 | episodes_ = 5000; 10 | margin_[0] = margin_[1] = margin_[2] = margin_[3] = 0; 11 | resolution_ = 0.2; 12 | resample_resolution_[0] = resample_resolution_[1] = resample_resolution_[2] = 0.0; 13 | load_qtable_ = 0; 14 | 15 | ready_radius_outlier_remover_ = ready_refine_grid_ = ready_resample_ = ready_statiscal_outlier_remover_ = false; 16 | } 17 | 18 | bool CommandLineArgument::ParseCommandLine(int argc, char** argv) { 19 | boost::program_options::options_description options_desc("Parsing Building Facade Tools Options"); 20 | options_desc.add_options() 21 | ("help", "print help information.") 22 | ("workplace", boost::program_options::value(), "working folder.") 23 | ; 24 | 25 | boost::program_options::variables_map variables_map; 26 | try 27 | { 28 | boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options_desc), variables_map); 29 | boost::program_options::notify(variables_map); 30 | 31 | if(variables_map.count("help") || variables_map.size() == 0) { 32 | std::cout << options_desc << std::endl; 33 | return false; 34 | } 35 | if(variables_map.count("workplace")) { 36 | working_folder = variables_map["workplace"].as(); 37 | } 38 | else 39 | { 40 | return false; 41 | } 42 | } 43 | catch(boost::program_options::error& e) 44 | { 45 | std::cerr << "ERROR: " << e.what() << std::endl << std::endl; 46 | std::cerr << options_desc << std::endl; 47 | return false; 48 | } 49 | return true; 50 | } 51 | 52 | bool CommandLineArgument::ParseCommandLineArgument(int argc, char** argv) { 53 | if (!ParseCommandLine(argc, argv)) 54 | { 55 | return false; 56 | } 57 | 58 | action_parameters_ = working_folder + "\\action.txt"; 59 | action_parameters_debug_ = working_folder + "\\action_debug.txt"; 60 | action_parameters_png_ = working_folder + "\\action.png"; 61 | grammar_ = working_folder + "\\grammar.json"; 62 | /*grid_header_ = working_folder + "\\grid_header.txt"; 63 | grid_wall_png_ = working_folder + "\\grid_wall.png"; 64 | grid_wall_txt_ = working_folder + "\\grid_wall.txt"; 65 | grid_window_png_ = working_folder + "\\grid_window.png"; 66 | grid_window_txt_ = working_folder + "\\grid_window.txt";*/ 67 | grid_ = working_folder + "\\grid_"; 68 | original_result_overlap_png_ = working_folder + "\\compare_result.png"; 69 | parameters_ = working_folder + "\\configure.json"; 70 | pt_pcd_ = working_folder + "\\pt.pcd"; 71 | qtable_ = working_folder + "\\qtable.txt"; 72 | raw_pcd_ = working_folder + "\\raw.pcd"; 73 | raw_txt_ = working_folder + "\\raw.txt"; 74 | result_png_ = working_folder + "\\result.png"; 75 | result_txt_ = working_folder + "\\result.txt"; 76 | /*revise_grid_header_ = working_folder + "\\revise_grid_header.txt"; 77 | revise_grid_wall_png_ = working_folder + "\\revise_grid_wall.png"; 78 | revise_grid_wall_txt_ = working_folder + "\\revise_grid_wall.txt"; 79 | revise_grid_window_png_ = working_folder + "\\revise_grid_window.png"; 80 | revise_grid_window_txt_ = working_folder + "\\revise_grid_window.txt";*/ 81 | revise_grid_ = working_folder + "\\revise_grid_"; 82 | rt_pcd_ = working_folder + "\\rt.pcd"; 83 | 84 | if (!ReadParameters()) 85 | { 86 | return false; 87 | } 88 | else 89 | { 90 | return true; 91 | } 92 | } 93 | 94 | bool CommandLineArgument::ReadParameters() { 95 | rapidjson::Document document; 96 | FILE* fp = fopen(parameters_.c_str(), "r"); 97 | if(fp == NULL) { 98 | return false; 99 | } 100 | 101 | rapidjson::FileStream is(fp); 102 | if(document.ParseStream<0>(is).HasParseError()) { 103 | return false; 104 | } 105 | 106 | if (!document.IsObject()) { 107 | return false; 108 | } 109 | 110 | if (document.HasMember("episodes")) { 111 | episodes_ = document["episodes"].GetInt(); 112 | } 113 | 114 | if (document.HasMember("resolution")) { 115 | resolution_ = document["resolution"].GetDouble(); 116 | } 117 | 118 | if (document.HasMember("load_qtable")) { 119 | load_qtable_ = document["load_qtable"].GetInt(); 120 | } 121 | 122 | if (document.HasMember("margin")) { 123 | const rapidjson::Value& margin = document["margin"]; 124 | if(margin.IsArray()) { 125 | if (margin.Size() == 4) { 126 | for (rapidjson::SizeType i = 0; i < margin.Size(); ++i) { 127 | margin_[i] = margin[i].GetInt(); 128 | } 129 | ready_refine_grid_ = true; 130 | } 131 | } 132 | } 133 | 134 | if (document.HasMember("radius_outlier_remover")) { 135 | const rapidjson::Value& radius_outlier_remover = document["radius_outlier_remover"]; 136 | if(radius_outlier_remover.IsArray()) { 137 | if (radius_outlier_remover.Size() == 2) { 138 | for (rapidjson::SizeType i = 0; i < radius_outlier_remover.Size(); ++i) { 139 | radius_outlier_remover_[i] = radius_outlier_remover[i].GetDouble(); 140 | } 141 | ready_radius_outlier_remover_ = true; 142 | } 143 | } 144 | } 145 | if (document.HasMember("static_outlier_remover")) { 146 | const rapidjson::Value& static_outlier_remover = document["static_outlier_remover"]; 147 | if(static_outlier_remover.IsArray()) { 148 | if (static_outlier_remover.Size() == 4) { 149 | for (rapidjson::SizeType i = 0; i < static_outlier_remover.Size(); ++i) { 150 | statiscal_outlier_remover_[i] = static_outlier_remover[i].GetDouble(); 151 | } 152 | ready_statiscal_outlier_remover_ = true; 153 | } 154 | } 155 | } 156 | if (document.HasMember("resample")) { 157 | const rapidjson::Value& resample = document["resample"]; 158 | if(resample.IsArray()) { 159 | if (resample.Size() == 3) { 160 | for (rapidjson::SizeType i = 0; i < resample.Size(); ++i) { 161 | resample_resolution_[i] = resample[i].GetDouble(); 162 | } 163 | ready_resample_ = true; 164 | } 165 | } 166 | } 167 | 168 | return true; 169 | } -------------------------------------------------------------------------------- /CmdUtility/cmd_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef CMD_UTILITY_H 2 | #define CMD_UTILITY_H 3 | 4 | #include "boost/program_options.hpp" 5 | #include 6 | #include 7 | 8 | class CommandLineArgument { 9 | public: 10 | CommandLineArgument(); 11 | ~CommandLineArgument() {} 12 | 13 | bool ParseCommandLineArgument(int argc, char** argv); 14 | bool ReadParameters(); 15 | bool ParseCommandLine(int argc, char** argv); 16 | 17 | //private: 18 | std::string working_folder; 19 | 20 | // point clouds 21 | std::string raw_pcd_; // raw point cloud in pcd format. 22 | std::string raw_txt_; // raw point cloud in text format 23 | std::string rt_pcd_; // raw transform point cloud. 24 | std::string pt_pcd_; // plane transform point cloud. 25 | 26 | // actions 27 | std::string action_parameters_; 28 | std::string action_parameters_debug_; 29 | std::string action_parameters_png_; 30 | 31 | // grammar file 32 | std::string grammar_; 33 | 34 | // original grid 35 | //std::string grid_header_; 36 | //std::string grid_wall_txt_; 37 | //std::string grid_window_txt_; 38 | //std::string grid_wall_png_; 39 | //std::string grid_window_png_; 40 | std::string grid_; 41 | 42 | // revise grid 43 | /*std::string revise_grid_header_; 44 | std::string revise_grid_wall_txt_; 45 | std::string revise_grid_window_txt_; 46 | std::string revise_grid_wall_png_; 47 | std::string revise_grid_window_png_;*/ 48 | std::string revise_grid_; 49 | 50 | // q table 51 | std::string qtable_; 52 | 53 | // parameter file 54 | std::string parameters_; 55 | double resolution_; 56 | double episodes_; 57 | int load_qtable_; // 0 -- not load; 1 -- load. 58 | //int margin_up_, margin_down_, margin_left_, margin_right_; 59 | int margin_[4]; // up, down, left, right 60 | double resample_resolution_[3]; 61 | double radius_outlier_remover_[2]; 62 | double statiscal_outlier_remover_[2]; 63 | 64 | bool ready_refine_grid_; 65 | bool ready_resample_; 66 | bool ready_radius_outlier_remover_; 67 | bool ready_statiscal_outlier_remover_; 68 | 69 | // result 70 | std::string result_png_; 71 | std::string result_txt_; 72 | std::string original_result_overlap_png_; 73 | 74 | }; 75 | 76 | #endif // !CMD_UTILITY_H 77 | -------------------------------------------------------------------------------- /CompareResultTool/CompareResultTool.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateGridTool/CreateGridTool.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {4E594CA7-F3CC-4682-832F-0510B9BF2B7B} 15 | Win32Proj 16 | CreateGridTool 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | true 56 | ..\CmdUtility;..\3rd\VTK6.0.0\INCLUDE;..\3rd\VTK_BUILD\INCLUDE;..\3rd\pcl_lib\includes;..\3rd\opencv\build\include;..\3rd\flann_build;..\3rd\eigen;..\3rd\boost_build\include\boost-1_54;..\ReinforcementLearningCore;..\ShapeGrammarCore;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | ..\3rd\VTK_BUILD\lib\Debug;..\3rd\pcl_lib\lib;..\3rd\opencv\build\x86\vc11\lib;..\3rd\boost_build\lib;%(AdditionalLibraryDirectories) 62 | boost_chrono-vc110-mt-gd-1_54.lib;boost_filesystem-vc110-mt-gd-1_54.lib;opencv_core246d.lib;opencv_highgui246d.lib;opencv_imgproc246d.lib;opencv_video246d.lib;opencv_videostab246d.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_recognition_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_stereo_debug.lib;pcl_surface_debug.lib;pcl_visualization_debug.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {6ba776b1-cf6c-46b0-a735-647d7211b8d4} 89 | 90 | 91 | {8efede7a-bf56-4a5e-af00-71dd489d8b15} 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /CreateGridTool/CreateGridTool.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateGridTool/create_grid_tool.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "facade_grammar.h" 3 | #include "facade_model.h" 4 | #include "cmd_utility.h" 5 | #include "pcl\io\pcd_io.h" 6 | #include "opencv2/opencv.hpp" 7 | #include "boost/program_options.hpp" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | CommandLineArgument cmd_arguments; 19 | 20 | pcl::PointCloud::Ptr facade_cloud(new pcl::PointCloud); 21 | std::shared_ptr facade_grammar; 22 | std::shared_ptr facade_model; 23 | 24 | // Main function 25 | int main(int argc, char** argv) 26 | { 27 | // Step 0 28 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 29 | return -1; 30 | 31 | // Step 1 32 | cout << "\nLoad the shape grammar.\n"; 33 | facade_grammar = std::shared_ptr(new FacadeGrammar); 34 | facade_grammar->ReadGrammar(cmd_arguments.grammar_); 35 | 36 | // Step 2 37 | cout << "Initialize the facade model, "; 38 | facade_model = std::shared_ptr(new FacadeModel(facade_grammar)); 39 | 40 | // Step 3 41 | cout << "\nLoad the facade point cloud.\n"; 42 | pcl::io::loadPCDFile(cmd_arguments.rt_pcd_, *facade_cloud); 43 | 44 | // Step 4 45 | cout << "\nConstruct the facade grid ...\n"; 46 | facade_model->CreateGridFromPointCloud(facade_cloud, cmd_arguments.resolution_); 47 | 48 | facade_model->RenderGrd(cmd_arguments.grid_); 49 | 50 | facade_model->SaveGrids(cmd_arguments.grid_); 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /DataDrivenClassify/DataDrivenClassify.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | 17 | {255F8377-9774-4264-8AFE-5E56E63279C8} 18 | Win32Proj 19 | DataDrivenClassify 20 | 21 | 22 | 23 | Application 24 | true 25 | v110 26 | Unicode 27 | 28 | 29 | Application 30 | false 31 | v110 32 | true 33 | Unicode 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | true 47 | 48 | 49 | false 50 | 51 | 52 | 53 | 54 | 55 | Level3 56 | Disabled 57 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 58 | true 59 | ..\CmdUtility;..\3rd\flann_build;..\3rd\VTK6.0.0\INCLUDE;..\3rd\VTK_BUILD\INCLUDE;..\3rd\boost_build\include\boost-1_54;..\3rd\eigen;..\3rd\pcl_lib\includes;%(AdditionalIncludeDirectories) 60 | 61 | 62 | Console 63 | true 64 | boost_thread-vc110-mt-gd-1_54.lib;boost_system-vc110-mt-gd-1_54.lib;boost_chrono-vc110-mt-gd-1_54.lib;boost_filesystem-vc110-mt-gd-1_54.lib;boost_date_time-vc110-mt-gd-1_54.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_outofcore_debug.lib;pcl_registration_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_visualization_debug.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;%(AdditionalDependencies) 65 | ..\3rd\VTK_BUILD\lib\Debug;..\3rd\boost_build\lib;..\3rd\pcl_lib\lib;..\vs2012projects\ParsingEngine\DataDrivenClassify;%(AdditionalLibraryDirectories) 66 | 67 | 68 | 69 | 70 | Level3 71 | 72 | 73 | MaxSpeed 74 | true 75 | true 76 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 77 | true 78 | 79 | 80 | Console 81 | true 82 | true 83 | true 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /DataDrivenClassify/DataDrivenClassify.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /DataDrivenClassify/classify.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void RemovePoints(pcl::PointCloud::Ptr cloud_in, std::vector& indices, 15 | pcl::PointCloud::Ptr cloud_out) { 16 | cloud_out->width = cloud_in->width - indices.size(); 17 | cloud_out->height = cloud_in->height; 18 | bool* remove = new bool[cloud_in->points.size()]; 19 | for (int i = 0; i < cloud_in->points.size(); ++i) 20 | { 21 | remove[i] = false; 22 | } 23 | for (int i = 0; i < indices.size(); ++i) 24 | { 25 | remove[indices[i]] = true; 26 | } 27 | 28 | for (int i = 0; i < cloud_in->points.size(); ++i) 29 | { 30 | if (!remove[i]) 31 | { 32 | pcl::PointXYZ point; 33 | point.x = cloud_in->points[i].x; 34 | point.y = cloud_in->points[i].y; 35 | point.z = cloud_in->points[i].z; 36 | cloud_out->points.push_back(point); 37 | } 38 | } 39 | delete[] remove; 40 | } 41 | 42 | void ExtractPlane(pcl::PointCloud::Ptr cloud) 43 | { 44 | std::vector inliers; // build plane indices in the raw building point cloud 45 | pcl::SampleConsensusModelPlane::Ptr 46 | PlaneModel(new pcl::SampleConsensusModelPlane(cloud)); // plane Model 47 | pcl::RandomSampleConsensus ransac(PlaneModel); // ransac 48 | std::ostringstream oss; 49 | int count = 0; 50 | ransac.setDistanceThreshold(0.01); 51 | std::cout << "compute model.\n"; 52 | while (ransac.computeModel()) 53 | { 54 | std::cout << "compute done.\n"; 55 | ++count; 56 | oss << count << ".pcd"; 57 | 58 | ransac.getInliers(inliers); 59 | 60 | std::cout << "plane " << oss.str() << " has " << inliers.size() << " inliers.\n"; 61 | 62 | pcl::PointCloud::Ptr cloud_plane(new pcl::PointCloud); 63 | pcl::copyPointCloud(*cloud, inliers, *cloud_plane); 64 | pcl::io::savePCDFile(oss.str(), *cloud_plane); 65 | std::cout << oss.str() << " saved\n"; 66 | 67 | std::cout << "remove the plane from cloud.\n"; 68 | pcl::PointCloud::Ptr cloud_reduce(new pcl::PointCloud); 69 | RemovePoints(cloud, inliers, cloud_reduce); 70 | std::cout << "remove done.\n"; 71 | 72 | inliers.clear(); 73 | PlaneModel = pcl::SampleConsensusModelPlane::Ptr(new 74 | pcl::SampleConsensusModelPlane(cloud_reduce)); 75 | ransac.setSampleConsensusModel(PlaneModel); 76 | ransac.setDistanceThreshold(0.01); 77 | std::cout << "compute model.\n"; 78 | } 79 | } 80 | 81 | int main (int argc, char** argv) 82 | { 83 | pcl::visualization::PCLVisualizer viewer ("Cluster viewer"); 84 | #if 1 85 | std::cout << "Reading pcd ... \n"; 86 | pcl::PointCloud::Ptr cloud (new pcl::PointCloud); 87 | pcl::PointCloud::Ptr cloud_reduce (new pcl::PointCloud); 88 | if ( pcl::io::loadPCDFile ("rt.pcd", *cloud) == -1) 89 | { 90 | std::cout << "Cloud reading failed." << std::endl; 91 | return (-1); 92 | } 93 | 94 | 95 | std::cout << "Extract plane ...\n"; 96 | std::vector inliers; // build plane indices in the raw building point cloud 97 | pcl::SampleConsensusModelPlane::Ptr 98 | PlaneModel(new pcl::SampleConsensusModelPlane(cloud)); // plane Model 99 | pcl::RandomSampleConsensus ransac(PlaneModel); // ransac 100 | // set attributes... 101 | ransac.setDistanceThreshold(0.01); 102 | ransac.computeModel(); 103 | 104 | Eigen::VectorXf build_plane_coeff(4); 105 | ransac.getModelCoefficients(build_plane_coeff); 106 | 107 | // get result 108 | ransac.getInliers(inliers); 109 | 110 | std::cout << "save building plane...\n"; 111 | pcl::PointCloud::Ptr build_cloud_plane(new pcl::PointCloud); 112 | pcl::copyPointCloud(*cloud, inliers, *build_cloud_plane); 113 | pcl::io::savePCDFile("build_plane.pcd", *build_cloud_plane); 114 | 115 | std::cout << "Remove plane cloud ... \n"; 116 | std::cout << "width = " << cloud->width << " height = " << cloud->height << std::endl; 117 | std::cout << "original #points = " << cloud->points.size() << std::endl; 118 | // remove the inliers from the cloud. 119 | RemovePoints(cloud, inliers, cloud_reduce); 120 | std::cout << "after remove, #points = " << cloud_reduce->points.size() << std::endl; 121 | pcl::io::savePCDFile("rt_reduce.pcd", *cloud_reduce); 122 | #endif 123 | 124 | /*pcl::PointCloud::Ptr cloud_reduce (new pcl::PointCloud); 125 | pcl::io::loadPCDFile ("rt.pcd", *cloud_reduce);*/ 126 | 127 | std::cout << "Compute normal ... \n"; 128 | pcl::search::Search::Ptr tree = boost::shared_ptr > (new pcl::search::KdTree); 129 | pcl::PointCloud ::Ptr normals (new pcl::PointCloud ); 130 | pcl::NormalEstimation normal_estimator; 131 | normal_estimator.setSearchMethod (tree); 132 | normal_estimator.setInputCloud (cloud_reduce); 133 | normal_estimator.setKSearch (30); 134 | normal_estimator.compute (*normals); 135 | 136 | //pcl::IndicesPtr indices (new std::vector ); 137 | //pcl::PassThrough pass; 138 | //pass.setInputCloud (cloud); 139 | //pass.setFilterFieldName ("z"); 140 | //pass.setFilterLimits (0.0, 1.0); 141 | //pass.filter (*indices); 142 | 143 | std::cout << "Region growing ... \n"; 144 | pcl::RegionGrowing reg; 145 | reg.setMinClusterSize (10); 146 | reg.setMaxClusterSize (10000000); 147 | reg.setSearchMethod (tree); 148 | reg.setNumberOfNeighbours (30); 149 | reg.setInputCloud (cloud_reduce); 150 | //reg.setIndices (indices); 151 | reg.setInputNormals (normals); 152 | reg.setSmoothnessThreshold (7.0 / 180.0 * M_PI); 153 | reg.setCurvatureThreshold (1.0); 154 | 155 | std::vector clusters; 156 | reg.extract (clusters); 157 | 158 | std::cout << "Number of clusters is equal to " << clusters.size () << std::endl; 159 | int count = 0; 160 | for (size_t i = 0; i < clusters.size(); ++i) 161 | { 162 | pcl::PointCloud::Ptr cluster_cloud(new pcl::PointCloud); 163 | pcl::copyPointCloud(*cloud_reduce, clusters[i], *cluster_cloud); 164 | 165 | std::vector cluster_inliers; 166 | pcl::SampleConsensusModelPlane::Ptr 167 | cluster_PlaneModel(new pcl::SampleConsensusModelPlane(cluster_cloud)); 168 | pcl::RandomSampleConsensus cluster_ransac(cluster_PlaneModel); 169 | // set attributes... 170 | cluster_ransac.setDistanceThreshold(0.01); 171 | cluster_ransac.computeModel(); 172 | 173 | Eigen::VectorXf cluster_plane_coeff(4); 174 | cluster_ransac.getModelCoefficients(cluster_plane_coeff); 175 | 176 | double coeff_a = cluster_plane_coeff(0) / build_plane_coeff(0); 177 | double coeff_b = cluster_plane_coeff(1) / build_plane_coeff(1); 178 | double coeff_c = cluster_plane_coeff(2) / build_plane_coeff(2); 179 | if (std::fabs(coeff_a - coeff_b) < 0.1 && std::fabs(coeff_a - coeff_c) < 0.1) 180 | { 181 | count++; 182 | std::ostringstream oss; 183 | oss << count << ".pcd"; 184 | // get result 185 | cluster_ransac.getInliers(cluster_inliers); 186 | pcl::PointCloud::Ptr per_cloud(new pcl::PointCloud); 187 | pcl::copyPointCloud(*cluster_cloud, clusters[i], *per_cloud); 188 | pcl::io::savePCDFile(oss.str(), *per_cloud); 189 | 190 | viewer.addPointCloud(per_cloud, oss.str()); 191 | } 192 | 193 | } 194 | 195 | //pcl::PointCloud ::Ptr colored_cloud = reg.getColoredCloud (); 196 | //viewer.showCloud(colored_cloud); 197 | while (!viewer.wasStopped ()) 198 | { 199 | } 200 | 201 | std::cout << "Done.\n"; 202 | return (0); 203 | } -------------------------------------------------------------------------------- /Downsample/Downsample.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {2E19875D-4982-4E38-BA79-3771369E7448} 15 | Win32Proj 16 | Downsample 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 55 | true 56 | ..\CmdUtility;..\3rd\flann_build;..\3rd\VTK6.0.0\INCLUDE;..\3rd\VTK_BUILD\INCLUDE;..\3rd\boost_build\include\boost-1_54;..\3rd\eigen;..\3rd\pcl_lib\includes;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | ..\3rd\VTK_BUILD\lib\Debug;..\3rd\boost_build\lib;..\3rd\pcl_lib\lib;%(AdditionalLibraryDirectories) 62 | boost_thread-vc110-mt-gd-1_54.lib;boost_system-vc110-mt-gd-1_54.lib;boost_chrono-vc110-mt-gd-1_54.lib;boost_filesystem-vc110-mt-gd-1_54.lib;boost_date_time-vc110-mt-gd-1_54.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_outofcore_debug.lib;pcl_registration_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_visualization_debug.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {6ba776b1-cf6c-46b0-a735-647d7211b8d4} 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /Downsample/Downsample.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /Downsample/downsample.cpp: -------------------------------------------------------------------------------- 1 | #include "cmd_utility.h" 2 | #include "pcl\io\pcd_io.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "pcl\filters\\voxel_grid.h" 11 | #include "pcl\filters\statistical_outlier_removal.h" 12 | #include "pcl\filters\extract_indices.h" 13 | #include "pcl\filters\radius_outlier_removal.h" 14 | #include "pcl\filters\conditional_removal.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | CommandLineArgument cmd_arguments; 25 | pcl::PointCloud::Ptr cloud(new pcl::PointCloud); 26 | 27 | //double size_x = 0.1; 28 | //double size_y = 0.1; 29 | //double size_z = 0.1; 30 | 31 | int main(int argc, char** argv) { 32 | /* Step 0 */ 33 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 34 | return -1; 35 | 36 | /* Step 1 */ 37 | std::cout << "Load pcd file ...\n"; 38 | pcl::io::loadPCDFile(cmd_arguments.raw_pcd_, *cloud); 39 | 40 | std::cout << "Before resample, #points = " << cloud->points.size() << std::endl; 41 | std::cout << "Resample ...\n"; 42 | pcl::PointCloud::Ptr sample(new pcl::PointCloud); 43 | 44 | // create the filtering object 45 | pcl::VoxelGrid grid; 46 | grid.setInputCloud(cloud); 47 | //grid.setLeafSize(size_x, size_y, size_z); 48 | grid.setLeafSize(cmd_arguments.resample_resolution_[0],cmd_arguments.resample_resolution_[1], 49 | cmd_arguments.resample_resolution_[2]); 50 | 51 | grid.filter(*sample); 52 | 53 | /* Step 2 */ 54 | std::cout << "After resample, #points = " << sample->points.size() << std::endl; 55 | std::cout << "Saving ...\n"; 56 | pcl::io::savePCDFile(cmd_arguments.raw_pcd_, *sample); 57 | 58 | return 0; 59 | } -------------------------------------------------------------------------------- /OutlierRemover/outlier_remover.cpp: -------------------------------------------------------------------------------- 1 | #include "cmd_utility.h" 2 | #include "pcl\io\pcd_io.h" 3 | #include "pcl\filters\statistical_outlier_removal.h" 4 | #include "pcl\filters\radius_outlier_removal.h" 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | CommandLineArgument cmd_arguments; 10 | pcl::PointCloud::Ptr cloud(new pcl::PointCloud); 11 | pcl::PointCloud::Ptr cloud_remove_outlier; 12 | 13 | pcl::PointCloud::Ptr radius_outliers_removal(pcl::PointCloud::Ptr inputCloud, 14 | double radius, int min_neighbors); 15 | 16 | pcl::PointCloud::Ptr statiscal_outlier_removal( 17 | pcl::PointCloud::Ptr inputCloud, 18 | int num_neighbors, // The number of neighbors to analyze for each point 19 | double stddevmul, // all points who have a distance larger than @stddevmul@ standard deviation of the mean distance 20 | // to the query point will be marked as outliers and removed. 21 | bool inliers 22 | ); 23 | 24 | 25 | int main(int argc, char** argv) 26 | { 27 | /* Step 0 */ 28 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 29 | return -1; 30 | 31 | /* Step 1 */ 32 | cout << "\n=========== Load raw building point cloud ... ==================\n"; 33 | pcl::io::loadPCDFile(cmd_arguments.raw_pcd_ , *cloud); 34 | 35 | /* Step 2 */ 36 | std::cout << "\n=============== Remove outliers ... =======================\n"; 37 | if (cmd_arguments.ready_radius_outlier_remover_) 38 | cloud_remove_outlier = radius_outliers_removal(cloud, cmd_arguments.radius_outlier_remover_[0], 39 | cmd_arguments.radius_outlier_remover_[1]); 40 | else if(cmd_arguments.ready_statiscal_outlier_remover_) 41 | cloud_remove_outlier = statiscal_outlier_removal(cloud, cmd_arguments.statiscal_outlier_remover_[0], 42 | cmd_arguments.statiscal_outlier_remover_[1], true); 43 | 44 | // Step 3 45 | std::cout << "Save ... \n"; 46 | pcl::io::savePCDFile(cmd_arguments.raw_pcd_, *cloud); 47 | 48 | return 0; 49 | } 50 | 51 | pcl::PointCloud::Ptr radius_outliers_removal(pcl::PointCloud::Ptr inputCloud, double radius, int min_neighbors) 52 | { 53 | pcl::PointCloud::Ptr filter(new pcl::PointCloud); 54 | 55 | pcl::RadiusOutlierRemoval outrem; 56 | outrem.setInputCloud(inputCloud); 57 | outrem.setRadiusSearch(radius); 58 | outrem.setMinNeighborsInRadius(min_neighbors); 59 | outrem.filter(*filter); 60 | 61 | return filter; 62 | } 63 | 64 | pcl::PointCloud::Ptr statiscal_outlier_removal( 65 | pcl::PointCloud::Ptr inputCloud, 66 | int num_neighbors, // The number of neighbors to analyze for each point 67 | double stddevmul, // all points who have a distance larger than @stddevmul@ standard deviation of the mean distance 68 | // to the query point will be marked as outliers and removed. 69 | bool inliers 70 | ) 71 | { 72 | pcl::PointCloud::Ptr filterd(new pcl::PointCloud); 73 | 74 | // Create the filtering object 75 | pcl::StatisticalOutlierRemoval sor; 76 | sor.setInputCloud(inputCloud); 77 | sor.setMeanK(num_neighbors); 78 | sor.setStddevMulThresh(stddevmul); 79 | if(!inliers) 80 | sor.setNegative(true); 81 | sor.filter(*filterd); 82 | 83 | return (filterd); 84 | } 85 | -------------------------------------------------------------------------------- /ParsingEngine.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TransformPointCloudTool", "TransformPointCloudTool\TransformPointCloudTool.vcxproj", "{E6ED19CE-C8C5-47B4-A85F-97201ECE910D}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReviseGridTool", "ReviseGridTool\ReviseGridTool.vcxproj", "{EB67A170-6AC7-4502-B536-CDD2A6412A9E}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ParsingFacadeTool", "ParsingFacadeTool\ParsingFacadeTool.vcxproj", "{212A3FA2-6107-4EE2-A8DC-24F851902237}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateGridTool", "CreateGridTool\CreateGridTool.vcxproj", "{4E594CA7-F3CC-4682-832F-0510B9BF2B7B}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReinforcementLearningCore", "ReinforcementLearningCore\ReinforcementLearningCore.vcxproj", "{5CA03A65-4F4E-4A9A-B9C2-7A80E231867B}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShapeGrammarCore", "ShapeGrammarCore\ShapeGrammarCore.vcxproj", "{8EFEDE7A-BF56-4A5E-AF00-71DD489D8B15}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestShapeGrammar", "TestShapeGrammar\TestShapeGrammarCore.vcxproj", "{46E40ADC-66F0-4070-BAC8-BEA9A197507B}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CompareResultTool", "CompareResultTool\CompareResultTool.vcxproj", "{36586AFB-5C45-4C2E-AA5E-67A7FDB198BA}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalculateFeature", "CalculateFeature\CalculateFeature.vcxproj", "{CD78F70E-05D9-430C-9C53-B1A108960802}" 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CmdUtility", "CmdUtility\CmdUtility.vcxproj", "{6BA776B1-CF6C-46B0-A735-647D7211B8D4}" 23 | EndProject 24 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PassThroughFilter", "PassThroughFilter\PassThroughFilter.vcxproj", "{5CE9EFFE-F650-459E-A557-CFA4765FDF50}" 25 | EndProject 26 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Downsample", "Downsample\Downsample.vcxproj", "{2E19875D-4982-4E38-BA79-3771369E7448}" 27 | EndProject 28 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DataDrivenClassify", "DataDrivenClassify\DataDrivenClassify.vcxproj", "{255F8377-9774-4264-8AFE-5E56E63279C8}" 29 | EndProject 30 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OutlierRemover", "OutlierRemover\OutlierRemover.vcxproj", "{6711EF17-CE76-42DA-BE2F-7A75F25B1B63}" 31 | EndProject 32 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Txt2Pcd", "Txt2Pcd\Txt2Pcd.vcxproj", "{48771D75-E9A3-44E4-A4B4-2877A60C2454}" 33 | EndProject 34 | Global 35 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 36 | Debug|Win32 = Debug|Win32 37 | Release|Win32 = Release|Win32 38 | EndGlobalSection 39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 40 | {E6ED19CE-C8C5-47B4-A85F-97201ECE910D}.Debug|Win32.ActiveCfg = Debug|Win32 41 | {E6ED19CE-C8C5-47B4-A85F-97201ECE910D}.Debug|Win32.Build.0 = Debug|Win32 42 | {E6ED19CE-C8C5-47B4-A85F-97201ECE910D}.Release|Win32.ActiveCfg = Release|Win32 43 | {E6ED19CE-C8C5-47B4-A85F-97201ECE910D}.Release|Win32.Build.0 = Release|Win32 44 | {EB67A170-6AC7-4502-B536-CDD2A6412A9E}.Debug|Win32.ActiveCfg = Debug|Win32 45 | {EB67A170-6AC7-4502-B536-CDD2A6412A9E}.Debug|Win32.Build.0 = Debug|Win32 46 | {EB67A170-6AC7-4502-B536-CDD2A6412A9E}.Release|Win32.ActiveCfg = Release|Win32 47 | {EB67A170-6AC7-4502-B536-CDD2A6412A9E}.Release|Win32.Build.0 = Release|Win32 48 | {212A3FA2-6107-4EE2-A8DC-24F851902237}.Debug|Win32.ActiveCfg = Debug|Win32 49 | {212A3FA2-6107-4EE2-A8DC-24F851902237}.Debug|Win32.Build.0 = Debug|Win32 50 | {212A3FA2-6107-4EE2-A8DC-24F851902237}.Release|Win32.ActiveCfg = Release|Win32 51 | {212A3FA2-6107-4EE2-A8DC-24F851902237}.Release|Win32.Build.0 = Release|Win32 52 | {4E594CA7-F3CC-4682-832F-0510B9BF2B7B}.Debug|Win32.ActiveCfg = Debug|Win32 53 | {4E594CA7-F3CC-4682-832F-0510B9BF2B7B}.Debug|Win32.Build.0 = Debug|Win32 54 | {4E594CA7-F3CC-4682-832F-0510B9BF2B7B}.Release|Win32.ActiveCfg = Release|Win32 55 | {4E594CA7-F3CC-4682-832F-0510B9BF2B7B}.Release|Win32.Build.0 = Release|Win32 56 | {5CA03A65-4F4E-4A9A-B9C2-7A80E231867B}.Debug|Win32.ActiveCfg = Debug|Win32 57 | {5CA03A65-4F4E-4A9A-B9C2-7A80E231867B}.Debug|Win32.Build.0 = Debug|Win32 58 | {5CA03A65-4F4E-4A9A-B9C2-7A80E231867B}.Release|Win32.ActiveCfg = Release|Win32 59 | {5CA03A65-4F4E-4A9A-B9C2-7A80E231867B}.Release|Win32.Build.0 = Release|Win32 60 | {8EFEDE7A-BF56-4A5E-AF00-71DD489D8B15}.Debug|Win32.ActiveCfg = Debug|Win32 61 | {8EFEDE7A-BF56-4A5E-AF00-71DD489D8B15}.Debug|Win32.Build.0 = Debug|Win32 62 | {8EFEDE7A-BF56-4A5E-AF00-71DD489D8B15}.Release|Win32.ActiveCfg = Release|Win32 63 | {8EFEDE7A-BF56-4A5E-AF00-71DD489D8B15}.Release|Win32.Build.0 = Release|Win32 64 | {46E40ADC-66F0-4070-BAC8-BEA9A197507B}.Debug|Win32.ActiveCfg = Debug|Win32 65 | {46E40ADC-66F0-4070-BAC8-BEA9A197507B}.Debug|Win32.Build.0 = Debug|Win32 66 | {46E40ADC-66F0-4070-BAC8-BEA9A197507B}.Release|Win32.ActiveCfg = Release|Win32 67 | {46E40ADC-66F0-4070-BAC8-BEA9A197507B}.Release|Win32.Build.0 = Release|Win32 68 | {36586AFB-5C45-4C2E-AA5E-67A7FDB198BA}.Debug|Win32.ActiveCfg = Debug|Win32 69 | {36586AFB-5C45-4C2E-AA5E-67A7FDB198BA}.Debug|Win32.Build.0 = Debug|Win32 70 | {36586AFB-5C45-4C2E-AA5E-67A7FDB198BA}.Release|Win32.ActiveCfg = Release|Win32 71 | {36586AFB-5C45-4C2E-AA5E-67A7FDB198BA}.Release|Win32.Build.0 = Release|Win32 72 | {CD78F70E-05D9-430C-9C53-B1A108960802}.Debug|Win32.ActiveCfg = Debug|Win32 73 | {CD78F70E-05D9-430C-9C53-B1A108960802}.Debug|Win32.Build.0 = Debug|Win32 74 | {CD78F70E-05D9-430C-9C53-B1A108960802}.Release|Win32.ActiveCfg = Release|Win32 75 | {CD78F70E-05D9-430C-9C53-B1A108960802}.Release|Win32.Build.0 = Release|Win32 76 | {6BA776B1-CF6C-46B0-A735-647D7211B8D4}.Debug|Win32.ActiveCfg = Debug|Win32 77 | {6BA776B1-CF6C-46B0-A735-647D7211B8D4}.Debug|Win32.Build.0 = Debug|Win32 78 | {6BA776B1-CF6C-46B0-A735-647D7211B8D4}.Release|Win32.ActiveCfg = Release|Win32 79 | {6BA776B1-CF6C-46B0-A735-647D7211B8D4}.Release|Win32.Build.0 = Release|Win32 80 | {5CE9EFFE-F650-459E-A557-CFA4765FDF50}.Debug|Win32.ActiveCfg = Debug|Win32 81 | {5CE9EFFE-F650-459E-A557-CFA4765FDF50}.Debug|Win32.Build.0 = Debug|Win32 82 | {5CE9EFFE-F650-459E-A557-CFA4765FDF50}.Release|Win32.ActiveCfg = Release|Win32 83 | {5CE9EFFE-F650-459E-A557-CFA4765FDF50}.Release|Win32.Build.0 = Release|Win32 84 | {2E19875D-4982-4E38-BA79-3771369E7448}.Debug|Win32.ActiveCfg = Debug|Win32 85 | {2E19875D-4982-4E38-BA79-3771369E7448}.Debug|Win32.Build.0 = Debug|Win32 86 | {2E19875D-4982-4E38-BA79-3771369E7448}.Release|Win32.ActiveCfg = Release|Win32 87 | {2E19875D-4982-4E38-BA79-3771369E7448}.Release|Win32.Build.0 = Release|Win32 88 | {255F8377-9774-4264-8AFE-5E56E63279C8}.Debug|Win32.ActiveCfg = Debug|Win32 89 | {255F8377-9774-4264-8AFE-5E56E63279C8}.Debug|Win32.Build.0 = Debug|Win32 90 | {255F8377-9774-4264-8AFE-5E56E63279C8}.Release|Win32.ActiveCfg = Release|Win32 91 | {255F8377-9774-4264-8AFE-5E56E63279C8}.Release|Win32.Build.0 = Release|Win32 92 | {6711EF17-CE76-42DA-BE2F-7A75F25B1B63}.Debug|Win32.ActiveCfg = Debug|Win32 93 | {6711EF17-CE76-42DA-BE2F-7A75F25B1B63}.Debug|Win32.Build.0 = Debug|Win32 94 | {6711EF17-CE76-42DA-BE2F-7A75F25B1B63}.Release|Win32.ActiveCfg = Release|Win32 95 | {6711EF17-CE76-42DA-BE2F-7A75F25B1B63}.Release|Win32.Build.0 = Release|Win32 96 | {48771D75-E9A3-44E4-A4B4-2877A60C2454}.Debug|Win32.ActiveCfg = Debug|Win32 97 | {48771D75-E9A3-44E4-A4B4-2877A60C2454}.Debug|Win32.Build.0 = Debug|Win32 98 | {48771D75-E9A3-44E4-A4B4-2877A60C2454}.Release|Win32.ActiveCfg = Release|Win32 99 | {48771D75-E9A3-44E4-A4B4-2877A60C2454}.Release|Win32.Build.0 = Release|Win32 100 | EndGlobalSection 101 | GlobalSection(SolutionProperties) = preSolution 102 | HideSolutionNode = FALSE 103 | EndGlobalSection 104 | EndGlobal 105 | -------------------------------------------------------------------------------- /ParsingFacadeTool/ParsingFacadeTool.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {212A3FA2-6107-4EE2-A8DC-24F851902237} 15 | Win32Proj 16 | ParsingFacadeTool 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | true 56 | ..\3rd\rapidjson_lib;..\CmdUtility;..\3rd\VTK6.0.0\INCLUDE;..\3rd\VTK_BUILD\INCLUDE;..\3rd\pcl_lib\includes;..\3rd\opencv\build\include;..\3rd\flann_build;..\3rd\eigen;..\3rd\boost_build\include\boost-1_54;..\ReinforcementLearningCore;..\ShapeGrammarCore;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | ..\3rd\VTK_BUILD\lib\Debug;..\3rd\pcl_lib\lib;..\3rd\opencv\build\x86\vc11\lib;..\3rd\boost_build\lib;%(AdditionalLibraryDirectories) 62 | boost_chrono-vc110-mt-gd-1_54.lib;boost_filesystem-vc110-mt-gd-1_54.lib;opencv_core246d.lib;opencv_highgui246d.lib;opencv_imgproc246d.lib;opencv_video246d.lib;opencv_videostab246d.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_recognition_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_stereo_debug.lib;pcl_surface_debug.lib;pcl_visualization_debug.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {6ba776b1-cf6c-46b0-a735-647d7211b8d4} 89 | 90 | 91 | {8efede7a-bf56-4a5e-af00-71dd489d8b15} 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /ParsingFacadeTool/ParsingFacadeTool.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /ParsingFacadeTool/parse_facade_tool.cpp: -------------------------------------------------------------------------------- 1 | #include "cmd_utility.h" 2 | #include "facade_grammar.h" 3 | #include "facade_model.h" 4 | 5 | #include "pcl\io\pcd_io.h" 6 | #include "opencv2/opencv.hpp" 7 | #include "boost/program_options.hpp" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | CommandLineArgument cmd_arguments; 19 | 20 | std::shared_ptr facade_grammar; 21 | std::shared_ptr facade_model; 22 | 23 | // Main function 24 | int main(int argc, char** argv) 25 | { 26 | // Step 0 27 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 28 | return -1; 29 | 30 | // Step 1 31 | cout << "\nLoad the shape grammar.\n"; 32 | facade_grammar = std::shared_ptr(new FacadeGrammar); 33 | facade_grammar->ReadGrammar(cmd_arguments.grammar_); 34 | 35 | // Step 2 36 | cout << "\nInitialize the facade model, "; 37 | facade_model = std::shared_ptr(new FacadeModel(facade_grammar)); 38 | 39 | // Step 3 40 | cout << "\nLoad the facade grid ...\n"; 41 | facade_model->LoadGrids(cmd_arguments.revise_grid_); 42 | 43 | // Step 4 44 | std::cout << "\nRunning algorithm ... \n"; 45 | facade_model->set_action_parameter_file(cmd_arguments.action_parameters_); 46 | facade_model->InitModel(); 47 | facade_model->set_qtable_path(cmd_arguments.qtable_.c_str()); 48 | 49 | if (cmd_arguments.load_qtable_) 50 | { 51 | facade_model->LoadQTable(); 52 | } 53 | facade_model->RunParsingAlgorithm(cmd_arguments.episodes_); 54 | 55 | // Step 5 56 | std::cout << "\nRendering result ...\n"; 57 | facade_model->RenderResult(cmd_arguments.result_png_); 58 | facade_model->SaveLearningResult(cmd_arguments.result_txt_); 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /PassThroughFilter/PassThroughFilter.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {5CE9EFFE-F650-459E-A557-CFA4765FDF50} 15 | Win32Proj 16 | PassThroughFilter 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 55 | true 56 | ..\CmdUtility;..\3rd\flann_build;..\3rd\VTK6.0.0\INCLUDE;..\3rd\VTK_BUILD\INCLUDE;..\3rd\boost_build\include\boost-1_54;..\3rd\eigen;..\3rd\pcl_lib\includes;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | ..\3rd\VTK_BUILD\lib\Debug;..\3rd\boost_build\lib;..\3rd\pcl_lib\lib;%(AdditionalLibraryDirectories) 62 | boost_thread-vc110-mt-gd-1_54.lib;boost_system-vc110-mt-gd-1_54.lib;boost_chrono-vc110-mt-gd-1_54.lib;boost_filesystem-vc110-mt-gd-1_54.lib;boost_date_time-vc110-mt-gd-1_54.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_outofcore_debug.lib;pcl_registration_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_visualization_debug.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {6ba776b1-cf6c-46b0-a735-647d7211b8d4} 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /PassThroughFilter/PassThroughFilter.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /PassThroughFilter/pass_through_filter.cpp: -------------------------------------------------------------------------------- 1 | #include "cmd_utility.h" 2 | #include "pcl\io\pcd_io.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "pcl\filters\\voxel_grid.h" 11 | #include "pcl\filters\statistical_outlier_removal.h" 12 | #include "pcl\filters\extract_indices.h" 13 | #include "pcl\filters\radius_outlier_removal.h" 14 | #include "pcl\filters\conditional_removal.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | CommandLineArgument cmd_arguments; 25 | boost::shared_ptr viewer; 26 | pcl::PointCloud::Ptr cloud(new pcl::PointCloud); 27 | pcl::search::KdTree search; 28 | 29 | bool filter = true; 30 | int pick_time = 0; 31 | std::vector picked_points; 32 | 33 | void pp_callback (const pcl::visualization::PointPickingEvent& event, void* cookie); 34 | void FindPickedPoint(const pcl::visualization::PointPickingEvent& event); 35 | void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* cookie); 36 | void ShowCloud(); 37 | 38 | pcl::PointCloud::Ptr passThrough_filter( 39 | pcl::PointCloud::Ptr inputCloud, // input cloud 40 | const std::string& axe, // filter field name is which coordinate? can be: "x", "y" or "z" 41 | double minLimits, // min range 42 | double maxLimits, // max range 43 | bool inside // inside or outside a given user range. 44 | ); 45 | 46 | 47 | int main(int argc, char** argv) { 48 | /* Step 0 */ 49 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 50 | return -1; 51 | 52 | /* Step 1 */ 53 | cout << "\n=========== Load raw building point cloud ... ==================\n"; 54 | pcl::io::loadPCDFile(cmd_arguments.pt_pcd_, *cloud); 55 | 56 | /* Step 2 */ 57 | cout << "\n=========== Showing the building plane ... ==================\n"; 58 | ShowCloud(); 59 | 60 | 61 | return 0; 62 | } 63 | 64 | void FindPickedPoint(const pcl::visualization::PointPickingEvent& event) { 65 | int idx = event.getPointIndex (); 66 | if (idx == -1) 67 | { 68 | std::cout << "Invalid pick!\n;"; 69 | return; 70 | } 71 | search.setInputCloud(cloud); 72 | 73 | // Return the correct index in the cloud instead of the index on the screen 74 | std::vector indices (1); 75 | std::vector distances (1); 76 | 77 | // Because VTK/OpenGL stores data without NaN, we lose the 1-1 correspondence, so we must search for the real point 78 | pcl::PointXYZ picked_pt; 79 | event.getPoint (picked_pt.x, picked_pt.y, picked_pt.z); 80 | search.nearestKSearch (picked_pt, 1, indices, distances); 81 | picked_points.push_back(picked_pt); 82 | } 83 | 84 | void pp_callback(const pcl::visualization::PointPickingEvent& event, void* cookie) 85 | { 86 | if(pick_time == 0) 87 | { 88 | FindPickedPoint(event); 89 | pick_time = 1; 90 | 91 | cout << "Lower bottom point Chosen! [" << picked_points[0].x << ", " 92 | << picked_points[0].y << ", " << picked_points[0].z << "]\n"; 93 | } 94 | else 95 | { 96 | FindPickedPoint(event); 97 | 98 | pick_time = 0; 99 | cout << "Upper right point chosen! And it's ready to filter.[" << picked_points[1].x << ", " 100 | << picked_points[1].y << ", " << picked_points[1].z << "]\n"; 101 | } 102 | } 103 | 104 | void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* cookie) { 105 | if(event.getKeySym() == "f" && filter) 106 | { 107 | std::cout << "original #points = " << cloud->points.size() << std::endl; 108 | cout << "Filter x axe ... \n"; 109 | 110 | pcl::PointCloud::Ptr x_filtered_cloud = 111 | passThrough_filter(cloud, "x", picked_points[0].x, picked_points[1].x, true); 112 | std::cout << "now #points = " << x_filtered_cloud->points.size() << std::endl; 113 | 114 | cout << "Filter y axe ...\n"; 115 | pcl::PointCloud::Ptr xy_filtered_cloud = 116 | passThrough_filter(x_filtered_cloud, "y", picked_points[0].y, picked_points[1].y, true); 117 | std::cout << "now #points = " << xy_filtered_cloud->points.size() << std::endl; 118 | cout << "Filter Done.\n"; 119 | 120 | cout << "Save filtered clouds ...\n"; 121 | pcl::io::savePCDFile(cmd_arguments.pt_pcd_, *xy_filtered_cloud); 122 | cout << "Save Done.\n"; 123 | filter = false; 124 | } 125 | } 126 | 127 | void ShowCloud() { 128 | viewer.reset (new pcl::visualization::PCLVisualizer()); 129 | viewer->addPointCloud (cloud, "build plane cloud"); 130 | viewer->setBackgroundColor (0, 0, 0); 131 | viewer->registerPointPickingCallback(&pp_callback); 132 | viewer->registerKeyboardCallback(&keyboardEventOccurred); 133 | viewer->spin (); 134 | } 135 | 136 | pcl::PointCloud::Ptr passThrough_filter( 137 | pcl::PointCloud::Ptr inputCloud, // input cloud 138 | const std::string& axe, // filter field name is which coordinate? can be: "x", "y" or "z" 139 | double minLimits, // min range 140 | double maxLimits, // max range 141 | bool inside // inside or outside a given user range. 142 | ) 143 | { 144 | pcl::PointCloud::Ptr filtered (new pcl::PointCloud); 145 | 146 | // Create the filtering object 147 | pcl::PassThrough pass; 148 | pass.setInputCloud(inputCloud); 149 | pass.setFilterFieldName(axe); 150 | pass.setFilterLimits(minLimits, maxLimits); 151 | if(!inside) 152 | pass.setFilterLimitsNegative(true); 153 | pass.filter(*filtered); 154 | 155 | return (filtered); 156 | } -------------------------------------------------------------------------------- /PclCore/PclCore.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {86C0F119-73EB-400C-9F16-F0E1B91BD66D} 15 | Win32Proj 16 | PclCore 17 | 18 | 19 | 20 | StaticLibrary 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 55 | true 56 | D:\3rd\flann_build;D:\3rd\VTK6.0.0\INCLUDE;D:\3rd\VTK_BUILD\INCLUDE;D:\3rd\boost_build\include\boost-1_54;D:\3rd\eigen;D:\3rd\pcl_lib\includes;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | D:\3rd\boost_build\lib;D:\3rd\VTK_BUILD\lib\Debug;D:\3rd\pcl_lib\lib;%(AdditionalLibraryDirectories) 62 | pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_outofcore_debug.lib;pcl_registration_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_visualization_debug.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /PclCore/PclCore.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 23 | 24 | 头文件 25 | 26 | 27 | -------------------------------------------------------------------------------- /PclCore/pclib.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartosquare/FacadeParsing/d1ef9d7c14c168c713598351dc74fca11e1c63d3/PclCore/pclib.cpp -------------------------------------------------------------------------------- /PclCore/pclib.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartosquare/FacadeParsing/d1ef9d7c14c168c713598351dc74fca11e1c63d3/PclCore/pclib.h -------------------------------------------------------------------------------- /ReadMe: -------------------------------------------------------------------------------- 1 | |- ParsingEngine: The Root Directory. 2 | |- 3rd: Contains third party libraries. 3 | |- CalculateFeature: Tool for calculating point cloud features. 4 | |- CmdUtility: Tool for Parsing command line arguments and initialize algorithm parameters. 5 | |- CompareResultTool: Tool for comparing the parsing result and original point cloud. 6 | |- CreateGridTool: Tool for creating the building grid using the transformed build point cloud plane. 7 | |- Debug: Contains the .exe programs. 8 | |- Doc: Contains the Doxygen documents. 9 | |- Experiments: Contains all the experiments data. 10 | |- ParsingFacadeTool: Tool Using the reforcement learning and shape grammar to parse the building facade. 11 | |- PclCore: Wrap of the PCL lib for some often used functions. 12 | |- RawData: This folder contains the original point cloud data. 13 | |- ReinforcementLearningCore: The reforcement learning lib. 14 | |- ResultGallery: Contains the parsing result of each experiment. 15 | |- ReviseGridTool: Tool to refine the grid manually. 16 | |- ShapeGrammarCore: The shape grammar lib. 17 | |- TestResults: The unit test result. 18 | |- TestShapeGrammar: A project to test the shape grammar lib. 19 | |- TransformPointCloudTool: Tool to alin the point cloud to X-Y plane. 20 | |- ParsingEngine.sln: The Project Solution. 21 | |- key guid.txt: The key short cut when open a viewer in either program. 22 | |- ReadMe: Contains the describle of the directory tree. 23 | -------------------------------------------------------------------------------- /ReinforcementLearningCore/ReinforcementLearningCore.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 26 | 27 | 源文件 28 | 29 | 30 | 源文件 31 | 32 | 33 | -------------------------------------------------------------------------------- /ReinforcementLearningCore/ReinforcementLearningCore.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {5CA03A65-4F4E-4A9A-B9C2-7A80E231867B} 15 | Win32Proj 16 | ParsingEngineCore 17 | ReinforcementLearningCore 18 | 19 | 20 | 21 | StaticLibrary 22 | true 23 | v110 24 | Unicode 25 | 26 | 27 | Application 28 | false 29 | v110 30 | true 31 | Unicode 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | true 45 | 46 | 47 | false 48 | 49 | 50 | 51 | 52 | 53 | Level3 54 | Disabled 55 | WIN32;_DEBUG;_CONSOLE;_TRACE_LOG;%(PreprocessorDefinitions) 56 | true 57 | MultiThreadedDebugDLL 58 | 4099;%(DisableSpecificWarnings) 59 | 60 | 61 | Console 62 | true 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /ReinforcementLearningCore/ReinforcementLearningCore.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 源文件 6 | 7 | 8 | 源文件 9 | 10 | 11 | 12 | 13 | 头文件 14 | 15 | 16 | 头文件 17 | 18 | 19 | 20 | 21 | {bbf21654-185c-4a5b-a484-97e9ca6d6531} 22 | h;hpp;hxx;hm;inl;inc;xsd 23 | 24 | 25 | {c3bf8948-7672-4210-af44-e098c080cdab} 26 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 27 | 28 | 29 | -------------------------------------------------------------------------------- /ReinforcementLearningCore/rl_algorithm.cpp: -------------------------------------------------------------------------------- 1 | #include "rl_algorithm.h" 2 | #include "rl_utility.h" 3 | #include 4 | #include 5 | 6 | RLAlgorithm::RLAlgorithm(int states_number, int actions_number) { 7 | Init(states_number, actions_number); 8 | } 9 | 10 | void RLAlgorithm::Init(int states_number, int actions_number) { 11 | #ifdef _TRACE_LOG 12 | std::cout << "Init q table: " << states_number << " * " << actions_number << std::endl; 13 | #endif 14 | 15 | state_number_ = states_number; 16 | action_number_ = actions_number; 17 | 18 | // q table stores state - action values 19 | q_ = new double*[state_number_]; 20 | for (int i = 0; i < state_number_; ++i) 21 | { 22 | q_[i] = new double[actions_number]; 23 | for (int j = 0; j < action_number_; ++j) 24 | { 25 | q_[i][j] = 0.0; 26 | } 27 | } 28 | 29 | // policy_ = new double[action_number_]; 30 | } 31 | 32 | RLAlgorithm::~RLAlgorithm() { 33 | } 34 | 35 | void RLAlgorithm::Explore(const int state, int& action, 36 | const double exploration_rate, const std::vector& action_index) { 37 | egreedy(state, action, exploration_rate, action_index); 38 | } 39 | 40 | //void RLAlgorithm::MaxExplore(const int state, int& action, const std::vector& action_index) { 41 | // GetMaxActionRandom(state, action, action_index); 42 | //} 43 | 44 | void RLAlgorithm::egreedy(const int state, int& action, const double epsilon, const std::vector& action_index) { 45 | if (RL::RLUtility::RandUnit() < epsilon) 46 | { 47 | GetMaxAction(state, action, action_index); 48 | } 49 | else 50 | { 51 | GetRandomAction(state, action, action_index) ; 52 | } 53 | } 54 | void RLAlgorithm::GetMaxAction(const int state, int& action, const std::vector& action_index) { 55 | GetMaxActionRandom(state, action, action_index); 56 | } 57 | 58 | void RLAlgorithm::GetMaxActionRandom(const int state, int& action, const std::vector& action_index) { 59 | double* q_values = q_[state]; 60 | std::vector max_all = RL::RLUtility::ArgMaxAll(q_values, action_index); 61 | action = max_all[RL::RLUtility::Rand0A(max_all.size())]; 62 | } 63 | 64 | void RLAlgorithm::GetMaxActionFirst(const int state, int& action, const std::vector& action_index) { 65 | double* q_values = q_[state]; 66 | action = RL::RLUtility::ArgMax(q_values, action_index); 67 | } 68 | 69 | void RLAlgorithm::GetRandomAction(const int state, int& action, const std::vector& action_index) { 70 | int index = RL::RLUtility::Rand0A(action_index.size()); 71 | action = action_index[index]; 72 | } 73 | 74 | void RLAlgorithm::Update(const int state, const int action, const double reward, 75 | const int next_state, const bool end_of_episode, 76 | const double learning_rate, const double gamma ) { 77 | if (end_of_episode) 78 | { 79 | q_[state][action] += learning_rate * (reward - q_[state][action]); 80 | } 81 | else 82 | { 83 | double max_q_value = RL::RLUtility::Max(q_[next_state], action_number_) ; 84 | q_[state][action] += learning_rate * (reward + gamma * max_q_value - q_[state][action]); 85 | } 86 | } 87 | 88 | void RLAlgorithm::SaveQTable() { 89 | std::ofstream ofs(qtable_path.c_str(), std::ofstream::out) ; 90 | 91 | for ( int i = 0; i < state_number_; ++i) 92 | { 93 | for ( int j = 0; j < action_number_; ++j) 94 | { 95 | ofs << q_[i][j] << " "; 96 | } 97 | ofs << std::endl; 98 | } 99 | 100 | ofs.close(); 101 | } 102 | 103 | void RLAlgorithm::LoadQTable() 104 | { 105 | std::ifstream ifs(qtable_path.c_str(), std::ifstream::in); 106 | 107 | double tmp; 108 | for ( int i = 0; i < state_number_; ++i) 109 | { 110 | for ( int j = 0; j < action_number_; ++j) 111 | { 112 | ifs >> tmp; 113 | q_[i][j] = tmp; 114 | } 115 | } 116 | ifs.close(); 117 | } 118 | 119 | 120 | void RLAlgorithm::PrintQTable() { 121 | 122 | } -------------------------------------------------------------------------------- /ReinforcementLearningCore/rl_algorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef RL_ALGORITHM_H 2 | #define RL_ALGORITHM_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | //! This is the reinforcement learning algorithm 9 | /*! 10 | This class is used to learn a q table. 11 | */ 12 | class RLAlgorithm { 13 | public: 14 | //! Constructor 15 | RLAlgorithm() {} 16 | 17 | //! Constructor 18 | /*! 19 | Initialize the algorithm with the number of states and actions. 20 | */ 21 | RLAlgorithm(int states_number, int actions_number); 22 | 23 | //! Constructor 24 | /*! 25 | Initialize the algorithm with the number of states and actions. 26 | */ 27 | void Init(int states_number, int actions_number); 28 | 29 | ~RLAlgorithm(); 30 | 31 | //! Given a state, explore an action with a exploration rate. 32 | /*! 33 | \param state current state. 34 | \param action explored action. 35 | \param exploration_rate exploration rate. 36 | \param action_index suitable actions for current state. 37 | */ 38 | void Explore(const int state, int& action, const double exploration_rate, const std::vector& action_index); 39 | 40 | //void MaxExplore(const int state, int& action, const std::vector& action_index); 41 | 42 | //! Update the state-action value 43 | /*! 44 | \param state current state. 45 | \param action chosen action. 46 | \param reward reward executing chosen action under current state. 47 | \param next_state next state. 48 | \param end_of_episode whether the episode is end. 49 | \param learning_rate the learning rate. 50 | \param gamma learning parameter. 51 | */ 52 | void Update(const int state, const int action, const double reward, const int next_state, 53 | const bool end_of_episode, const double learning_rate, const double gamma); 54 | 55 | //! Save the q table to a file. 56 | void SaveQTable(); 57 | 58 | //! Load the q table from a file. 59 | void LoadQTable(); 60 | 61 | //! Get the state-action value. 62 | inline double GetQValue(int state, int action) { return q_[state][action]; } 63 | 64 | //! Set the qtable file 65 | inline void set_qtable_path(std::string path) { qtable_path = path; } 66 | 67 | //! Print q table. 68 | static void PrintQTable(); 69 | 70 | protected: 71 | //! Epsilon greedy algorithm used to explore an action under a state with a exploration rate. 72 | /*! 73 | \param state current state. 74 | \param action explored action. 75 | \param epsilon exploration rate. 76 | \param action_index suitable actions for current state. 77 | */ 78 | void egreedy(const int state, int& action, const double epsilon, const std::vector& action_index); 79 | 80 | 81 | void GetMaxAction(const int state, int& action, const std::vector& action_index); 82 | void GetMaxActionFirst(const int state, int& action, const std::vector& action_index); 83 | void GetMaxActionRandom(const int state, int& action, const std::vector& action_index); 84 | void GetRandomAction(const int state, int& action, const std::vector& action_index); 85 | 86 | double** q_; /*!< Q table. */ 87 | std::string qtable_path; /*!< q table path. */ 88 | //double* policy_ ; 89 | //double q_target_; 90 | int state_number_, action_number_; /*< Number of state and action. */ 91 | }; 92 | 93 | 94 | #endif // ! RL_ALGORITHM_H -------------------------------------------------------------------------------- /ReinforcementLearningCore/rl_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "rl_utility.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace RL 9 | { 10 | double RLUtility::Max( double * array, int n ) { 11 | double max = array[0]; 12 | 13 | for (int i = 1; i < n; ++i) 14 | { 15 | if (max < array[i]) 16 | max = array[i]; 17 | } 18 | return max; 19 | } 20 | 21 | double RLUtility::Max(double* array, std::vector index) { 22 | double max = array[index[0]]; 23 | 24 | for (size_t i = 1; i < index.size(); ++i) 25 | { 26 | if (max < array[index[i]]) 27 | { 28 | max = array[index[i]]; 29 | } 30 | } 31 | return max; 32 | } 33 | 34 | int RLUtility::ArgMax(double* array, int n) { 35 | double max = array[0]; 36 | int IMax = 0; 37 | 38 | for (int i = 1; i < n; ++i) 39 | { 40 | if (max < array[i]) 41 | { 42 | max = array[i]; 43 | IMax = i; 44 | } 45 | } 46 | return IMax; 47 | } 48 | 49 | int RLUtility::ArgMax(double* array, std::vector index) { 50 | double max = array[index[0]]; 51 | int IMax = index[0]; 52 | 53 | for (size_t i = 1; i < index.size(); ++i) 54 | { 55 | if (max < array[index[i]]) 56 | { 57 | max = array[index[i]]; 58 | IMax = index[i]; 59 | } 60 | } 61 | return IMax; 62 | } 63 | 64 | std::vector RLUtility::MaxAll(double* array, int n) { 65 | double max = array[0]; 66 | std::vector max_all; 67 | max_all.push_back(max); 68 | 69 | for (int i = 1; i < n; ++i) 70 | { 71 | if (max < array[i]) 72 | { 73 | max = array[i]; 74 | max_all.clear(); 75 | max_all.push_back(array[i]); 76 | } 77 | else if (max == array[i]) 78 | { 79 | max_all.push_back(array[i]); 80 | } 81 | } 82 | 83 | return max_all; 84 | } 85 | 86 | std::vector RLUtility::MaxAll(double* array, std::vector index) { 87 | double max = array[index[0]]; 88 | std::vector max_all; 89 | max_all.push_back(max); 90 | 91 | for (size_t i = 1; i < index.size(); ++i) 92 | { 93 | if (max < array[index[i]]) 94 | { 95 | max = array[index[i]]; 96 | 97 | max_all.clear(); 98 | max_all.push_back(max); 99 | } 100 | else if (max == array[index[i]]) 101 | { 102 | max_all.push_back(max); 103 | } 104 | } 105 | 106 | return max_all; 107 | } 108 | 109 | std::vector RLUtility::ArgMaxAll(double* array, int n) { 110 | double max = array[0]; 111 | 112 | std::vector arg_all; 113 | arg_all.push_back(0); 114 | 115 | for (int i = 1; i < n; ++i) 116 | { 117 | if (max < array[i]) 118 | { 119 | max = array[i]; 120 | arg_all.clear(); 121 | arg_all.push_back(i); 122 | } 123 | else if (max == array[i]) 124 | { 125 | arg_all.push_back(i); 126 | } 127 | } 128 | 129 | return arg_all; 130 | } 131 | 132 | std::vector RLUtility::ArgMaxAll(double* array, std::vector index) { 133 | double max = array[index[0]]; 134 | 135 | std::vector max_all; 136 | max_all.push_back(index[0]); 137 | 138 | for (size_t i = 1; i < index.size(); ++i) 139 | { 140 | if (max < array[index[i]]) 141 | { 142 | max = array[index[i]]; 143 | 144 | max_all.clear(); 145 | max_all.push_back(index[i]); 146 | } 147 | else if (max == array[index[i]]) 148 | { 149 | max_all.push_back(index[i]); 150 | } 151 | } 152 | 153 | return max_all; 154 | } 155 | 156 | int RLUtility::Rand0A(int A) { 157 | return (std::rand() % A); 158 | } 159 | 160 | int RLUtility::RandAB(int A, int B) { 161 | assert(B > A); 162 | int cut = std::rand() % (B - A); 163 | return (A + cut); 164 | } 165 | 166 | double RLUtility::RandUnit() { 167 | return (static_cast(std::rand()) / static_cast(RAND_MAX)); 168 | } 169 | } 170 | 171 | 172 | -------------------------------------------------------------------------------- /ReinforcementLearningCore/rl_utility.h: -------------------------------------------------------------------------------- 1 | #ifndef RL_UTILITY_H 2 | #define RL_UTILITY_H 3 | 4 | #include 5 | 6 | //! Reinforcement Learning Algorithm namespace. 7 | namespace RL 8 | { 9 | //! Utility functions for Reinforcement Learning. 10 | class RLUtility { 11 | public: 12 | RLUtility() {} 13 | ~RLUtility() {} 14 | 15 | //! Get first max element in the array. 16 | /*! 17 | \param array the array. 18 | \param n the array size. 19 | \return the first max element in the array. 20 | \sa ArgMax(), MaxAll(), ArgMaxAll() 21 | */ 22 | static double Max(double* array, int n); 23 | 24 | //! Get first max element in the sub-array of an array. 25 | /*! 26 | \param array the array. 27 | \param index the sub-array's index in the array. 28 | \return the first max element in the sub-array. 29 | */ 30 | static double Max(double* array, std::vector index); 31 | 32 | //! Get first max element's index in the array. 33 | /*! 34 | \param array the array. 35 | \param n the array size. 36 | \return the first max element in the array. 37 | */ 38 | static int ArgMax(double* array, int n); 39 | 40 | //! Get first max element's index in the sub-array of an array. 41 | /*! 42 | \param array the array. 43 | \param index the sub-array's index in the array. 44 | \return the first max element's index in the sub-array. 45 | */ 46 | static int ArgMax(double* array, std::vector index); 47 | 48 | //! Get all the max elements' indexes in the array. 49 | /*! 50 | \param array the array. 51 | \param n array size. 52 | \return all the max elements' indexes in the array. 53 | */ 54 | static std::vector MaxAll(double* array, int n); 55 | 56 | //! Get all the max elements in the sub-array of an array. 57 | /*! 58 | \param array the array. 59 | \param index the sub-array's index in the array. 60 | \return all the max elements in the sub-array of an array. 61 | */ 62 | static std::vector MaxAll(double* array, std::vector index); 63 | 64 | //! Get all the max elements' indexes in the array. 65 | /*! 66 | \param array the array. 67 | \param n array size. 68 | \return all the max elements' indexes in the array. 69 | */ 70 | static std::vector ArgMaxAll(double* array, int n); 71 | 72 | //! Get all the max elements' indexes in the sub-array of an array. 73 | /*! 74 | \param array the array. 75 | \param index the sub-array's index in the array. 76 | \return all the max elements' indexes in the sub-array of an array. 77 | */ 78 | static std::vector ArgMaxAll(double* array, std::vector index); 79 | 80 | //! Generate an int in [0, A) 81 | static int Rand0A(int A); 82 | 83 | //! Generate an int in [A, B) 84 | static int RandAB(int A, int B); 85 | 86 | //! Generate a double in [0, 1] 87 | static double RandUnit(); 88 | }; 89 | } 90 | 91 | #endif -------------------------------------------------------------------------------- /ReviseGridTool/ReviseGridTool.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {EB67A170-6AC7-4502-B536-CDD2A6412A9E} 15 | Win32Proj 16 | ReviseGridTool 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | true 56 | ..\CmdUtility;..\ReinforcementLearningCore;..\3rd\opencv\build\include;..\3rd\eigen;..\3rd\pcl_lib\includes;..\3rd\boost_build\include\boost-1_54;..\ShapeGrammarCore;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | ..\3rd\pcl_lib\lib;..\3rd\VTK_BUILD\lib\Debug;..\3rd\opencv\build\x86\vc11\lib;..\3rd\boost_build\lib;%(AdditionalLibraryDirectories) 62 | boost_chrono-vc110-mt-gd-1_54.lib;boost_filesystem-vc110-mt-gd-1_54.lib;opencv_core246d.lib;opencv_highgui246d.lib;opencv_imgproc246d.lib;opencv_video246d.lib;opencv_videostab246d.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_outofcore_debug.lib;pcl_registration_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_visualization_debug.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {6ba776b1-cf6c-46b0-a735-647d7211b8d4} 89 | 90 | 91 | {8efede7a-bf56-4a5e-af00-71dd489d8b15} 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /ReviseGridTool/ReviseGridTool.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /ReviseGridTool/revise_grid_tool.cpp: -------------------------------------------------------------------------------- 1 | #include "cmd_utility.h" 2 | #include "facade_model.h" 3 | #include "boost/program_options.hpp" 4 | using namespace std; 5 | 6 | CommandLineArgument cmd_arguments; 7 | 8 | std::shared_ptr facade_grammar; 9 | std::shared_ptr facade_model; 10 | 11 | bool ParseCommandLine(int argc, char** argv); 12 | 13 | int main(int argc, char** argv) { 14 | // Step 0 15 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 16 | return -1; 17 | 18 | // Step 1 19 | cout << "\nLoad the shape grammar.\n"; 20 | facade_grammar = std::shared_ptr(new FacadeGrammar); 21 | facade_grammar->ReadGrammar(cmd_arguments.grammar_); 22 | 23 | // Step 2 24 | cout << "\nInitialize the facade model, "; 25 | facade_model = std::shared_ptr(new FacadeModel(facade_grammar)); 26 | 27 | cout << "\nLoad grids.\n"; 28 | facade_model->LoadGrids(cmd_arguments.grid_); 29 | 30 | cout << "\nRevise grids.\n"; 31 | for (int i = 0; i < facade_model->get_width(); ++i) 32 | { 33 | // up 34 | for (int j = 0; j < cmd_arguments.margin_[0]; ++j) 35 | { 36 | facade_model->SetProperty(i, j, 0, 1.0); 37 | facade_model->SetProperty(i, j, 1, 0.0); 38 | } 39 | 40 | // down 41 | int start = facade_model->get_height() - cmd_arguments.margin_[1]; 42 | for (int j = start; j < facade_model->get_height(); ++j) 43 | { 44 | facade_model->SetProperty(i, j, 0, 1.0); 45 | facade_model->SetProperty(i, j, 1, 0.0); 46 | } 47 | } 48 | 49 | for (int i = 0; i < facade_model->get_height(); ++i) 50 | { 51 | // left 52 | for (int j = 0; j < cmd_arguments.margin_[2]; ++j) 53 | { 54 | facade_model->SetProperty(j, i, 0, 1.0); 55 | facade_model->SetProperty(j, i, 1, 0.0); 56 | } 57 | 58 | // right 59 | int start = facade_model->get_width() - cmd_arguments.margin_[3]; 60 | for (int j = start; j < facade_model->get_width(); ++j) 61 | { 62 | facade_model->SetProperty(j, i, 0, 1.0); 63 | facade_model->SetProperty(j, i, 1, 0.0); 64 | } 65 | } 66 | 67 | cout << "\nRender grids.\n"; 68 | facade_model->RenderGrd(cmd_arguments.revise_grid_); 69 | cout << "\nSave grids.\n"; 70 | facade_model->SaveGrids(cmd_arguments.revise_grid_); 71 | 72 | cout << "\nDone.\n"; 73 | return 0; 74 | } -------------------------------------------------------------------------------- /SampleInput/cofigure.json: -------------------------------------------------------------------------------- 1 | { 2 | "episodes": 10000, 3 | "resolution": 0.2, 4 | "resample": [ 5 | 0.1, 6 | 0.1, 7 | 0.1 8 | ], 9 | "radius_outlier_remover": [radius, neighbers], 10 | "static_outlier_remover": [neighbers, stddev], 11 | 12 | "margin": [ 13 | 5, 14 | 5, 15 | 5, 16 | 5 17 | ], 18 | "load_qtable": 0 19 | } -------------------------------------------------------------------------------- /SampleInput/grammar.json: -------------------------------------------------------------------------------- 1 | { 2 | "atom": "facade", 3 | "terminal": [ 4 | { 5 | "name": "wall", 6 | "color": [ 7 | 120, 8 | 120, 9 | 120 10 | ] 11 | }, 12 | { 13 | "name": "window", 14 | "color": [ 15 | 0, 16 | 0, 17 | 255 18 | ] 19 | } 20 | ], 21 | "unterminal": [ 22 | "facadeWall", 23 | "facadeFloor", 24 | "floorWall", 25 | "floorWindow" 26 | ], 27 | "grammar": [ 28 | { 29 | "name": "facade -> wall + facadeFloor", 30 | "direction": 0, 31 | "parent": "facade", 32 | "child1": "wall", 33 | "child2": "facadeFloor", 34 | "parameter": [ 35 | 1, 36 | 50 37 | ], 38 | "exception": "wall" 39 | }, 40 | { 41 | "name": "facade -> floorWall + facadeWall", 42 | "direction": 0, 43 | "parent": "facade", 44 | "child1": "floorWall", 45 | "child2": "facadeWall", 46 | "parameter": [ 47 | 1, 48 | 50 49 | ], 50 | "exception": "wall" 51 | }, 52 | { 53 | "name": "facadeFloor -> floorWall + facadeWall", 54 | "direction": 0, 55 | "parent": "facadeFloor", 56 | "child1": "floorWall", 57 | "child2": "facadeWall", 58 | "parameter": [ 59 | 1, 60 | 50 61 | ], 62 | "exception": "wall" 63 | }, 64 | { 65 | "name": "facadeWall -> wall + facadeFloor", 66 | "direction": 0, 67 | "parent": "facadeWall", 68 | "child1": "wall", 69 | "child2": "facadeFloor", 70 | "parameter": [ 71 | 1, 72 | 50 73 | ], 74 | "exception": "wall" 75 | }, 76 | { 77 | "name": "floorWall -> wall + floorWindow", 78 | "direction": 1, 79 | "parent": "floorWall", 80 | "child1": "wall", 81 | "child2": "floorWindow", 82 | "parameter": [ 83 | 1, 84 | 50 85 | ], 86 | "exception": "wall" 87 | }, 88 | { 89 | "name": "floorWindow -> window + floorWall", 90 | "direction": 1, 91 | "parent": "floorWindow", 92 | "child1": "window", 93 | "child2": "floorWall", 94 | "parameter": [ 95 | 1, 96 | 50 97 | ], 98 | "exception": "wall" 99 | } 100 | ] 101 | } -------------------------------------------------------------------------------- /ShapeGrammarCore/ShapeGrammarCore.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 源文件 32 | 33 | 34 | 35 | 36 | 头文件 37 | 38 | 39 | 头文件 40 | 41 | 42 | 头文件 43 | 44 | 45 | 头文件 46 | 47 | 48 | 头文件 49 | 50 | 51 | 头文件 52 | 53 | 54 | 头文件 55 | 56 | 57 | -------------------------------------------------------------------------------- /ShapeGrammarCore/facade_geography.h: -------------------------------------------------------------------------------- 1 | /*========================================================================================= 2 | * Facade geography define 3 | * CopyRight Xiang Xu, 2013 4 | * xuxiang@mail.bnu.edu.cn 5 | * =========================================================================================*/ 6 | #ifndef FACADE_GEOGRAPHY_H 7 | #define FACADE_GEOGRAPHY_H 8 | 9 | #include "pcl\point_types.h" 10 | #include "pcl\point_cloud.h" 11 | #include "opencv2/opencv.hpp" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | class FacadeGrammar; 19 | //! The geography position of the facade. 20 | /*! 21 | This class contains the spatial extent of the facade. 22 | The facade is rostered to a rectangle grids. 23 | */ 24 | class FacadeGeography 25 | { 26 | public: 27 | //! Constructor 28 | /*! 29 | \param widthX Facade width. 30 | \param widthY Facade Height. 31 | \param facade_grammar Facade grammar. 32 | */ 33 | FacadeGeography(int widthX, int widthY, std::shared_ptr facade_grammar); 34 | 35 | //! Initialize the facade geography 36 | /*! 37 | \param widthX Facade width. 38 | \param widthY Facade Height. 39 | \param facade_grammar Facade grammar. 40 | */ 41 | void init(int widthX, int widthY, std::shared_ptr facade_grammar); 42 | 43 | //! Constructor 44 | /*! 45 | \param facade_grammar Facade grammar. 46 | */ 47 | FacadeGeography(std::shared_ptr facade_grammar); 48 | 49 | //! Initialize the facade geography 50 | /*! 51 | \param res Facade resolution, stands for the meters of one pixel. 52 | \param extMin The left-bottom corner of the facade. 53 | \param extRange The extent of the facade. 54 | */ 55 | void init(double res, const cv::Point2d &extMin, const cv::Point2d &extRange); 56 | 57 | ~FacadeGeography(); 58 | void destroy(); 59 | 60 | /** /brief Create the facade grid with pcl point cloud. 61 | * \param facade_cloud facade point cloud. 62 | */ 63 | void CreateGridFromPointCloud(pcl::PointCloud::Ptr facade_cloud, double resolution); 64 | 65 | //! Render the facade to picture. 66 | void RenderGrd(std::string path); 67 | 68 | //! Serialization 69 | /*! 70 | Save facade geography to file. 71 | */ 72 | void SaveGrids(std::string& filename); 73 | 74 | //! Serialization 75 | /*! 76 | Load facade geography from file. 77 | */ 78 | void LoadGrids(std::string& filename); 79 | 80 | //! Set the value at a specified pixel(grid). 81 | /*! 82 | \param width the width of the pixel. 83 | \param height the height of the pixel 84 | \param depth the depth of the pixel. 85 | \param value the value that we want to set in this pixel. 86 | */ 87 | void SetProperty(int width, int height, int depth, double value); 88 | 89 | //! get the value at a specified pixel(grid). 90 | /*! 91 | \param width the width of the pixel. 92 | \param height the height of the pixel 93 | \param depth the depth of the pixel. 94 | \return the value in this pixel. 95 | */ 96 | double GetProperty(int width, int height, int depth); 97 | 98 | //! get the value at a specified position. 99 | /*! 100 | \param pos the position of the pixel. 101 | \param depth the depth of the pixel. 102 | \return the value in this pixel. 103 | */ 104 | double GetProperty(const cv::Point2d &pos, int depth); 105 | 106 | 107 | void ComputeFeature(pcl::PointCloud::Ptr facade_cloud); 108 | void ComputeFeature2(); 109 | void SaveActionParammeters(std::string parater_path); 110 | void SaveActionParammeters2(std::string parater_path); 111 | void ShowFeature(); 112 | void CalculateActionParameters(double vertical_thread, double horizontal_thread); 113 | void CalculateActionParameters2(double vertical_thread, double horizontal_thread); 114 | void ParseActionParameters(); 115 | void DebugCalculateFeature(std::string filename); 116 | 117 | // Inline functions 118 | inline double get_resolution() const { return resolution_; } 119 | inline int get_width() const { return width_; } 120 | inline int get_height() const { return height_; } 121 | inline int get_depth() const { return depth_; } 122 | inline cv::Point2d get_extents_min() { return extents_min_; } 123 | inline cv::Point2d get_extents_range() { return extents_range_; } 124 | inline cv::Point2d get_convert_ratio() { return convert_ratio_; } 125 | 126 | // dangerous access 127 | inline double** get_grd_ptr ( int index ) { return grd_[index]; } 128 | 129 | // for tests 130 | void SetSymbol(double xmin, double xmax, double ymin, double ymax, int depth); 131 | 132 | protected: 133 | std::vector grd_; /*!< Facade grid. */ 134 | cv::Point2d extents_min_, extents_range_, convert_ratio_; /*!< Facade extent and convert ratio. */ 135 | double resolution_; /*!< Facade resolution. */ 136 | int width_, height_, depth_; /*!< Facade grid extent and depth. */ 137 | 138 | std::vector vertical_feature, horizonal_feature; 139 | std::vector vertical_wall_parameters, horizontal_wall_parameters, vertical_window_parameters, horizontal_window_parameters; 140 | 141 | std::vector > action_parameters_vertical_, action_parameters_horizontal_; 142 | 143 | std::shared_ptr facade_grammar_; /*!< Facade grammar. */ 144 | }; 145 | 146 | #endif // FACADE_GEOGRAPHY_H -------------------------------------------------------------------------------- /ShapeGrammarCore/facade_grammar.cpp: -------------------------------------------------------------------------------- 1 | #include "facade_grammar.h" 2 | #include "rapidjson/reader.h" 3 | #include "rapidjson/filestream.h" 4 | #include "rapidjson/document.h" 5 | #include "opencv2/opencv.hpp" 6 | 7 | FacadeGrammar::FacadeGrammar() { 8 | 9 | } 10 | 11 | FacadeGrammar::~FacadeGrammar() { 12 | 13 | } 14 | 15 | bool FacadeGrammar::ReadGrammar ( std::string& configure_file ) 16 | { 17 | rapidjson::Document document; 18 | FILE* fp = fopen(configure_file.c_str(), "r"); 19 | if(fp == NULL) { 20 | return false; 21 | } 22 | 23 | rapidjson::FileStream is(fp); 24 | if(document.ParseStream<0>(is).HasParseError()) { 25 | return false; 26 | } 27 | 28 | if (!document.IsObject()) { 29 | return false; 30 | } 31 | 32 | // atom symbol 33 | if (document.HasMember("atom")) { 34 | atom_symbol_ = document["atom"].GetString(); 35 | } else { 36 | return false; 37 | } 38 | 39 | // terminal symbols 40 | if (document.HasMember("terminal")) { 41 | const rapidjson::Value& terminals = document["terminal"]; 42 | if (!terminals.IsArray()) 43 | return false; 44 | 45 | for (int i = 0; i < terminals.Size(); ++i) { 46 | const rapidjson::Value& terminal_symbol = terminals[i]; 47 | if (!terminal_symbol.IsObject()) // A terminal symbol can have a color 48 | return false; 49 | if (terminal_symbol.HasMember("name")) { 50 | terminal_symbol_.push_back(terminal_symbol["name"].GetString()); 51 | } else { 52 | return false; 53 | } 54 | if (terminal_symbol.HasMember("color")) { 55 | std::vector color; 56 | if (terminal_symbol["color"].Size() != 3) 57 | return false; 58 | for (int j = 0; j < 3; ++j) { 59 | color.push_back(terminal_symbol["color"][j].GetInt()); 60 | } 61 | symbol_colors_.push_back(color); 62 | 63 | std::pair color_pair; 64 | color_pair.first = terminal_symbol_[i]; 65 | color_pair.second = i; 66 | symbol_color_map_.insert(color_pair); 67 | } 68 | } 69 | } 70 | 71 | // unterminal symbols 72 | if (document.HasMember("unterminal")) { 73 | const rapidjson::Value& unterminals = document["unterminal"]; 74 | if (!unterminals.IsArray()) 75 | return false; 76 | for (int i = 0; i < unterminals.Size(); ++i) { 77 | unterminal_symbol_.push_back(unterminals[i].GetString()); 78 | } 79 | } 80 | 81 | // grammars 82 | if (document.HasMember("grammar")) { 83 | const rapidjson::Value& grammar = document["grammar"]; 84 | if (!grammar.IsArray()) 85 | return false; 86 | for (int i = 0; i < grammar.Size(); ++i) { 87 | const rapidjson::Value& grammar_object = grammar[i]; 88 | if (!grammar_object.IsObject()) 89 | return false; 90 | 91 | ShapeGrammar shape_grammar; 92 | if (grammar_object.HasMember("name")) { 93 | shape_grammar.grammar_name_ = grammar_object["name"].GetString(); 94 | grammar_names_.push_back(grammar_object["name"].GetString()); 95 | } 96 | else { 97 | return false; 98 | } 99 | if (grammar_object.HasMember("direction")) 100 | shape_grammar.apply_direction_ = grammar_object["direction"].GetInt(); 101 | else 102 | return false; 103 | if (grammar_object.HasMember("parent")) 104 | shape_grammar.left_hand_symbol_ = grammar_object["parent"].GetString(); 105 | else 106 | return false; 107 | if (grammar_object.HasMember("child1")) 108 | shape_grammar.right_hand_symbol1_ = grammar_object["child1"].GetString(); 109 | else 110 | return false; 111 | if (grammar_object.HasMember("child2")) 112 | shape_grammar.right_hand_symbol2_ = grammar_object["child2"].GetString(); 113 | else 114 | return false; 115 | if (grammar_object.HasMember("parameter")) { 116 | shape_grammar.parameter_min_ = grammar_object["parameter"][rapidjson::SizeType(0)].GetInt(); 117 | shape_grammar.parameter_max_ = grammar_object["parameter"][rapidjson::SizeType(1)].GetInt(); 118 | } 119 | else { 120 | return false; 121 | } 122 | if (grammar_object.HasMember("exception")) 123 | shape_grammar.exception_symbol_ = grammar_object["exception"].GetString(); 124 | else 125 | return false; 126 | 127 | grammar_set_.push_back(shape_grammar); 128 | } 129 | } 130 | 131 | // symbol_apply_direction_ 132 | for (size_t i = 0; i < grammar_set_.size(); ++i) { 133 | if(atom_symbol_ == grammar_set_[i].left_hand_symbol_) { 134 | std::pair str_dir; 135 | str_dir.first = atom_symbol_; 136 | str_dir.second = grammar_set_[i].apply_direction_; 137 | symbol_apply_direction_.insert(str_dir); 138 | } else { 139 | for (size_t j = 0; j < unterminal_symbol_.size(); ++j) { 140 | if (unterminal_symbol_[j] == grammar_set_[i].left_hand_symbol_) { 141 | std::pair str_dir; 142 | str_dir.first = unterminal_symbol_[j]; 143 | str_dir.second = grammar_set_[i].apply_direction_; 144 | symbol_apply_direction_.insert(str_dir); 145 | } 146 | } 147 | } 148 | } 149 | 150 | return true; 151 | } 152 | 153 | void FacadeGrammar::SaveGrammar ( std::string& configure_file ) 154 | { 155 | cv::FileStorage fs; 156 | fs.open(configure_file, cv::FileStorage::WRITE); 157 | 158 | fs << "Facade_Gramamr"; 159 | fs << "{"; 160 | 161 | fs << "Atom"; 162 | fs << "[" << atom_symbol_ << "]"; 163 | 164 | fs << "Terminal_Symbol"; 165 | fs << "["; 166 | for (size_t i = 0; i < terminal_symbol_.size(); ++i) 167 | { 168 | fs << terminal_symbol_[i]; 169 | } 170 | fs << "]"; 171 | 172 | fs << "Unterminal_Symbol"; 173 | fs << "["; 174 | for (size_t i = 0; i < unterminal_symbol_.size(); ++i) 175 | { 176 | fs << unterminal_symbol_[i]; 177 | } 178 | fs << "]"; 179 | 180 | fs << "Grammars"; 181 | fs << "["; 182 | for (size_t i = 0; i < grammar_set_.size(); ++i) 183 | { 184 | fs << grammar_set_[i].grammar_name_; 185 | } 186 | fs << "]"; 187 | 188 | for (size_t i = 0; i < grammar_set_.size(); ++i) 189 | { 190 | fs << grammar_set_[i].grammar_name_; 191 | fs << "{"; 192 | 193 | fs << "Apply_Direction"; 194 | fs << grammar_set_[i].apply_direction_; 195 | fs << "Left_Hand_Symbol"; 196 | fs << grammar_set_[i].left_hand_symbol_; 197 | fs << "Right_Hand_Symbol1"; 198 | fs << grammar_set_[i].right_hand_symbol1_; 199 | fs << "Right_Hand_Symbol2"; 200 | fs << grammar_set_[i].right_hand_symbol2_; 201 | 202 | fs << "Parameter_Min"; 203 | fs << grammar_set_[i].parameter_min_; 204 | fs << "Parameter_Max"; 205 | fs << grammar_set_[i].parameter_max_; 206 | 207 | fs << "Exception_Symbol"; 208 | fs << grammar_set_[i].exception_symbol_; 209 | 210 | fs << "}"; 211 | } 212 | fs << "}"; 213 | 214 | fs.release(); 215 | } 216 | 217 | void FacadeGrammar::PrintGrammars() 218 | { 219 | std::cout << "Facade_Gramamr\n"; 220 | std::cout << "{\n"; 221 | 222 | std::cout << "Atom\n"; 223 | std::cout << "[" << atom_symbol_ << "]\n\n"; 224 | 225 | std::cout << "Terminal_Symbol\n"; 226 | std::cout << "["; 227 | for (size_t i = 0; i < terminal_symbol_.size(); ++i) 228 | { 229 | std::cout << terminal_symbol_[i] << " "; 230 | } 231 | std::cout << "]\n\n"; 232 | 233 | std::cout << "Unterminal_Symbol\n"; 234 | std::cout << "["; 235 | for (size_t i = 0; i < unterminal_symbol_.size(); ++i) 236 | { 237 | std::cout << unterminal_symbol_[i] << " "; 238 | } 239 | std::cout << "]\n\n"; 240 | 241 | std::cout << "Grammars\n"; 242 | std::cout << "["; 243 | for (size_t i = 0; i < grammar_set_.size(); ++i) 244 | { 245 | std::cout << grammar_set_[i].grammar_name_ << " "; 246 | } 247 | std::cout << "]\n\n"; 248 | 249 | for (size_t i = 0; i < grammar_set_.size(); ++i) 250 | { 251 | std::cout << grammar_set_[i].grammar_name_; 252 | std::cout << "{\n"; 253 | 254 | std::cout << "Apply_Direction\n["; 255 | std::cout << grammar_set_[i].apply_direction_; 256 | std::cout << "]\n\nLeft_Hand_Symbol\n["; 257 | std::cout << grammar_set_[i].left_hand_symbol_ ; 258 | std::cout << "]\n\nRight_Hand_Symbol1\n["; 259 | std::cout << grammar_set_[i].right_hand_symbol1_; 260 | std::cout << "]\n\nRight_Hand_Symbol2\n["; 261 | std::cout << grammar_set_[i].right_hand_symbol2_; 262 | 263 | std::cout << "]\n\nParameter_Min\n["; 264 | std::cout << grammar_set_[i].parameter_min_; 265 | std::cout << "]\n\nParameter_Max\n["; 266 | std::cout << grammar_set_[i].parameter_max_; 267 | 268 | std::cout << "]\n\nException_Symbol\n["; 269 | std::cout << grammar_set_[i].exception_symbol_; 270 | 271 | std::cout << "]\n}\n\n"; 272 | } 273 | std::cout << "}\n"; 274 | } 275 | 276 | std::vector FacadeGrammar::get_symbol_color(std::string symbol) { 277 | int index = symbol_color_map_.at(symbol); 278 | return symbol_colors_[index]; 279 | } -------------------------------------------------------------------------------- /ShapeGrammarCore/facade_grammar.h: -------------------------------------------------------------------------------- 1 | #ifndef FACADE_GRAMMAR_H 2 | #define FACADE_GRAMMAR_H 3 | 4 | #include "rule_define.h" 5 | #include 6 | 7 | //! This class describe the shape grammar of the facade. 8 | /*! 9 | The grammar is stored in a xml file. We should use this class to load the grammar. 10 | */ 11 | class FacadeGrammar 12 | { 13 | public: 14 | FacadeGrammar(); 15 | ~FacadeGrammar(); 16 | 17 | //! Load the facade grammar from the json file. 18 | /*! 19 | \param configure_file The file name of the json file. 20 | */ 21 | bool ReadGrammar(std::string& configure_file ); 22 | 23 | //! Save the facade grammar to the xml file. 24 | /*! 25 | \param configure_file The file name of the xml file. 26 | */ 27 | void SaveGrammar(std::string& configure_file ); 28 | 29 | //! Print the facade grammar to the console. 30 | void PrintGrammars(); 31 | 32 | //! Get the number of terminal shape symbols. 33 | inline int get_terminal_symbol_size() { return terminal_symbol_.size(); } 34 | 35 | //! Get the name of the atom symbol. 36 | inline std::string get_atom_symbol() { return atom_symbol_; } 37 | 38 | //! Get the names of all the terminal symbols. 39 | inline std::vector get_terminal_symbols() { return terminal_symbol_; } 40 | 41 | //! Get the name of a terminal symbol by index. 42 | inline std::string get_terminal_symbol(int index) { return terminal_symbol_[index]; } 43 | 44 | //! Get the names of all the unterminal symbols. 45 | inline std::vector get_unterminal_symbols() { return unterminal_symbol_; } 46 | 47 | //! Get the number of all the unterminal symbols. 48 | inline int get_unterminal_symbol_size() { return unterminal_symbol_.size(); } 49 | 50 | //! Get the name of a unterminal symbol by index. 51 | inline std::string get_unterminal_symbol(int index) { return unterminal_symbol_[index]; } 52 | 53 | //! Get the number of the grammar rules. 54 | inline int get_grammar_number() { return grammar_names_.size(); } 55 | 56 | //! Get a grammar by index. 57 | inline ShapeGrammar get_grammar(int index) { return grammar_set_[index];} 58 | 59 | //! Get a symbol's split direction. 60 | inline int get_symbol_apply_direction(std::string symbol) { return symbol_apply_direction_.at(symbol); } 61 | 62 | //! Get the length of the symbol apply direction map. 63 | inline int get_symbol_direction_map_size() { return symbol_apply_direction_.size(); } 64 | 65 | //! Add a state-actions pair. 66 | inline void push_back_suitable_actions(std::vector action) {suitable_actions_index_.push_back(action); } 67 | 68 | //! Get a symbol's color. 69 | std::vector get_symbol_color(std::string symbol); 70 | 71 | //! Get all the actions that is suitable to apply to a state(symbol). 72 | std::vector get_suitable_action(const int state) { return suitable_actions_index_[state]; } 73 | private: 74 | // facade grammar 75 | std::string atom_symbol_; /*!< name of the atom symbol. */ 76 | std::vector terminal_symbol_; /*!< Name of the terminal symbol. */ 77 | std::vector unterminal_symbol_; /*!< Name of the unterminal symbol.*/ 78 | 79 | std::vector grammar_names_; /*!< Name of all the grammar rules. */ 80 | std::vector grammar_set_; /*!< Grammar rule set. */ 81 | std::map symbol_apply_direction_; /*!< Symbol-actions map. */ 82 | std::vector > symbol_colors_; /*!< The colors of all the terminal symbols. */ 83 | std::map symbol_color_map_; /*!< symbol-color map. */ 84 | std::vector > suitable_actions_index_; /*!< symbol-suitable actions map. */ 85 | }; 86 | 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /ShapeGrammarCore/facade_model.h: -------------------------------------------------------------------------------- 1 | #ifndef FACADE_H 2 | #define FACADE_H 3 | 4 | #include "grammar_elements.h" 5 | #include "facade_geography.h" 6 | #include "facade_grammar.h" 7 | #include "rl_algorithm.h" 8 | 9 | #include "opencv2/opencv.hpp" 10 | #include "pcl\point_types.h" 11 | 12 | #include 13 | #include 14 | 15 | typedef SplitAction Facadestate; 16 | 17 | //! This is the agent in RL 18 | /*! 19 | This class is used to parsing facade. 20 | */ 21 | class FacadeModel : public FacadeGeography, public RLAlgorithm 22 | { 23 | public: 24 | //! Constructor 25 | /*! 26 | \param widthX Facade width. 27 | \param widthY Facade Height. 28 | \param facade_grammar Facade grammar. 29 | */ 30 | FacadeModel(int widthX, int widthY, std::shared_ptr facade_grammar); 31 | 32 | //! Constructor 33 | /*! 34 | \param res Facade resolution, stands for the meters of one pixel(grid). 35 | \param extMin The left-bottom corner of the facade. 36 | \param extRange The extent of the facade. 37 | \param facade_grammar Facade grammar. 38 | */ 39 | FacadeModel (std::shared_ptr facade_grammar); 40 | 41 | //! Initialize the model. 42 | /*! 43 | Called in the constructor. 44 | */ 45 | void InitModel(); 46 | 47 | ~FacadeModel(); 48 | 49 | //! Run the parsing algorithm. 50 | void RunParsingAlgorithm(int episodes); 51 | 52 | //! Calculate the symbol score. 53 | double CalculateScore (std::shared_ptr shape_symbol); 54 | 55 | //! Render the parsing result. 56 | void RenderResult(std::string& filename); 57 | 58 | void ConfigureOneDimensionFacade(std::string path); 59 | void ConfigureComplexOneDimensioFacade(std::string path); 60 | void ConfigureTwoDimensionFacade(std::string path); 61 | 62 | //! Print Q table to console. 63 | void PrintQTable(); 64 | 65 | //! Save easy to read Q table to file. 66 | void SaveEasyReadQTable(); 67 | 68 | void SaveLearningResult(std::string path); 69 | // inline functions 70 | inline std::vector > get_split_result() { return split_result_; } 71 | inline int get_states_number() { return states_number_; } 72 | inline int get_actions_number() { return actions_number_; } 73 | 74 | inline std::vector get_suitable_actions(const int state) { return facade_grammar_->get_suitable_action(state); } 75 | inline std::vector get_symbol_color(std::string symbol) { return facade_grammar_->get_symbol_color(symbol); } 76 | 77 | inline bool current_state_is_terminal() { return current_state_->is_terminal(); } 78 | 79 | inline void set_action_parameter_file(std::string file) { action_parameter_file_ = file; } 80 | protected: 81 | //! Reset the model. 82 | void Reset(); 83 | 84 | //! Run a learning sub-task. 85 | double RunTask(std::shared_ptr& state, int state_index); 86 | 87 | //! Initialize the state-index and index-state map. 88 | int InitStateMap(); 89 | 90 | //! Initialize the action-index and index-action map. 91 | int InitActionMap(); 92 | 93 | int InitActionMapFromFile(); 94 | 95 | //! Initialize the index-suitable actions map. 96 | void InitSymbolSuitableActions(); 97 | 98 | 99 | 100 | //double RunGreedyTask(std::shared_ptr& state, int state_index); 101 | 102 | // no longer used ... 103 | //double Act(const int action ); 104 | //int GetState() ; 105 | //void SetState (const int state); 106 | //bool EndOfEpisode() ; 107 | 108 | private: 109 | int states_number_, actions_number_; /*!< Number of state and action. */ 110 | // int state_ , next_state_, action_; 111 | int episodes_; /*!< Number of episodes. */ 112 | bool learning_, record_; /*!< Whether to learning, record result. */ 113 | double epsilon_, learning_rate_, gamma_; /*!< learing parameters. */ 114 | 115 | std::map action_to_index_; /*!< action-index map. */ 116 | std::map index_to_action_; /*!< index-action map. */ 117 | std::map state_to_index_; /*!< state-index map. */ 118 | std::map index_to_state_; /*!< index-state map. */ 119 | 120 | std::shared_ptr current_state_; /*!< current state. */ 121 | std::vector > split_result_; /*!< parsing result. */ 122 | 123 | std::string action_parameter_file_; 124 | //std::stack > internal_symbols_; 125 | //std::stack > sub_internal_symbols_; 126 | }; 127 | 128 | #endif // FACADE -------------------------------------------------------------------------------- /ShapeGrammarCore/grammar_elements.cpp: -------------------------------------------------------------------------------- 1 | #include "opencv2/opencv.hpp" 2 | #include "grammar_elements.h" 3 | #include "facade_grammar.h" 4 | #include 5 | 6 | ShapeSymbol::ShapeSymbol(std::shared_ptr facade_grammar) { 7 | facade_grammar_ = facade_grammar; 8 | } 9 | 10 | ShapeSymbol::ShapeSymbol ( int x, int y, int w, int h, std::string name, std::shared_ptr facade_grammar) 11 | { 12 | facade_grammar_ = facade_grammar; 13 | 14 | this->is_terminal_ = false; 15 | this->is_atom_ = false; 16 | this->SetScope(x, y, w, h); 17 | this->set_symbol_name(name); 18 | } 19 | 20 | void ShapeSymbol::SetScope ( int x, int y, int w, int h ) 21 | { 22 | position_x_ = x; 23 | position_y_ = y; 24 | width_ = w; 25 | height_ = h; 26 | } 27 | 28 | void ShapeSymbol::set_symbol_name ( std::string value ) 29 | { 30 | symbol_name_ = value; 31 | 32 | this->is_atom_ = false; 33 | this->is_terminal_= false; 34 | 35 | if ( symbol_name_ == facade_grammar_->get_atom_symbol() ) 36 | this->is_atom_ = true; 37 | 38 | for ( int i = 0; i < facade_grammar_->get_terminal_symbol_size(); ++i) 39 | { 40 | if(symbol_name_ == facade_grammar_->get_terminal_symbol(i)) 41 | { 42 | this->is_terminal_ = true; 43 | break; 44 | } 45 | } 46 | } 47 | 48 | 49 | bool ShapeSymbol::DoSplit ( SplitAction& split_action, std::shared_ptr right_symbol_1, 50 | std::shared_ptr right_symbol_2, double width, double height) 51 | { 52 | ShapeGrammar shape_grammar = facade_grammar_->get_grammar(split_action.get_shape_grammar_index()); 53 | 54 | // assert that the shape grammar is suitable 55 | assert(shape_grammar.left_hand_symbol_ == this->symbol_name_); 56 | 57 | double split_parameter = split_action.get_parameter(); 58 | 59 | #if 0 60 | if (split_parameter == 0) 61 | { 62 | right_symbol_1->SetScope(this->position_x_, this->position_y_, this->width_, this->height_); 63 | right_symbol_1->set_symbol_name(shape_grammar.exception_symbol); 64 | 65 | return false; 66 | } 67 | #endif 68 | 69 | if(shape_grammar.apply_direction_ == 0) // vertical action 70 | { 71 | if((split_parameter + position_y_) >= height) // split fail... 72 | { 73 | right_symbol_1->SetScope(this->position_x_, this->position_y_, this->width_, this->height_); 74 | right_symbol_1->set_symbol_name(shape_grammar.exception_symbol_); 75 | 76 | return false; 77 | } 78 | else 79 | { 80 | right_symbol_1->SetScope(this->position_x_, this->position_y_, this->width_, split_parameter); 81 | right_symbol_1->set_symbol_name(shape_grammar.right_hand_symbol1_); 82 | 83 | right_symbol_2->SetScope(this->position_x_, this->position_y_ + split_parameter, 84 | this->width_, this->height_ - split_parameter); 85 | right_symbol_2->set_symbol_name(shape_grammar.right_hand_symbol2_); 86 | 87 | return true; 88 | } 89 | } 90 | else // horizontal action 91 | { 92 | if((split_parameter + position_x_) >= width) // split fail ... 93 | { 94 | right_symbol_1->SetScope(this->position_x_, this->position_y_, this->width_, this->height_); 95 | right_symbol_1->set_symbol_name(shape_grammar.exception_symbol_); 96 | 97 | return false; 98 | } 99 | else 100 | { 101 | right_symbol_1->SetScope(this->position_x_, this->position_y_, split_parameter, this->height_); 102 | right_symbol_1->set_symbol_name(shape_grammar.right_hand_symbol1_); 103 | 104 | right_symbol_2->SetScope(this->position_x_ + split_parameter, this->position_y_, 105 | this->width_ - split_parameter, this->height_); 106 | right_symbol_2->set_symbol_name(shape_grammar.right_hand_symbol2_); 107 | 108 | return true; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /ShapeGrammarCore/grammar_elements.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAMMAR_ELEMENTS_H 2 | #define GRAMMAR_ELEMENTS_H 3 | /* 4 | * Binary Grammar Symbol Representation 5 | * 6 | * Xiang Xu, August 18th, 2013 7 | * 8 | * Email: xiangxu@mail.bnu.edu.cn 9 | */ 10 | 11 | #include "rule_define.h" 12 | #include 13 | 14 | //! Split action 15 | /*! This class is used by RL Learning. It is the brief describe of ShapeGrammar structure.*/ 16 | class SplitAction { 17 | public: 18 | SplitAction() {} 19 | //! Constructor 20 | /*! 21 | \param name Action name. 22 | \param parameter Split length. 23 | \param grammar_index The grammar rule that this Action belongs to. 24 | */ 25 | SplitAction(std::string name, double parameter, int grammar_index = -1) { 26 | grammar_name_ = name, parameter_ = parameter; grammar_index_ = grammar_index; } 27 | 28 | //! Copy constructor 29 | SplitAction(const SplitAction& sa) { 30 | this->grammar_name_ = sa.grammar_name_; 31 | this->parameter_ = sa.parameter_; 32 | this->grammar_index_ = sa.grammar_index_; 33 | } 34 | 35 | //! Set the grammar rule index that this action belongs to. 36 | inline void set_shape_grammar(int grammar_index) { grammar_index_ = grammar_index;} 37 | //! Get the grammar rule index that this action belongs to. 38 | inline int get_shape_grammar_index() { return grammar_index_; } 39 | //! Get the rule name of this action. 40 | inline std::string get_grammar_name() { return grammar_name_; } 41 | //! Get the rule parameter of this action. 42 | inline double get_parameter() { return parameter_; } 43 | 44 | SplitAction& operator=(const SplitAction& action) 45 | { 46 | this->grammar_name_ = action.grammar_name_; 47 | this->parameter_ = action.parameter_; 48 | this->grammar_index_ = action.grammar_index_; 49 | 50 | return *this; 51 | } 52 | 53 | bool operator==(const SplitAction& sa) const { 54 | return (grammar_name_ == sa.grammar_name_ && parameter_ == sa.parameter_); 55 | } 56 | bool operator!=(const SplitAction& sa) const { 57 | return (grammar_name_ != sa.grammar_name_ || parameter_ != sa.parameter_); 58 | } 59 | 60 | bool operator>(const SplitAction& sa) const { 61 | if(parameter_ == sa.parameter_) 62 | return (grammar_name_ > sa.grammar_name_); 63 | else 64 | return (parameter_ > sa.parameter_); 65 | } 66 | 67 | bool operator<(const SplitAction& sa) const { 68 | if(parameter_ == sa.parameter_) 69 | return (grammar_name_ < sa.grammar_name_); 70 | else 71 | return (parameter_ < sa.parameter_); 72 | } 73 | 74 | private: 75 | std::string grammar_name_; /*!< grammar rule name of this action. */ 76 | double parameter_; /*!< grammar rule parameter of this action. */ 77 | int grammar_index_; /*!< grammar rule index of this action. */ 78 | }; 79 | 80 | 81 | class FacadeGrammar; 82 | 83 | //! Shape symbol definition of the Shape Grammar. 84 | /*! A shape symbol has its rectangle envelope and its type. */ 85 | class ShapeSymbol { 86 | public: 87 | //! Constructors 88 | /*! 89 | \param facade_grammar The facade grammar that this shape symbol is in. 90 | */ 91 | ShapeSymbol(std::shared_ptr facade_grammar); 92 | //! Constructors 93 | /*! 94 | \param x x position of the left bottom corner of this shape symbol. 95 | \param y y position of the left bottom corner of this shape symbol. 96 | \param w width of this shape symbol. 97 | \param h height of this shape symbol. 98 | \param name the name of this shape symbol. 99 | \param facade_grammar the facade grammar that this shape symbol is in. 100 | */ 101 | ShapeSymbol (int x, int y, int w, int h, std::string name, std::shared_ptr facade_grammar); 102 | ~ShapeSymbol() {} 103 | 104 | //! Set the envelop 105 | /*! 106 | \param x x position of the left bottom corner of this shape symbol. 107 | \param y y position of the left bottom corner of this shape symbol. 108 | \param w width of this shape symbol. 109 | \param h height of this shape symbol. 110 | \return void. 111 | */ 112 | void SetScope(int x, int y, int w, int h); 113 | 114 | //! Split this shape symbol to two sub symbols with a given split action. 115 | /*! 116 | \param split_action The action that used to split this symbol. 117 | \param right_symbol_1 The first sub symbol. 118 | \param right_symbol_2 The second sub symbol. 119 | \param width the facade width. 120 | \param height the facade height. 121 | \return true if the split success, otherwise false. If is false, the right_symbol_1 is the exception symbol. 122 | */ 123 | bool DoSplit ( SplitAction& split_action, std::shared_ptr right_symbol_1, 124 | std::shared_ptr right_symbol_2, double width, double height); 125 | 126 | inline int position_x() { return position_x_; } 127 | inline int position_y() { return position_y_; } 128 | inline int width() { return width_; } 129 | inline int height() { return height_; } 130 | inline std::string symbol_name() { return symbol_name_; } 131 | void set_symbol_name ( std::string value ); 132 | inline void set_position_x ( int value ) { this->position_x_ = value; } 133 | inline void set_position_y ( int value ) { this->position_y_ = value; } 134 | inline void set_width( int value ) { this->width_ = value; } 135 | inline void set_height ( int value ) { this->height_ = value; } 136 | inline bool is_terminal() { return this->is_terminal_; } 137 | inline bool is_atom() { return this->is_atom_; } 138 | inline void set_is_terminal(bool value) { this->is_terminal_ = value; } 139 | inline void set_is_atom(bool value) { this->is_atom_ = value; } 140 | 141 | private: 142 | int position_x_, position_y_, width_, height_; /*!< Envelop of this shape symbol. */ 143 | std::string symbol_name_; /*< symbol name. */ 144 | bool is_terminal_, is_atom_; /*< If this symbol is terminal symbol, is atom symbol. */ 145 | 146 | std::shared_ptr facade_grammar_; /*< The facade grammar that this symbol is in. */ 147 | }; 148 | 149 | 150 | #endif // GRAMMAR_ELEMENTS_H -------------------------------------------------------------------------------- /ShapeGrammarCore/main_page.h: -------------------------------------------------------------------------------- 1 | /*! \mainpage Welcome Page. 2 | * 3 | * \section intro_sec Introduction 4 | * 5 | * This Project is for automatic parsing building facades from LEDIA point clouds. 6 | * 7 | * \author Xiang Xu 8 | * \date Oct. 6th, 2013. 9 | * \copyright All Rights Reserved. 10 | */ -------------------------------------------------------------------------------- /ShapeGrammarCore/rule_define.h: -------------------------------------------------------------------------------- 1 | #ifndef RULE_DEFINE_H 2 | #define RULE_DEFINE_H 3 | 4 | #include 5 | #include 6 | 7 | //! Shape grammar rule define. 8 | /*! 9 | * It contains all the elements that a grammar rule has. 10 | * A rule is of this format: 11 | * [left_hand_symbol parameter, apply_direction] --> [right_hand_symbol1_ + right_hand_symbol2_] or [exception_symbol]. 12 | */ 13 | struct ShapeGrammar { 14 | std::string grammar_name_; /*!< Rule name. */ 15 | int apply_direction_; /*!< 0 -- vertical rule; 1 -- horizonal rule. */ 16 | std::string left_hand_symbol_; /*!< Left hand symbol. */ 17 | std::string right_hand_symbol1_; /*!< First right hand symbol. */ 18 | std::string right_hand_symbol2_; /*!< Second right hand symbol. */ 19 | std::string exception_symbol_; /*!< Exception symbol. */ 20 | double parameter_min_, parameter_max_; /*!< Parameter range. */ 21 | }; 22 | 23 | 24 | #endif -------------------------------------------------------------------------------- /ShapeGrammarCore/scale_model.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "scale_model.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | double ScaleModel::AB2MN(double target, double A, double B, double M, double N) 9 | { 10 | /** 11 | * We have the equation: (B - A)/(N - M) = (target - A)/(value - M) 12 | */ 13 | double factor = (N - M) / (B - A); 14 | double value = factor * (target - A) + M; 15 | 16 | return value; 17 | } 18 | 19 | double ScaleModel::Normalize(double target, double targetMin, double targetMax) 20 | { 21 | return AB2MN(target, targetMin, targetMax, 0.0, 1.0); 22 | } 23 | 24 | double ScaleModel::LinearTrans(double target, double A, double B) 25 | { 26 | double functionValue = target; 27 | 28 | return AB2MN(functionValue, 0.0, 1.0, A, B); 29 | } 30 | 31 | double ScaleModel::FractTrans(double target, double A, double B) 32 | { 33 | double functionValue = 1.0 / (target + 1.0); 34 | 35 | return AB2MN(functionValue, 0.5, 1.0, A, B); 36 | } 37 | 38 | double ScaleModel::SquareTrans(double target, double A, double B) 39 | { 40 | assert(target >= 0 && target <= 1); 41 | 42 | double functionValue = pow(target, 2); 43 | 44 | double result = AB2MN(functionValue, 0.0, 1.0, A, B); 45 | 46 | assert(result >= A && result <= B); 47 | 48 | return result; 49 | } 50 | 51 | double ScaleModel::LogTrans(double target, double A, double B) 52 | { 53 | double functionValue = log(target + 1.0); 54 | 55 | return AB2MN(functionValue, 0.0, log(2.0), A, B); 56 | } 57 | 58 | double ScaleModel::FractSquareTrans(double target, double A, double B) 59 | { 60 | double functionValue = 1.0 / (pow(target, 2) + 1.0); 61 | 62 | return AB2MN(functionValue, 0.5, 1.0, A, B); 63 | } 64 | 65 | double ScaleModel::FractLogTrans(double target, double A, double B) 66 | { 67 | double functionValue = 1.0 / (log(target + 1) + 1.0); 68 | 69 | return AB2MN(functionValue, 0.5, 1.0 / (log(2.0) + 1), A, B); 70 | } 71 | 72 | double ScaleModel::ExpTrans(double target, double A, double B) 73 | { 74 | double functionValue = exp(target); 75 | 76 | double result = AB2MN(functionValue, 1.0, exp(1.0), A, B); 77 | 78 | // assert(result >= A && result <= B); 79 | 80 | return result; 81 | } -------------------------------------------------------------------------------- /ShapeGrammarCore/scale_model.h: -------------------------------------------------------------------------------- 1 | #ifndef MY_SCALE_MODEL_H 2 | #define MY_SCALE_MODEL_H 3 | 4 | /* 5 | * class: CScaleModel 6 | * 7 | * Function: To apply a function to a target value and map the result to a given domain. 8 | * 9 | * XiangXu. August 18th, 2013. 10 | * 11 | * Email: xiangxu@mail.bnu.edu.cn 12 | */ 13 | 14 | //! This class is used to map a target value to an given domain with a given function. 15 | class ScaleModel 16 | { 17 | public: 18 | ScaleModel(){} 19 | ~ScaleModel(){} 20 | 21 | //! Transfer target form domain [A, B] to [M, N] 22 | /*! 23 | \param target the target value we want to convert. 24 | \param A source domain lower boundary. 25 | \param B source domain upper boundary. 26 | \param M destination domain lower boundary. 27 | \param N destination domain upper boundary. 28 | \return the value mapped from [A, B] to [M, N] at target. 29 | */ 30 | static double AB2MN(double target, double A, double B, double M, double N); 31 | 32 | //! Normalize target in [targetMin, targetMax] to [0, 1] 33 | static double Normalize(double target, double targetMin, double targetMax); 34 | 35 | //! Apply a function to a target value and map the result to a given domain. 36 | /*! Target should be between [0, 1] 37 | * First y = x function is applied to it, 38 | * Then the result is scaled into [A, B] 39 | */ 40 | static double LinearTrans(double target, double A, double B); 41 | 42 | //! Apply a function to a target value and map the result to a given domain. 43 | /*! Target should be between [0, 1] 44 | * First y = 1.0 / (x + 1.0) function is applied to it, 45 | * Then the result is scaled into [A, B] 46 | */ 47 | static double FractTrans(double target, double A, double B); 48 | 49 | //! Apply a function to a target value and map the result to a given domain. 50 | /*! Target should be between [0, 1] 51 | * First y = pow(x, 2) function is applied to it, 52 | * Then the result is scaled into [A, B] 53 | */ 54 | static double SquareTrans(double target, double A, double B); 55 | 56 | //! Apply a function to a target value and map the result to a given domain. 57 | /*! Target should be between [0, 1] 58 | * First y = log(x + 1.0) function is applied to it, 59 | * Then the result is scaled into [A, B] 60 | */ 61 | static double LogTrans(double target, double A, double B); 62 | 63 | //! Apply a function to a target value and map the result to a given domain. 64 | /*! Target should be between [0, 1] 65 | * First y = 1.0 / (pow(x, 2) + 1.0) function is applied to it, 66 | * Then the result is scaled into [A, B] 67 | */ 68 | static double FractSquareTrans(double target, double A, double B); 69 | 70 | //! Apply a function to a target value and map the result to a given domain. 71 | /*! Target should be between [0, 1] 72 | * First y = 1.0 / (log(x + 1) + 1.0) function is applied to it, 73 | * Then the result is scaled into [A, B] 74 | */ 75 | static double FractLogTrans(double target, double A, double B); 76 | 77 | //! Apply a function to a target value and map the result to a given domain. 78 | /*! Target should be between [0, 1] 79 | * y = exp(x) function is applied to it, 80 | * Then the result is scaled into [A, B] 81 | */ 82 | static double ExpTrans(double target, double A, double B); 83 | 84 | }; 85 | 86 | 87 | 88 | #endif -------------------------------------------------------------------------------- /TestShapeGrammar/TestShapeGrammarCore.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {46E40ADC-66F0-4070-BAC8-BEA9A197507B} 15 | Win32Proj 16 | TestShapeGrammarCore 17 | TestShapeGrammar 18 | 19 | 20 | 21 | Application 22 | true 23 | v110 24 | Unicode 25 | 26 | 27 | Application 28 | false 29 | v110 30 | true 31 | Unicode 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | true 45 | 46 | 47 | false 48 | 49 | 50 | 51 | 52 | 53 | Level3 54 | Disabled 55 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 56 | true 57 | ..\3rd\boost_build\include\boost-1_54;..\3rd\pcl_lib\includes;..\3rd\eigen;..\3rd\opencv\build\include;..\ReinforcementLearningCore;..\ShapeGrammarCore;%(AdditionalIncludeDirectories) 58 | 59 | 60 | Console 61 | true 62 | ..\3rd\VTK_BUILD\lib\Debug;..\3rd\pcl_lib\lib;..\3rd\opencv\build\x86\vc11\lib;%(AdditionalLibraryDirectories) 63 | opencv_core246d.lib;opencv_highgui246d.lib;opencv_imgproc246d.lib;opencv_video246d.lib;opencv_videostab246d.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_outofcore_debug.lib;pcl_registration_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_visualization_debug.lib;%(AdditionalDependencies) 64 | 65 | 66 | 67 | 68 | Level3 69 | 70 | 71 | MaxSpeed 72 | true 73 | true 74 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 75 | true 76 | 77 | 78 | Console 79 | true 80 | true 81 | true 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | {8efede7a-bf56-4a5e-af00-71dd489d8b15} 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /TestShapeGrammar/TestShapeGrammarCore.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /TestShapeGrammar/test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "facade_grammar.h" 3 | #include "facade_model.h" 4 | #include "opencv2/opencv.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | 12 | #define SHOW_RESULT 0 13 | 14 | // 0 - simple one dimension; 1 - complex one dimension; 2 - simple two dimension; 3 - complex two dimension 15 | const int TEST_CASE = 2; 16 | int episodes = 50000; 17 | 18 | int main() { 19 | srand(static_cast(time(0))); 20 | 21 | std::string grammar_file; 22 | shared_ptr facade_grammar(new FacadeGrammar); 23 | 24 | switch (TEST_CASE) 25 | { 26 | case 0: 27 | { 28 | grammar_file = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\simple one dimension.xml"; 29 | facade_grammar->ReadGrammar(grammar_file); 30 | 31 | shared_ptr facade_model(new FacadeModel(10, 5, facade_grammar)); 32 | 33 | std::cout << "Configure facade geography ...\n"; 34 | std::string path = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\simple_one_dimension.png"; 35 | facade_model->ConfigureOneDimensionFacade(path); 36 | 37 | std::cout << "Running algorithm ... \n"; 38 | facade_model->RunParsingAlgorithm(episodes); 39 | 40 | std::cout << "Rendering result ...\n"; 41 | std::string result = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\simple_one_dimension_result.png"; 42 | facade_model->RenderResult(result); 43 | 44 | break; 45 | } 46 | case 1: 47 | { 48 | grammar_file = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\complex one dimension.xml"; 49 | facade_grammar->ReadGrammar(grammar_file); 50 | 51 | shared_ptr facade_model(new FacadeModel(210, 100, facade_grammar)); 52 | 53 | std::cout << "Configure facade geography ...\n"; 54 | std::string path = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\complex_one_dimension.png"; 55 | facade_model->ConfigureComplexOneDimensioFacade(path); 56 | 57 | std::cout << "Running algorithm ... \n"; 58 | facade_model->RunParsingAlgorithm(episodes); 59 | 60 | std::cout << "Rendering result ...\n"; 61 | std::string result = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\complex_one_dimension_result.png"; 62 | facade_model->RenderResult(result); 63 | 64 | break; 65 | } 66 | case 2: 67 | { 68 | grammar_file = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\simple two dimension.xml"; 69 | facade_grammar->ReadGrammar(grammar_file); 70 | 71 | shared_ptr facade_model(new FacadeModel(25, 25, facade_grammar)); 72 | 73 | std::cout << "Configure facade geography ...\n"; 74 | std::string path = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\simple_two_dimension.png"; 75 | facade_model->ConfigureTwoDimensionFacade(path); 76 | //std::string grid_path = "grid"; 77 | //facade_model->SaveGrids(grid_path); 78 | 79 | std::cout << "Running algorithm ... \n"; 80 | facade_model->RunParsingAlgorithm(episodes); 81 | 82 | std::cout << "Rendering result ...\n"; 83 | std::string result = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\simple_two_dimension_result.png"; 84 | facade_model->RenderResult(result); 85 | 86 | break; 87 | } 88 | case 3: 89 | { 90 | 91 | 92 | grammar_file = "D:\\vs2012projects\\ParsingEngineCore\\Tests\\data\\complex two dimension.xml"; 93 | facade_grammar->ReadGrammar(grammar_file); 94 | 95 | // .......................... 96 | // ............................ 97 | break; 98 | } 99 | default: 100 | break; 101 | } 102 | 103 | #if 0 // validate the CalculateScore function 104 | 105 | std::string grid_path = "grid"; 106 | facade_model->SaveGrids(grid_path); 107 | 108 | std::shared_ptr wall1(new ShapeSymbol(0, 0, 4, 5, "Wall", facade_grammar)); 109 | assert(facade_model->CalculateScore(wall1) == 20); 110 | 111 | std::shared_ptr wall2(new ShapeSymbol(7, 0, 3, 5, "Wall", facade_grammar)); 112 | assert(facade_model->CalculateScore(wall2) == 15); 113 | 114 | std::shared_ptr window(new ShapeSymbol(4, 0, 3, 5, "Window", facade_grammar)); 115 | assert(facade_model->CalculateScore(window) == 15); 116 | 117 | std::shared_ptr wall_window(new ShapeSymbol(4, 0, 6, 5, "Window", facade_grammar)); 118 | assert(facade_model->CalculateScore(wall_window) == 15); 119 | #endif 120 | 121 | 122 | 123 | std::cout << "Done.\n"; 124 | 125 | #if SHOW_RESULT 126 | std::cout << "Showing result ...\n"; 127 | cv::namedWindow("Learning result"); 128 | cv::namedWindow("Original facade"); 129 | cv::Mat image = cv::imread(result);//, CV_LOAD_IMAGE_COLOR); 130 | cv::Mat original_image = cv::imread(path);//, CV_LOAD_IMAGE_GRAYSCALE); 131 | cv::imshow("Original facade", original_image); 132 | cv::imshow("Learning result", image); 133 | 134 | cv::waitKey(); 135 | #endif 136 | 137 | return 0; 138 | } -------------------------------------------------------------------------------- /Tests/Tests.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {4A8F87EC-238F-446E-B0DF-849D8A2AADAE} 15 | Win32Proj 16 | Tests 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | $(IncludePath) 45 | 46 | 47 | false 48 | 49 | 50 | 51 | 52 | 53 | Level3 54 | Disabled 55 | WIN32;_DEBUG;_CONSOLE;_VARIADIC_MAX=10;%(PreprocessorDefinitions) 56 | true 57 | D:\vs2012projects\ParsingEngineCore\RL;D:\vs2012projects\ParsingEngineCore\3rd\gtests-1.6.0\include;D:\vs2012projects\ParsingEngineCore\SG;%(AdditionalIncludeDirectories) 58 | MultiThreadedDebugDLL 59 | 4099;%(DisableSpecificWarnings) 60 | 61 | 62 | Console 63 | true 64 | D:\vs2012projects\ParsingEngineCore\3rd\gtests-1.6.0\static;%(AdditionalLibraryDirectories) 65 | gtest.lib;%(AdditionalDependencies) 66 | 67 | 68 | 69 | 70 | Level3 71 | 72 | 73 | MaxSpeed 74 | true 75 | true 76 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 77 | true 78 | 79 | 80 | Console 81 | true 82 | true 83 | true 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | {5ca03a65-4f4e-4a9a-b9c2-7a80e231867b} 96 | 97 | 98 | {bb29930f-276e-42f8-81f5-8a0f3b1e4d2c} 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /Tests/Tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 26 | 27 | 源文件 28 | 29 | 30 | -------------------------------------------------------------------------------- /Tests/run_tests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test_suits.h" 3 | 4 | using namespace std; 5 | 6 | using ::testing::EmptyTestEventListener; 7 | using ::testing::InitGoogleTest; 8 | using ::testing::Test; 9 | using ::testing::TestCase; 10 | using ::testing::TestInfo; 11 | using ::testing::TestPartResult; 12 | using ::testing::UnitTest; 13 | 14 | 15 | int main(int argc, char** argv) 16 | { 17 | InitGoogleTest(&argc, argv); 18 | 19 | RUN_ALL_TESTS(); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Tests/shape_grammar_test.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SHAPE_GRAMMAR_TEST_H 3 | #define SHAPE_GRAMMAR_TEST_H 4 | 5 | #include "gtest/gtest.h" 6 | #include "facade_grammar.h" 7 | 8 | TEST(Test_SG, Read_Grammar) { 9 | std::string grammar_path = "data\\shape_grammar.xml"; 10 | 11 | FacadeGrammar facade_grammar; 12 | facade_grammar.ReadGrammar(grammar_path); 13 | 14 | EXPECT_TRUE(facade_grammar.get_atom_symbol() == "Facade"); 15 | EXPECT_TRUE(facade_grammar.get_terminal_symbol_size() == 2); 16 | EXPECT_TRUE(facade_grammar.get_terminal_symbol(0) == "Wall"); 17 | EXPECT_TRUE(facade_grammar.get_terminal_symbol(1) == "Window"); 18 | EXPECT_TRUE(facade_grammar.get_symbol_color("Wall")[0] == 120); 19 | EXPECT_TRUE(facade_grammar.get_symbol_color("Wall")[1] == 120); 20 | EXPECT_TRUE(facade_grammar.get_symbol_color("Wall")[2] == 120); 21 | EXPECT_TRUE(facade_grammar.get_symbol_color("Window")[0] == 0); 22 | EXPECT_TRUE(facade_grammar.get_symbol_color("Window")[1] == 0); 23 | EXPECT_TRUE(facade_grammar.get_symbol_color("Window")[2] == 255); 24 | 25 | EXPECT_TRUE(facade_grammar.get_grammar_number() == 6); 26 | ShapeGrammar sg = facade_grammar.get_grammar(0); 27 | EXPECT_TRUE(sg.grammar_name_ == "Facade2WallAndFacadeFloor"); 28 | EXPECT_TRUE(sg.apply_direction_ == 0); 29 | EXPECT_TRUE(sg.left_hand_symbol_ == "Facade"); 30 | EXPECT_TRUE(sg.right_hand_symbol1_ == "Wall"); 31 | EXPECT_TRUE(sg.right_hand_symbol2_ == "FacadeFloor"); 32 | EXPECT_TRUE(sg.parameter_min == 1); 33 | EXPECT_TRUE(sg.parameter_max == 15); 34 | EXPECT_TRUE(sg.exception_symbol == "Wall"); 35 | 36 | sg = facade_grammar.get_grammar(5); 37 | EXPECT_TRUE(sg.grammar_name_ == "FloorWindow2WindowAndFloorWall"); 38 | EXPECT_TRUE(sg.apply_direction_ == 1); 39 | EXPECT_TRUE(sg.left_hand_symbol_ == "FloorWindow"); 40 | EXPECT_TRUE(sg.right_hand_symbol1_ == "Window"); 41 | EXPECT_TRUE(sg.right_hand_symbol2_ == "FloorWall"); 42 | EXPECT_TRUE(sg.parameter_min == 1); 43 | EXPECT_TRUE(sg.parameter_max == 15); 44 | EXPECT_TRUE(sg.exception_symbol == "Wall"); 45 | 46 | EXPECT_TRUE(facade_grammar.get_symbol_direction_map_size() == 5); 47 | EXPECT_TRUE(facade_grammar.get_symbol_apply_direction("Facade") == 0); 48 | EXPECT_TRUE(facade_grammar.get_symbol_apply_direction("FacadeFloor") == 0); 49 | EXPECT_TRUE(facade_grammar.get_symbol_apply_direction("FacadeWall") == 0); 50 | EXPECT_TRUE(facade_grammar.get_symbol_apply_direction("FloorWall") == 1); 51 | EXPECT_TRUE(facade_grammar.get_symbol_apply_direction("FloorWindow") == 1); 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /Tests/test_suits.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_SUITS_H 2 | #define TEST_SUITS_H 3 | #include "rl_utility_test.h" 4 | //#include "shape_grammar_test.h" 5 | 6 | #endif //!TEST_SUITS_H -------------------------------------------------------------------------------- /TransformPointCloudTool/TransformPointCloudTool.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {E6ED19CE-C8C5-47B4-A85F-97201ECE910D} 15 | Win32Proj 16 | TransformPointCloudTool 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 55 | true 56 | ..\CmdUtility;..\3rd\flann_build;..\3rd\VTK6.0.0\INCLUDE;..\3rd\VTK_BUILD\INCLUDE;..\3rd\boost_build\include\boost-1_54;..\3rd\eigen;..\3rd\pcl_lib\includes;%(AdditionalIncludeDirectories) 57 | 58 | 59 | Console 60 | true 61 | ..\3rd\VTK_BUILD\lib\Debug;..\3rd\boost_build\lib;..\3rd\pcl_lib\lib;%(AdditionalLibraryDirectories) 62 | boost_thread-vc110-mt-gd-1_54.lib;boost_system-vc110-mt-gd-1_54.lib;boost_chrono-vc110-mt-gd-1_54.lib;boost_filesystem-vc110-mt-gd-1_54.lib;boost_date_time-vc110-mt-gd-1_54.lib;pcl_common_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;pcl_kdtree_debug.lib;pcl_keypoints_debug.lib;pcl_ml_debug.lib;pcl_octree_debug.lib;pcl_outofcore_debug.lib;pcl_registration_debug.lib;pcl_sample_consensus_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_visualization_debug.lib;QVTKWidgetPlugin.lib;vtkalglib-6.0.lib;vtkChartsCore-6.0.lib;vtkCommonColor-6.0.lib;vtkCommonComputationalGeometry-6.0.lib;vtkCommonCore-6.0.lib;vtkCommonCoreCxxTests.lib;vtkCommonDataModel-6.0.lib;vtkCommonExecutionModel-6.0.lib;vtkCommonMath-6.0.lib;vtkCommonMisc-6.0.lib;vtkCommonSystem-6.0.lib;vtkCommonTransforms-6.0.lib;vtkDICOMParser-6.0.lib;vtkDomainsChemistry-6.0.lib;vtkexoIIc-6.0.lib;vtkexpat-6.0.lib;vtkFiltersAMR-6.0.lib;vtkFiltersCore-6.0.lib;vtkFiltersExtraction-6.0.lib;vtkFiltersFlowPaths-6.0.lib;vtkFiltersGeneral-6.0.lib;vtkFiltersGeneric-6.0.lib;vtkFiltersGeometry-6.0.lib;vtkFiltersHybrid-6.0.lib;vtkFiltersHyperTree-6.0.lib;vtkFiltersImaging-6.0.lib;vtkFiltersModeling-6.0.lib;vtkFiltersParallel-6.0.lib;vtkFiltersParallelImaging-6.0.lib;vtkFiltersProgrammable-6.0.lib;vtkFiltersSelection-6.0.lib;vtkFiltersSources-6.0.lib;vtkFiltersStatistics-6.0.lib;vtkFiltersTexture-6.0.lib;vtkFiltersVerdict-6.0.lib;vtkfreetype-6.0.lib;vtkftgl-6.0.lib;vtkGeovisCore-6.0.lib;vtkgl2ps-6.0.lib;vtkGUISupportQt-6.0.lib;vtkGUISupportQtOpenGL-6.0.lib;vtkGUISupportQtSQL-6.0.lib;vtkGUISupportQtWebkit-6.0.lib;vtkhdf5_hl-6.0.lib;vtkhdf5-6.0.lib;vtkImagingColor-6.0.lib;vtkImagingCore-6.0.lib;vtkImagingFourier-6.0.lib;vtkImagingGeneral-6.0.lib;vtkImagingHybrid-6.0.lib;vtkImagingMath-6.0.lib;vtkImagingMorphological-6.0.lib;vtkImagingSources-6.0.lib;vtkImagingStatistics-6.0.lib;vtkImagingStencil-6.0.lib;vtkInfovisCore-6.0.lib;vtkInfovisLayout-6.0.lib;vtkInteractionImage-6.0.lib;vtkInteractionStyle-6.0.lib;vtkInteractionWidgets-6.0.lib;vtkIOAMR-6.0.lib;vtkIOCore-6.0.lib;vtkIOEnSight-6.0.lib;vtkIOExodus-6.0.lib;vtkIOExport-6.0.lib;vtkIOGeometry-6.0.lib;vtkIOImage-6.0.lib;vtkIOImport-6.0.lib;vtkIOInfovis-6.0.lib;vtkIOLegacy-6.0.lib;vtkIOLSDyna-6.0.lib;vtkIOMINC-6.0.lib;vtkIOMovie-6.0.lib;vtkIONetCDF-6.0.lib;vtkIOParallel-6.0.lib;vtkIOPLY-6.0.lib;vtkIOSQL-6.0.lib;vtkIOVideo-6.0.lib;vtkIOXML-6.0.lib;vtkIOXMLParser-6.0.lib;vtkjpeg-6.0.lib;vtkjsoncpp-6.0.lib;vtklibxml2-6.0.lib;vtkLocalExample-6.0.lib;vtkmetaio-6.0.lib;vtkNetCDF_cxx-6.0.lib;vtkNetCDF-6.0.lib;vtkoggtheora-6.0.lib;vtkParallelCore-6.0.lib;vtkpng-6.0.lib;vtkproj4-6.0.lib;vtkRenderingAnnotation-6.0.lib;vtkRenderingContext2D-6.0.lib;vtkRenderingCore-6.0.lib;vtkRenderingFreeType-6.0.lib;vtkRenderingFreeTypeOpenGL-6.0.lib;vtkRenderingGL2PS-6.0.lib;vtkRenderingHybridOpenGL-6.0.lib;vtkRenderingImage-6.0.lib;vtkRenderingLabel-6.0.lib;vtkRenderingLOD-6.0.lib;vtkRenderingOpenGL-6.0.lib;vtkRenderingQt-6.0.lib;vtkRenderingVolume-6.0.lib;vtkRenderingVolumeAMR-6.0.lib;vtkRenderingVolumeOpenGL-6.0.lib;vtksqlite-6.0.lib;vtksys-6.0.lib;vtkTestingGenericBridge-6.0.lib;vtkTestingIOSQL-6.0.lib;vtkTestingRendering-6.0.lib;vtktiff-6.0.lib;vtkverdict-6.0.lib;vtkViewsContext2D-6.0.lib;vtkViewsCore-6.0.lib;vtkViewsGeovis-6.0.lib;vtkViewsInfovis-6.0.lib;vtkViewsQt-6.0.lib;vtkzlib-6.0.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | Level3 68 | 69 | 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | true 75 | 76 | 77 | Console 78 | true 79 | true 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {6ba776b1-cf6c-46b0-a735-647d7211b8d4} 89 | 90 | 91 | {8efede7a-bf56-4a5e-af00-71dd489d8b15} 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /TransformPointCloudTool/TransformPointCloudTool.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /Txt2Pcd/txt2pcd.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "cmd_utility.h" 3 | #include "pcl\io\pcd_io.h" 4 | 5 | #include 6 | #include 7 | 8 | CommandLineArgument cmd_arguments; 9 | pcl::PointCloud::Ptr cloud(new pcl::PointCloud); 10 | bool load_pcd_from_txt(const std::string& filePath, pcl::PointCloud::Ptr cloud); 11 | 12 | int main(int argc, char** argv) 13 | { 14 | // Step 0 15 | if (!cmd_arguments.ParseCommandLineArgument(argc, argv)) 16 | return -1; 17 | 18 | // Step 1 19 | std::cout << "Convert .txt format to .pcd format ...\n"; 20 | if (!load_pcd_from_txt(cmd_arguments.raw_txt_, cloud)) 21 | { 22 | std::cout << ".txt to .pcd fail!\n"; 23 | } 24 | 25 | // Step 2 26 | std::cout << "\nSave ... \n"; 27 | pcl::io::savePCDFile(cmd_arguments.raw_pcd_, *cloud); 28 | 29 | return 0; 30 | } 31 | 32 | bool load_pcd_from_txt(const std::string& filePath, pcl::PointCloud::Ptr cloud) 33 | { 34 | // fill in the cloud data 35 | std::fstream ifs(filePath); 36 | 37 | if(ifs.is_open()) 38 | { 39 | while(!ifs.eof()) 40 | { 41 | pcl::PointXYZ point; 42 | ifs >> point.x >> point.y >> point.z; 43 | 44 | cloud->push_back(point); 45 | } 46 | 47 | ifs.close(); 48 | 49 | return true; 50 | } 51 | return false; 52 | } -------------------------------------------------------------------------------- /Usage: -------------------------------------------------------------------------------- 1 | A working fold should at least has a point cloud file(raw.pcd or raw.txt, in the later case, you should use PreparePcd tool to convert raw.txt to raw.pcd) , 2 | a shape grammar file(grammar.json) and a parameter file(parameters.json). 3 | 4 | Here is the working flow: 5 | 6 | Step 1. If we don't have raw.pcd, instead, we only have raw.txt(in this file, each line contains the tree coordinate of a point, seperated by blank space). 7 | We must Use PreparePcd tool to convert .txt to .pcd.The output of this step is raw.pcd. In this tool, we also remove the outliers in the original point cloud. 8 | 9 | Step 2. Use Downsample tool to downsample the point cloud if need. The result will overwrite the original raw.pcd, so always save a copy before you excute this tool!. 10 | 11 | Step 3. Use TransformPointCloudTool to alignn the point cloud file to X-Y plane. 12 | This step will produce two files: The transformed point cloud plane(pt.pcd) and transformed raw point cloud(rt.pcd). 13 | 14 | Step 4. Use PassthroughFilter to filter the pt.pcd by axe range(optional). 15 | 16 | Step 5. Use CreateGridTool to create facade grid from the transformed point cloud plane. This step will produce these files: files that begin with grid_. Note: the resolution parameter should be defined in the parameters.json! 17 | 18 | Step 6. Use ReviseGridTool to refine the grid. This step will produce these files: files that begin with revise_grid_.Note: The margin_up, margin_down, margin_left and margin_right parameters in the parameter.txt shuld be defined! 19 | 20 | Step 7. Use CalculateFeature tool to calculate the feature so as to extract the action parameter space. This step will produce these files: files that begin with action. 21 | 22 | Step 8. Use ParsingFacadeTool to learn the parsing result. Note: the episodes, load_qtable parameters should be defined in the parameters.json! This step will produce these files: files that begin with result. 23 | 24 | Step 9. Use CompareResultTool to see the original point cloud and learning result at the same time. Refer to the key guid to see how to use different screen short cuts. -------------------------------------------------------------------------------- /key guid: -------------------------------------------------------------------------------- 1 | 2 | | Help: 3 | ------- 4 | p, P : switch to a point-based representation 5 | w, W : switch to a wireframe-based representation (where available) 6 | s, S : switch to a surface-based representation (where available) 7 | 8 | j, J : take a .PNG snapshot of the current window view 9 | c, C : display current camera/window parameters 10 | f, F : fly to point mode 11 | 12 | e, E : exit the interactor 13 | q, Q : stop and call VTK's TerminateApp 14 | 15 | +/- : increment/decrement overall point size 16 | +/- [+ ALT] : zoom in/out 17 | 18 | g, G : display scale grid (on/off) 19 | u, U : display lookup table (on/off) 20 | 21 | r, R [+ ALT] : reset camera [to viewpoint = {0, 0, 0} -> center_{x, y, z}] 22 | 23 | ALT + s, S : turn stereo mode on/off 24 | ALT + f, F : switch between maximized window mode and original size 25 | 26 | l, L : list all available geometric and color handlers for t 27 | he current actor map 28 | ALT + 0..9 [+ CTRL] : switch between different geometric handlers (where av 29 | ailable) 30 | 0..9 [+ CTRL] : switch between different color handlers (where availa 31 | ble) 32 | 33 | SHIFT + left click : select a point 34 | 35 | x, X : toggle rubber band selection mode for left mouse button --------------------------------------------------------------------------------